Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Conversation

@MrAlias MrAlias added pkg:API Related to an API package area:metrics Part of OpenTelemetry Metrics proposal labels Nov 9, 2022
@codecov
Copy link

codecov bot commented Nov 9, 2022

Codecov Report

Merging #3456 (29d1452) into main (484c8bd) will decrease coverage by 0.5%.
The diff coverage is 69.1%.

Additional details and impacted files

Impacted file tree graph

@@           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     
Impacted Files Coverage Δ
metric/config.go 7.9% <0.0%> (-14.8%) ⬇️
metric/instrument/config.go 0.0% <ø> (ø)
sdk/metric/instrument.go 83.3% <ø> (ø)
sdk/metric/pipeline.go 88.6% <38.4%> (-4.9%) ⬇️
sdk/metric/instrument_provider.go 66.6% <70.3%> (-13.4%) ⬇️
metric/internal/global/instruments.go 54.3% <72.2%> (ø)
metric/internal/global/meter.go 86.1% <81.2%> (-10.4%) ⬇️
metric/noop.go 92.3% <96.9%> (-7.7%) ⬇️
sdk/metric/meter.go 100.0% <100.0%> (ø)
... and 5 more

Comment on lines +178 to +180
func WithCallback(callback Callback) ObservableOption {
return callbackOption(callback)
}
Copy link
Contributor

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.
}))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}),
)

@MrAlias MrAlias closed this Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics pkg:API Related to an API package proposal
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants