New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metrics support (WIP) #31
Conversation
debbbef
to
bb7821e
Compare
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 74.32% 70.51% -3.81%
==========================================
Files 60 56 -4
Lines 3131 3229 +98
==========================================
- Hits 2327 2277 -50
- Misses 620 777 +157
+ Partials 184 175 -9
Continue to review full report at Codecov.
|
5af695b
to
57c45c6
Compare
Minimal program to send Prometheus's builtin Go metrics: package main
import (
"github.com/elastic/apm-agent-go"
"github.com/elastic/apm-agent-go/contrib/apmprometheus"
"github.com/prometheus/client_golang/prometheus"
)
func main() {
elasticapm.DefaultTracer.AddMetricsGatherer(apmprometheus.Wrap(prometheus.DefaultGatherer))
elasticapm.DefaultTracer.SendMetrics(nil)
} |
tracer.go
Outdated
} | ||
} | ||
} | ||
timestamp := model.Time(time.Now()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jalvz points out that we need to convert to UTC here
MetricsGatherer is an interface for gathering metrics. You add one to a Tracer using AddMetricsGatherer, and it is periodically called to gather all the metrics. Once they are gathered, they are sent in a payload to the Elastic APM server. Mostly for testing purposes, you can force metrics to be gathered and sent at any given time by calling Tracer.SendMetrics. It has the same sort of behaviour as Tracer.Flush, blocking until the metrics are sent or the abort channel is signaled.
Package apmprometheus provides a method for wrapping a prometheus.Gatherer to adapt it to the elasticapm.MetricsGatherer interface. Untyped, Gauge and Counter metric types are supported; Histogram and and Summary metrics are silently ignored for now.
Support for metrics, including bridges for Prometheus and go-metrics. See commit messages for any non-obvious details.