From b4eb4353438398d1065d67cdeb1b7c262d9bb1fe Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:47:05 -0800 Subject: [PATCH] update readme Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- sdk/metric/internal/x/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/metric/internal/x/README.md b/sdk/metric/internal/x/README.md index 8bc7841d9a2..59f736b733f 100644 --- a/sdk/metric/internal/x/README.md +++ b/sdk/metric/internal/x/README.md @@ -112,11 +112,11 @@ To help users avoid performing computationally expensive operations when recordi The following code shows an example of how to check if an instrument implements the `EnabledInstrument` interface before using the `Enabled` function to avoid doing an expensive computation: ```go -type enabledInstrument interface { Enabled() bool } +type enabledInstrument interface { Enabled(context.Context) bool } ctr, err := m.Int64Counter("expensive-counter") c, ok := ctr.(enabledInstrument) -if c.Enabled() { +if !ok || c.Enabled(context.Background()) { c.Add(expensiveComputation()) } ```