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

where are valuerecorders? #2680

Closed
nerdvegas opened this issue May 12, 2022 · 3 comments
Closed

where are valuerecorders? #2680

nerdvegas opened this issue May 12, 2022 · 3 comments

Comments

@nerdvegas
Copy link

Hi,

I'm new to opentelem and trying to get to grips.

I looked here: https://open-telemetry.github.io/opentelemetry-python/api/metrics.html#opentelemetry.metrics.BoundValueRecorder

..but that doesn't seem to match the code at all. What's going on? I can't tell what version those docs are generated from, it doesn't say anywhere. I am thoroughly confused. Are those docs for an older version? If so, what's the new equivalent of a value recorder?

Thanks
Allan

@srikanthccv
Copy link
Member

@nerdvegas that's based on the old branch which used for some benchmarks. The correct docs lives at here https://opentelemetry-python.readthedocs.io/en/latest/. This is the new equivalent for value recorder.

@CrashLaker
Copy link

hi @srikanthccv,
could you help me please?

back then i used to use create_valuerecorder to push some metrics on demand.

vr = meter.create_valuerecorder(...)
vr.record(value, label)

but now.. how can i replicate the code above?
as far as i understand from the docs https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html
now we can only publish 1 metric_name per callback iteration?

meter.create_observable_counter(
    "system.cpu.time",
    callbacks=[cpu_time_callback({"user", "system"})],
    unit="s",
    description="CPU time"
)

using create_valuerecorder back then we could iterate over many metric names.
for example if i want to have

vrmap = {
   "metric1": meter.create_valuerecorder(...),
   "metric2": meter.create_valuerecorder(...),
   "metric3": meter.create_valuerecorder(...),
}
#payload = from_api_call()
payload = {
  "metric1": 1,
  "metric2": 2,
  "metric3": 3,
}
for k,v in payload.items():
    vrmap[k].record(v, label)

how can we do this now?

@srikanthccv
Copy link
Member

@CrashLaker I guess the equivalent for use case is to use sync gauge which is yet to be added #3462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants