本文整理汇总了Golang中github.com/yvasiyarov/newrelic_platform_go.IComponent类的典型用法代码示例。如果您正苦于以下问题:Golang IComponent类的具体用法?Golang IComponent怎么用?Golang IComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IComponent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: addHTTPStatusMetricsToComponent
// addHTTPStatusMetricsToComponent initializes counter metrics for all http statuses and adds them to the component.
func addHTTPStatusMetricsToComponent(component newrelic_platform_go.IComponent, statusCounters map[int]metrics.Counter) {
for statusCode, counter := range statusCounters {
component.AddMetrica(&counterByStatusMetrica{
counter: counter,
name: fmt.Sprintf("http/status/%d", statusCode),
units: "count",
})
}
}
开发者ID:gistia,项目名称:slackbot,代码行数:10,代码来源:http_status_metrics.go
示例2: Run
//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)
agent.plugin.Client = agent.Client
var component newrelic_platform_go.IComponent
component = newrelic_platform_go.NewPluginComponent(agent.NewrelicName, agent.AgentGUID)
// Add default metrics and tracer.
addRuntimeMericsToComponent(component)
agent.Tracer = newTracer(component)
// Check agent flags and add relevant metrics.
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."))
}
for _, metric := range agent.CustomMetrics {
component.AddMetrica(metric)
agent.debug(fmt.Sprintf("Init %s metric collection.", metric.GetName()))
}
if agent.CollectHTTPStatuses {
agent.initStatusCounters()
component = &resettableComponent{component, agent.HTTPStatusCounters}
addHTTPStatusMetricsToComponent(component, agent.HTTPStatusCounters)
agent.debug(fmt.Sprintf("Init HTTP status metrics collection."))
}
// Init newrelic reporting plugin.
agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
agent.plugin.Verbose = agent.Verbose
// Add our metrics component to the plugin.
agent.plugin.AddComponent(component)
// Start reporting!
go agent.plugin.Run()
return nil
}
开发者ID:gistia,项目名称:slackbot,代码行数:56,代码来源:agent.go
示例3: addGCMericsToComponent
func addGCMericsToComponent(component newrelic_platform_go.IComponent, pollInterval int) {
metrics := []*BaseGoMetrica{
&BaseGoMetrica{
name: "NumberOfGCCalls",
units: "calls",
dataSourceKey: "debug.GCStats.NumGC",
},
&BaseGoMetrica{
name: "PauseTotalTime",
units: "nanoseconds",
dataSourceKey: "debug.GCStats.PauseTotal",
},
}
ds := NewGCMetricaDataSource(pollInterval)
for _, m := range metrics {
m.basePath = "Runtime/GC/"
m.dataSource = ds
component.AddMetrica(&GaugeMetrica{m})
}
histogramMetrics := []*HistogramMetrica{
&HistogramMetrica{
statFunction: HISTOGRAM_MAX,
BaseGoMetrica: &BaseGoMetrica{name: "Max"},
},
&HistogramMetrica{
statFunction: HISTOGRAM_MIN,
BaseGoMetrica: &BaseGoMetrica{name: "Min"},
},
&HistogramMetrica{
statFunction: HISTOGRAM_MEAN,
BaseGoMetrica: &BaseGoMetrica{name: "Mean"},
},
&HistogramMetrica{
statFunction: HISTOGRAM_PERCENTILE,
percentileValue: 0.95,
BaseGoMetrica: &BaseGoMetrica{name: "Percentile95"},
},
}
for _, m := range histogramMetrics {
m.BaseGoMetrica.units = "nanoseconds"
m.BaseGoMetrica.dataSourceKey = "debug.GCStats.Pause"
m.BaseGoMetrica.basePath = "Runtime/GC/GCTime/"
m.BaseGoMetrica.dataSource = ds
component.AddMetrica(m)
}
}
开发者ID:ZhangBanger,项目名称:gorelic,代码行数:49,代码来源:gc_metrics.go
示例4: addGCMericsToComponent
func addGCMericsToComponent(component newrelic_platform_go.IComponent, pollInterval int) {
metrics := []*baseGoMetrica{
&baseGoMetrica{
name: "NumberOfGCCalls",
units: "calls",
dataSourceKey: "debug.GCStats.NumGC",
},
&baseGoMetrica{
name: "PauseTotalTime",
units: "nanoseconds",
dataSourceKey: "debug.GCStats.PauseTotal",
},
}
ds := newGCMetricaDataSource(pollInterval)
for _, m := range metrics {
m.basePath = "Runtime/GC/"
m.dataSource = ds
component.AddMetrica(&gaugeMetrica{m})
}
histogramMetrics := []*histogramMetrica{
&histogramMetrica{
statFunction: histogramMax,
baseGoMetrica: &baseGoMetrica{name: "Max"},
},
&histogramMetrica{
statFunction: histogramMin,
baseGoMetrica: &baseGoMetrica{name: "Min"},
},
&histogramMetrica{
statFunction: histogramMean,
baseGoMetrica: &baseGoMetrica{name: "Mean"},
},
&histogramMetrica{
statFunction: histogramPercentile,
percentileValue: 0.95,
baseGoMetrica: &baseGoMetrica{name: "Percentile95"},
},
}
for _, m := range histogramMetrics {
m.baseGoMetrica.units = "nanoseconds"
m.baseGoMetrica.dataSourceKey = "debug.GCStats.Pause"
m.baseGoMetrica.basePath = "Runtime/GC/GCTime/"
m.baseGoMetrica.dataSource = ds
component.AddMetrica(m)
}
}
开发者ID:CowLeo,项目名称:distribution,代码行数:49,代码来源:gc_metrics.go
示例5: addCounterMericsToComponent
// Helper func to add all our counter metrics to the plugin component
func addCounterMericsToComponent(component newrelic_platform_go.IComponent, counter metrics.Counter, counterName string) {
// with CountedByStatus sampling, counterName looks like <prefix>-<status>
// where prefix is the actual counter name, status is http status code
strParts := strings.Split(counterName, "-")
realCounterName := strParts[0]
statusCode := strParts[1] // WARN: will panic on Counted sampling
ctr := &statusCounterMetrica{
baseCounterMetrica: &baseCounterMetrica{
dataSource: counter,
name: realCounterName + "/http/status/" + statusCode,
units: "Count",
},
}
component.AddMetrica(ctr)
}
开发者ID:rounds,项目名称:newrelic_tigertonic,代码行数:19,代码来源:counted_metrics.go
示例6: addRuntimeMericsToComponent
func addRuntimeMericsToComponent(component newrelic_platform_go.IComponent) {
component.AddMetrica(&NOGoroutinesMetrica{})
component.AddMetrica(&NOCgoCallsMetrica{})
ds := NewSystemMetricaDataSource()
metrics := []*SystemMetrica{
&SystemMetrica{
sourceKey: "Threads",
units: "Threads",
newrelicName: "Runtime/System/Threads",
},
&SystemMetrica{
sourceKey: "FDSize",
units: "fd",
newrelicName: "Runtime/System/FDSize",
},
// Peak virtual memory size
&SystemMetrica{
sourceKey: "VmPeak",
units: "bytes",
newrelicName: "Runtime/System/Memory/VmPeakSize",
},
//Virtual memory size
&SystemMetrica{
sourceKey: "VmSize",
units: "bytes",
newrelicName: "Runtime/System/Memory/VmCurrent",
},
//Peak resident set size
&SystemMetrica{
sourceKey: "VmHWM",
units: "bytes",
newrelicName: "Runtime/System/Memory/RssPeak",
},
//Resident set size
&SystemMetrica{
sourceKey: "VmRSS",
units: "bytes",
newrelicName: "Runtime/System/Memory/RssCurrent",
},
}
for _, m := range metrics {
m.dataSource = ds
component.AddMetrica(m)
}
}
开发者ID:ZhangBanger,项目名称:gorelic,代码行数:46,代码来源:runtime_metrics.go
示例7: addHTTPMericsToComponent
func addHTTPMericsToComponent(component newrelic_platform_go.IComponent, timer metrics.Timer) {
rate1 := &timerRate1Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/throughput/1minute",
units: "rps",
dataSource: timer,
},
}
component.AddMetrica(rate1)
rateMean := &timerRateMeanMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/throughput/rateMean",
units: "rps",
dataSource: timer,
},
}
component.AddMetrica(rateMean)
responseTimeMean := &timerMeanMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/mean",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimeMean)
responseTimeMax := &timerMaxMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/max",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimeMax)
responseTimeMin := &timerMinMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/min",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimeMin)
responseTimePercentile75 := &timerPercentile75Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/percentile75",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimePercentile75)
responseTimePercentile90 := &timerPercentile90Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/percentile90",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimePercentile90)
responseTimePercentile95 := &timerPercentile95Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: "http/responseTime/percentile95",
units: "ms",
dataSource: timer,
},
}
component.AddMetrica(responseTimePercentile95)
}
开发者ID:CowLeo,项目名称:distribution,代码行数:73,代码来源:http_metrics.go
示例8: addMemoryMericsToComponent
func addMemoryMericsToComponent(component newrelic_platform_go.IComponent, pollInterval int) {
gaugeMetrics := []*baseGoMetrica{
//Memory in use metrics
&baseGoMetrica{
name: "InUse/Total",
units: "bytes",
dataSourceKey: "runtime.MemStats.Alloc",
},
&baseGoMetrica{
name: "InUse/Heap",
units: "bytes",
dataSourceKey: "runtime.MemStats.HeapAlloc",
},
&baseGoMetrica{
name: "InUse/Stack",
units: "bytes",
dataSourceKey: "runtime.MemStats.StackInuse",
},
&baseGoMetrica{
name: "InUse/MSpanInuse",
units: "bytes",
dataSourceKey: "runtime.MemStats.MSpanInuse",
},
&baseGoMetrica{
name: "InUse/MCacheInuse",
units: "bytes",
dataSourceKey: "runtime.MemStats.MCacheInuse",
},
}
ds := newMemoryMetricaDataSource(pollInterval)
for _, m := range gaugeMetrics {
m.basePath = "Runtime/Memory/"
m.dataSource = ds
component.AddMetrica(&gaugeMetrica{m})
}
gaugeIncMetrics := []*baseGoMetrica{
//NO operations graph
&baseGoMetrica{
name: "Operations/NoPointerLookups",
units: "lookups",
dataSourceKey: "runtime.MemStats.Lookups",
},
&baseGoMetrica{
name: "Operations/NoMallocs",
units: "mallocs",
dataSourceKey: "runtime.MemStats.Mallocs",
},
&baseGoMetrica{
name: "Operations/NoFrees",
units: "frees",
dataSourceKey: "runtime.MemStats.Frees",
},
// Sytem memory allocations
&baseGoMetrica{
name: "SysMem/Total",
units: "bytes",
dataSourceKey: "runtime.MemStats.Sys",
},
&baseGoMetrica{
name: "SysMem/Heap",
units: "bytes",
dataSourceKey: "runtime.MemStats.HeapSys",
},
&baseGoMetrica{
name: "SysMem/Stack",
units: "bytes",
dataSourceKey: "runtime.MemStats.StackSys",
},
&baseGoMetrica{
name: "SysMem/MSpan",
units: "bytes",
dataSourceKey: "runtime.MemStats.MSpanSys",
},
&baseGoMetrica{
name: "SysMem/MCache",
units: "bytes",
dataSourceKey: "runtime.MemStats.MCacheSys",
},
&baseGoMetrica{
name: "SysMem/BuckHash",
units: "bytes",
dataSourceKey: "runtime.MemStats.BuckHashSys",
},
}
for _, m := range gaugeIncMetrics {
m.basePath = "Runtime/Memory/"
m.dataSource = ds
component.AddMetrica(&gaugeIncMetrica{baseGoMetrica: m})
}
}
开发者ID:CowLeo,项目名称:distribution,代码行数:93,代码来源:memory_metrics.go
示例9: addMetricsToComponent
func (transaction *TraceTransaction) addMetricsToComponent(component newrelic_platform_go.IComponent) {
rate1 := &timerRate1Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/throughput/1minute",
units: "rps",
dataSource: transaction.timer,
},
}
component.AddMetrica(rate1)
rateMean := &timerRateMeanMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/throughput/rateMean",
units: "rps",
dataSource: transaction.timer,
},
}
component.AddMetrica(rateMean)
tracerMean := &timerMeanMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/mean",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMean)
tracerMax := &timerMaxMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/max",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMax)
tracerMin := &timerMinMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/min",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMin)
tracer75 := &timerPercentile75Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/percentile75",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer75)
tracer90 := &timerPercentile90Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/percentile90",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer90)
tracer95 := &timerPercentile95Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/percentile95",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer95)
tracer99 := &timerPercentile99Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/responseTime/percentile99",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer99)
}
开发者ID:jordanshoebox,项目名称:gorelic,代码行数:83,代码来源:tracer_metrics.go
示例10: addMetricsToComponent
func (transaction *TraceTransaction) addMetricsToComponent(component newrelic_platform_go.IComponent) {
tracerMean := &timerMeanMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/mean",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMean)
tracerMax := &timerMaxMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/max",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMax)
tracerMin := &timerMinMetrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/min",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracerMin)
tracer75 := &timerPercentile75Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/percentile75",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer75)
tracer90 := &timerPercentile90Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/percentile90",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer90)
tracer95 := &timerPercentile95Metrica{
baseTimerMetrica: &baseTimerMetrica{
name: transaction.name + "/percentile95",
units: "ms",
dataSource: transaction.timer,
},
}
component.AddMetrica(tracer95)
}
开发者ID:gistia,项目名称:slackbot,代码行数:55,代码来源:tracer_metrics.go
注:本文中的github.com/yvasiyarov/newrelic_platform_go.IComponent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论