@@ -95,7 +95,7 @@ class OtlpFileExporterTestPeer : public ::testing::Test
9595 resource_attributes[" vec_uint64_value" ] = std::vector<uint64_t >{7 , 8 };
9696 resource_attributes[" vec_double_value" ] = std::vector<double >{3.2 , 3.3 };
9797 resource_attributes[" vec_string_value" ] = std::vector<std::string>{" vector" , " string" };
98- auto resource = resource::Resource::Create (resource_attributes);
98+ auto resource = resource::Resource::Create (resource_attributes, " resource_url " );
9999
100100 auto processor_opts = sdk::trace::BatchSpanProcessorOptions ();
101101 processor_opts.max_export_batch_size = 5 ;
@@ -109,9 +109,17 @@ class OtlpFileExporterTestPeer : public ::testing::Test
109109
110110 std::string report_trace_id;
111111
112+ #if OPENTELEMETRY_ABI_VERSION_NO >= 2
113+ auto tracer = provider->GetTracer (" scope_name" , " scope_version" , " scope_url" ,
114+ {{ " scope_key" ,
115+ " scope_value" }});
116+ #else
117+ auto tracer = provider->GetTracer (" scope_name" , " scope_version" , " scope_url" );
118+ #endif
119+
120+ auto parent_span = tracer->StartSpan (" Test parent span" );
121+
112122 char trace_id_hex[2 * trace_api::TraceId::kSize ] = {0 };
113- auto tracer = provider->GetTracer (" test" );
114- auto parent_span = tracer->StartSpan (" Test parent span" );
115123
116124 trace_api::StartSpanOptions child_span_opts = {};
117125 child_span_opts.parent = parent_span->GetContext ();
@@ -136,11 +144,22 @@ class OtlpFileExporterTestPeer : public ::testing::Test
136144 auto check_json = nlohmann::json::parse (check_json_text, nullptr , false );
137145 if (!check_json.is_discarded ())
138146 {
139- auto resource_span = *check_json[" resourceSpans" ].begin ();
140- auto scope_span = *resource_span[" scopeSpans" ].begin ();
141- auto span = *scope_span[" spans" ].begin ();
142- auto received_trace_id = span[" traceId" ].get <std::string>();
143- EXPECT_EQ (received_trace_id, report_trace_id);
147+ auto resource_span = *check_json[" resourceSpans" ].begin ();
148+ auto scope_span = *resource_span[" scopeSpans" ].begin ();
149+ auto scope = scope_span[" scope" ];
150+ auto span = *scope_span[" spans" ].begin ();
151+
152+ #if OPENTELEMETRY_ABI_VERSION_NO >= 2
153+ ASSERT_EQ (1 , scope[" attributes" ].size ());
154+ const auto scope_attribute = scope[" attributes" ].front ();
155+ EXPECT_EQ (" scope_key" , scope_attribute[" key" ].get <std::string>());
156+ EXPECT_EQ (" scope_value" , scope_attribute[" value" ][" stringValue" ].get <std::string>());
157+ #endif
158+ EXPECT_EQ (" resource_url" , resource_span[" schemaUrl" ].get <std::string>());
159+ EXPECT_EQ (" scope_url" , scope_span[" schemaUrl" ].get <std::string>());
160+ EXPECT_EQ (" scope_name" , scope[" name" ].get <std::string>());
161+ EXPECT_EQ (" scope_version" , scope[" version" ].get <std::string>());
162+ EXPECT_EQ (report_trace_id, span[" traceId" ].get <std::string>());
144163 }
145164 else
146165 {
0 commit comments