mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-03-25 21:28:58 +02:00
Add comment to other observable instruments about repeated creation with callbacks (#5606)
In https://github.com/open-telemetry/opentelemetry-go/pull/4820, I only added a comment describing the behavior to `Int64ObservableCounter`, but forgot other instruments. This adds the comment to all observable instruments. Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5561 --------- Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
776ceb7cc9
commit
9535f08920
@ -31,6 +31,14 @@
|
||||
// is being run on. That way when multiple instances of the code are collected
|
||||
// at a single endpoint their origin is decipherable.
|
||||
//
|
||||
// To avoid leaking memory, the SDK returns the same instrument for calls to
|
||||
// create new instruments with the same Name, Unit, and Description.
|
||||
// Importantly, callbacks provided using metric.WithFloat64Callback or
|
||||
// metric.WithInt64Callback will only apply for the first instrument created
|
||||
// with a given Name, Unit, and Description. Instead, use
|
||||
// Meter.RegisterCallback and Registration.Unregister to add and remove
|
||||
// callbacks without leaking memory.
|
||||
//
|
||||
// See [go.opentelemetry.io/otel/metric] for more information about
|
||||
// the metric API.
|
||||
//
|
||||
|
@ -185,6 +185,11 @@ func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64Obser
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// int64 measurements once per a measurement collection cycle. Only the
|
||||
// measurements recorded during the collection cycle are exported.
|
||||
//
|
||||
// If Int64ObservableUpDownCounter is invoked repeatedly with the same Name,
|
||||
// Description, and Unit, only the first set of callbacks provided are used.
|
||||
// Use meter.RegisterCallback and Registration.Unregister to manage callbacks
|
||||
// if instrumentation can be created multiple times with different callbacks.
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
cfg := metric.NewInt64ObservableUpDownCounterConfig(options...)
|
||||
id := Instrument{
|
||||
@ -201,6 +206,11 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int6
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// instantaneous int64 measurements once per a measurement collection cycle.
|
||||
// Only the measurements recorded during the collection cycle are exported.
|
||||
//
|
||||
// If Int64ObservableGauge is invoked repeatedly with the same Name,
|
||||
// Description, and Unit, only the first set of callbacks provided are used.
|
||||
// Use meter.RegisterCallback and Registration.Unregister to manage callbacks
|
||||
// if instrumentation can be created multiple times with different callbacks.
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
cfg := metric.NewInt64ObservableGaugeConfig(options...)
|
||||
id := Instrument{
|
||||
@ -334,6 +344,11 @@ func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64O
|
||||
// and configured with options. The instrument is used to asynchronously record
|
||||
// float64 measurements once per a measurement collection cycle. Only the
|
||||
// measurements recorded during the collection cycle are exported.
|
||||
//
|
||||
// If Float64ObservableUpDownCounter is invoked repeatedly with the same Name,
|
||||
// Description, and Unit, only the first set of callbacks provided are used.
|
||||
// Use meter.RegisterCallback and Registration.Unregister to manage callbacks
|
||||
// if instrumentation can be created multiple times with different callbacks.
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
cfg := metric.NewFloat64ObservableUpDownCounterConfig(options...)
|
||||
id := Instrument{
|
||||
@ -350,6 +365,11 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Fl
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// instantaneous float64 measurements once per a measurement collection cycle.
|
||||
// Only the measurements recorded during the collection cycle are exported.
|
||||
//
|
||||
// If Float64ObservableGauge is invoked repeatedly with the same Name,
|
||||
// Description, and Unit, only the first set of callbacks provided are used.
|
||||
// Use meter.RegisterCallback and Registration.Unregister to manage callbacks
|
||||
// if instrumentation can be created multiple times with different callbacks.
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
cfg := metric.NewFloat64ObservableGaugeConfig(options...)
|
||||
id := Instrument{
|
||||
|
Loading…
x
Reference in New Issue
Block a user