コード例 #1
0
ファイル: agent.go プロジェクト: jskrzypek/jqplay
//Run initialize Agent instance and start harvest go routine
func (agent *Agent) Run() error {
	if agent.NewrelicLicense == "" {
		return errors.New("please, pass a valid newrelic license key")
	}

	agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
	component := newrelic_platform_go.NewPluginComponent(agent.NewrelicName, agent.AgentGUID)
	agent.plugin.AddComponent(component)

	addRuntimeMericsToComponent(component)

	if agent.CollectGcStat {
		addGCMericsToComponent(component, agent.GCPollInterval)
		agent.debug(fmt.Sprintf("Init GC metrics collection. Poll interval %d seconds.", agent.GCPollInterval))
	}
	if agent.CollectMemoryStat {
		addMemoryMericsToComponent(component, agent.MemoryAllocatorPollInterval)
		agent.debug(fmt.Sprintf("Init memory allocator metrics collection. Poll interval %d seconds.", agent.MemoryAllocatorPollInterval))
	}

	if agent.CollectHTTPStat {
		agent.initTimer()
		addHTTPMericsToComponent(component, agent.HTTPTimer)
		agent.debug(fmt.Sprintf("Init HTTP metrics collection."))
	}

	agent.plugin.Verbose = agent.Verbose
	go agent.plugin.Run()
	return nil
}
コード例 #2
0
ファイル: wave_plugin.go プロジェクト: jskrzypek/jqplay
func main() {
	plugin := newrelic_platform_go.NewNewrelicPlugin("0.0.1", "7bceac019c7dcafae1ef95be3e3a3ff8866de246", 60)
	component := newrelic_platform_go.NewPluginComponent("Wave component", "com.exmaple.plugin.gowave")
	plugin.AddComponent(component)

	m := &WaveMetrica{
		sawtoothMax:     10,
		sawtoothCounter: 5,
	}
	component.AddMetrica(m)

	m1 := &SquareWaveMetrica{
		squarewaveMax:     4,
		squarewaveCounter: 1,
	}
	component.AddMetrica(m1)

	plugin.Verbose = true
	plugin.Run()
}