-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] OTEL / Prom metrics benchmark #5676
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: Saransh Shankar <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
…into OTEL_Metrics
Signed-off-by: Wise-Wizard <[email protected]>
tested via ``` $ go test -benchmem -benchtime=5s -bench=Benchmark ./internal/metrics/ ``` before: ``` BenchmarkPrometheusCounter-10 856818336 6.875 ns/op 0 B/op 0 allocs/op BenchmarkOTELCounter-10 146044255 40.92 ns/op 32 B/op 2 allocs/op ``` after: `` BenchmarkPrometheusCounter-10 855046669 6.924 ns/op 0 B/op 0 allocs/op BenchmarkOTELCounter-10 293330721 21.05 ns/op 16 B/op 1 allocs/op ``` Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Wise-Wizard <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5676 +/- ##
=======================================
Coverage 96.36% 96.36%
=======================================
Files 329 329
Lines 16060 16060
=======================================
Hits 15477 15477
Misses 405 405
Partials 178 178
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
TODO: add Opencensus as implementation, for comparison |
Signed-off-by: Yuri Shkuro <[email protected]>
attrSet := attribute.NewSet(attribute.String("tag1", "value1")) | ||
attrOpt := metric.WithAttributeSet(attrSet) | ||
|
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.
Curious how you feel about these two lines, and why you've excluded them from the benchmark? Ergonomically speaking, would you cache the attrOpt
value after computing it? If so, you'd be better off with bound instruments. If not, you should measure it. I ask because the introduction of functional options adds a bunch of allocations, so unless you compute and re-use the []Option slice, you've either got an ergonomics problem or a performance problem. We stopped using the OTel-Go API as a result of this and installed a more-efficient functional-option-free bypass. lightstep/otel-launcher-go#446
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.
Ergonomically speaking, would you cache the attrOpt value after computing it?
@jmacd yes, that's exactly what Jaeger is doing, we always used "bound" instruments.
jaeger/internal/metrics/otelmetrics/counter.go
Lines 12 to 20 in 8a33800
type otelCounter struct { | |
counter metric.Int64Counter | |
fixedCtx context.Context | |
option metric.AddOption | |
} | |
func (c *otelCounter) Inc(value int64) { | |
c.counter.Add(c.fixedCtx, value, c.option) | |
} |
But this does not help to completely avoid allocations. It's not the passing of vararg options that's causing the allocations, it's something deeper in the implementation.
Signed-off-by: Yuri Shkuro <[email protected]>
Note that the benchmarks are designed to minimize the perf impact of counter bumps using "bounded instruments". Jaeger code always caches the instruments when some of the labels are dynamic (e.g. counts of received spans labeled with emitting service name)