From d22d958b4a53bb90b393e8505b448aba4e67dbcc Mon Sep 17 00:00:00 2001 From: Cedric Sirianni Date: Thu, 19 Mar 2026 14:57:23 -0400 Subject: [PATCH] SERVER-122162: Fix syntax errors in otel/metrics/README.md (#49992) GitOrigin-RevId: d970af7f6b09798cf0f0e2548d13c5fa4bb52d66 --- src/mongo/otel/metrics/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mongo/otel/metrics/README.md b/src/mongo/otel/metrics/README.md index 7658b76a2f5..093bc2881d4 100644 --- a/src/mongo/otel/metrics/README.md +++ b/src/mongo/otel/metrics/README.md @@ -14,7 +14,7 @@ Metrics are created by calling the `create*` functions on the #include "mongo/otel/metrics/metrics_service.h" namespace { -Counter& operationsCounter = otel::metrics::MetricsService::instance().createInt64Counter( +auto& operationsCounter = otel::metrics::MetricsService::instance().createInt64Counter( otel::metrics::MetricNames::kQueryCount, // name "Number of queries executed", // description otel::metrics::MetricUnit::kQueries); // unit @@ -101,8 +101,8 @@ auto& counter = otel::metrics::MetricsService::instance().createInt64Counter( "Total number of operations performed", otel::metrics::MetricUnit::kOperations); -counter->add(1); // Increment by 1 -counter->add(10); // Increment by 10 +counter.add(1); // Increment by 1 +counter.add(10); // Increment by 10 ``` **Important:** Counter values must only increase. Attempting to add a negative value will throw an @@ -186,7 +186,7 @@ Counter& counter = MetricsService::instance().createInt64Counter(...); } // namespace void doWork() { - counter->add(1); + counter.add(1); } ``` @@ -194,7 +194,7 @@ void doWork() { // BAD: Creates/looks up metric on every call void doWork() { auto& counter = MetricsService::instance().createInt64Counter(...); // Slow: acquires lock - counter->add(1); + counter.add(1); } ``` @@ -224,7 +224,7 @@ TEST(MyFeatureTest, RecordsMetrics) { otel::metrics::MetricNames::kMyFeatureEvents, "Number of events processed", otel::metrics::MetricUnit::kOperations); - counter->add(5); + counter.add(5); // Some variants don't currently include otel (notably Windows and some suse variants) so // always condition on if metrics can be read if your tests will run in one of those variants.