From 1f6d0d3e75f263244f9ad2cadd3e1bcd432c39e6 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Wed, 10 Jul 2024 18:53:55 +0000 Subject: [PATCH] add note to SDK package documentation --- sdk/metric/doc.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/metric/doc.go b/sdk/metric/doc.go index 4f553a57153..512b2114a34 100644 --- a/sdk/metric/doc.go +++ b/sdk/metric/doc.go @@ -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 Unit, Name, 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. //