-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 Metric API refactor #3456
WIP Metric API refactor #3456
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3456 +/- ##
=======================================
- Coverage 77.6% 77.1% -0.6%
=======================================
Files 164 164
Lines 11651 11614 -37
=======================================
- Hits 9050 8957 -93
- Misses 2392 2450 +58
+ Partials 209 207 -2
|
func WithCallback(callback Callback) ObservableOption { | ||
return callbackOption(callback) | ||
} |
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.
How do you practically use this WithCallback?
ctr := meter.Int64ObservableCounter("stuff", WithCallback(func(ctx context.Context){
ctr.Observe(ctx, 1) // Where is ctr defined? ctr will only be available after this clojure is defined.
}))
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.
opentelemetry-go/metric/example_test.go
Lines 54 to 66 in 29d1452
var memoryUsage metric.Int64ObservableGauge | |
memoryUsage, err := meter.Int64ObservableGauge( | |
"MemoryUsage", | |
metric.WithUnit(unit.Bytes), | |
metric.WithCallback(func(ctx context.Context) error { | |
// Do Work to get the real memoryUsage. | |
// mem := GatherMemory(ctx) | |
mem := 75000 | |
memoryUsage.Observe(ctx, int64(mem)) | |
return nil | |
}), | |
) |
Related to and possibly fixes: