diff --git a/src/mongo/otel/traces/bson_text_map_carrier.cpp b/src/mongo/otel/traces/bson_text_map_carrier.cpp index 34518fc66f9..e96c6bdbd8e 100644 --- a/src/mongo/otel/traces/bson_text_map_carrier.cpp +++ b/src/mongo/otel/traces/bson_text_map_carrier.cpp @@ -47,7 +47,7 @@ BSONTextMapCarrier::BSONTextMapCarrier(const BSONObj& bson) { OtelStringView BSONTextMapCarrier::Get(OtelStringView key) const noexcept { auto it = _values.find(key); if (it == _values.end()) { - return {}; + return kMissingKeyReturnValue; } return it->second; } diff --git a/src/mongo/otel/traces/bson_text_map_carrier.h b/src/mongo/otel/traces/bson_text_map_carrier.h index 21364006d74..0ef0163b0cb 100644 --- a/src/mongo/otel/traces/bson_text_map_carrier.h +++ b/src/mongo/otel/traces/bson_text_map_carrier.h @@ -39,6 +39,9 @@ namespace mongo { namespace otel { namespace traces { +// TODO SERVER-112886: Once this ticket is resolved this should be changed back to an empty string. +constexpr OtelStringView kMissingKeyReturnValue = " "; + using opentelemetry::nostd::function_ref; /** diff --git a/src/mongo/otel/traces/bson_text_map_carrier_test.cpp b/src/mongo/otel/traces/bson_text_map_carrier_test.cpp index c1712056051..5a9b8207865 100644 --- a/src/mongo/otel/traces/bson_text_map_carrier_test.cpp +++ b/src/mongo/otel/traces/bson_text_map_carrier_test.cpp @@ -63,7 +63,7 @@ TEST(BSONTextMapCarrier, GetExistingKey) { TEST(BSONTextMapCarrier, GetMissingKey) { BSONTextMapCarrier carrier; - ASSERT_EQ(carrier.Get(keyA), ""); + ASSERT_EQ(carrier.Get(keyA), kMissingKeyReturnValue); } TEST(BSONTextMapCarrier, SetExistingKey) { @@ -127,7 +127,7 @@ TEST(BSONTextMapCarrier, NonStringFieldsIgnored) { ASSERT_EQ(keys.size(), 1); ASSERT_TRUE(keys.contains(keyA)); ASSERT_EQ(carrier.Get(keyA), valueA); - ASSERT_EQ(carrier.Get("uuid"), ""); + ASSERT_EQ(carrier.Get("uuid"), kMissingKeyReturnValue); } } // namespace diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index 2e2bd493983..99bfd634d4d 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -353,10 +353,9 @@ let _jsTestOptions = {}; function jsTestOptions() { if (TestData) { - // TODO (SERVER-112812): Enable OpenTelemetry tracing. - // const isMultiversion = - // TestData.useRandomBinVersionsWithinReplicaSet || TestData.mixedBinVersions || TestData.mongosBinVersion; - const enableOTELTracing = false; //TestData.enableOTELTracing ?? !isMultiversion; + const isMultiversion = + TestData.useRandomBinVersionsWithinReplicaSet || TestData.mixedBinVersions || TestData.mongosBinVersion; + const enableOTELTracing = TestData.enableOTELTracing ?? !isMultiversion; return Object.merge(_jsTestOptions, { // Test commands should be enabled by default if no enableTestCommands were present in