Skip to content

Provide conventional way to retrieve metric values  #486

@kofalt

Description

@kofalt

Sometimes an observed metric is useful internally. I was surprised to see that it wasn't very straightforward to retrieve the current value from a declared Metric variable.

Gauge & etc are already concurrency safe, so it wouldn't make any sense to store the value a second time. But because their state vars are not package-exported (rightfully so), it's not as easy as just calling the same Float64frombits stuff that's used internally.

I think this is the easiest way right now to pull a metric's value back out:

store := new(dto.Metric)

SomeGauge.Write(store) # this call could fail, while the internal float-fetch cannot!

Println("The gauge is reading", *store.Gauge.Value)

It would be nice to just have Gauge.Get() float64 and equivalents instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions