diff --git a/sdk/include/opentelemetry/sdk/metrics/instrument.h b/sdk/include/opentelemetry/sdk/metrics/instrument.h index 85de5ee701..802e201bc6 100644 --- a/sdk/include/opentelemetry/sdk/metrics/instrument.h +++ b/sdk/include/opentelemetry/sdk/metrics/instrument.h @@ -244,11 +244,9 @@ inline void print_value(std::stringstream &ss, switch (value.index()) { case common::AttributeType::TYPE_STRING: - if (jsonTypes) - ss << '"'; + ss << nostd::get(value); - if (jsonTypes) - ss << '"'; + break; default: #if __EXCEPTIONS @@ -282,7 +280,7 @@ inline std::string KvToString(const trace::KeyValueIterable &kv) noexcept { size_t i = 1; kv.ForEachKeyValue([&](nostd::string_view key, common::AttributeValue value) noexcept { - ss << "\"" << key << "\":"; + ss << key << ":"; print_value(ss, value, true); if (size != i) { diff --git a/sdk/test/metrics/metric_instrument_test.cc b/sdk/test/metrics/metric_instrument_test.cc index 3caf526010..28ca482375 100644 --- a/sdk/test/metrics/metric_instrument_test.cc +++ b/sdk/test/metrics/metric_instrument_test.cc @@ -35,7 +35,7 @@ TEST(ApiSdkConversion, async) alpha->observe(123456, labelkv); EXPECT_EQ(dynamic_cast *>(alpha.get())->GetRecords()[0].GetLabels(), - "{\"key587\":\"value264\"}"); + "{key587:value264}"); alpha->observe(123456, labelkv); AggregatorVariant canCollect = @@ -258,7 +258,7 @@ TEST(Counter, getAggsandnewupdate) EXPECT_EQ(theta.size(), 1); EXPECT_EQ(theta[0].GetName(), "test"); EXPECT_EQ(theta[0].GetDescription(), "none"); - EXPECT_EQ(theta[0].GetLabels(), "{\"key2\":\"value2\",\"key3\":\"value3\"}"); + EXPECT_EQ(theta[0].GetLabels(), "{key2:value2,key3:value3}"); } void CounterCallback(std::shared_ptr> in,