@@ -1408,6 +1408,48 @@ private static Stream<Arguments> exemplarLabelLimitArgs() {
14081408 new String [] {}));
14091409 }
14101410
1411+ @ ParameterizedTest
1412+ @ MethodSource ("exemplarSpanContextLabelsTakePrecedenceArgs" )
1413+ void exemplarSpanContextLabelsTakePrecedence (Attributes filteredAttributes ) {
1414+ SpanContext spanContext =
1415+ SpanContext .create (
1416+ "00000000000000000000000000000001" ,
1417+ "0000000000000001" ,
1418+ TraceFlags .getSampled (),
1419+ TraceState .getDefault ());
1420+ ImmutableDoubleExemplarData exemplar =
1421+ (ImmutableDoubleExemplarData )
1422+ ImmutableDoubleExemplarData .create (filteredAttributes , 1000L , spanContext , 1.0 );
1423+
1424+ MetricData metricData =
1425+ ImmutableMetricData .createDoubleGauge (
1426+ Resource .getDefault (),
1427+ InstrumentationScopeInfo .create ("test" ),
1428+ "my.gauge" ,
1429+ "desc" ,
1430+ "unit" ,
1431+ ImmutableGaugeData .create (
1432+ Collections .singletonList (
1433+ ImmutableDoublePointData .create (
1434+ 0 , 1000 , Attributes .empty (), 1.0 , Collections .singletonList (exemplar )))));
1435+
1436+ MetricSnapshots snapshots = converter .convert (Collections .singletonList (metricData ));
1437+ GaugeDataPointSnapshot point = (GaugeDataPointSnapshot ) snapshots .get (0 ).getDataPoints ().get (0 );
1438+ Labels exemplarLabels = point .getExemplar ().getLabels ();
1439+ assertThat (exemplarLabels .get ("trace_id" )).isEqualTo ("00000000000000000000000000000001" );
1440+ assertThat (exemplarLabels .get ("span_id" )).isEqualTo ("0000000000000001" );
1441+ }
1442+
1443+ private static Stream <Arguments > exemplarSpanContextLabelsTakePrecedenceArgs () {
1444+ return Stream .of (
1445+ Arguments .argumentSet (
1446+ "sameLabelName" ,
1447+ Attributes .of (stringKey ("trace_id" ), "bogus" , stringKey ("span_id" ), "bogus" )),
1448+ Arguments .argumentSet (
1449+ "sameLabelNameAfterEscaping" ,
1450+ Attributes .of (stringKey ("trace.id" ), "bogus" , stringKey ("span.id" ), "bogus" )));
1451+ }
1452+
14111453 private static InfoSnapshot makeInfoSnapshot (String id ) {
14121454 return new InfoSnapshot (
14131455 MetricMetadata .builder ().name ("target" ).build (),
0 commit comments