@@ -122,7 +122,7 @@ public final class AzureMonitorTraceExporter implements SpanExporter {
122122 */
123123 @ Override
124124 public CompletableResultCode export (Collection <SpanData > spans ) {
125-
125+ CompletableResultCode completableResultCode = new CompletableResultCode ();
126126 try {
127127 List <TelemetryItem > telemetryItems = new ArrayList <>();
128128 for (SpanData span : spans ) {
@@ -131,11 +131,11 @@ public CompletableResultCode export(Collection<SpanData> spans) {
131131 }
132132 client .export (telemetryItems )
133133 .subscriberContext (Context .of (Tracer .DISABLE_TRACING_KEY , true ))
134- .subscribe ();
135- return CompletableResultCode . ofSuccess () ;
134+ .subscribe (ignored -> { }, error -> completableResultCode . fail (), completableResultCode :: succeed );
135+ return completableResultCode ;
136136 } catch (Throwable t ) {
137137 logger .error (t .getMessage (), t );
138- return CompletableResultCode . ofFailure ();
138+ return completableResultCode . fail ();
139139 }
140140 }
141141
@@ -160,25 +160,18 @@ private void export(SpanData span, List<TelemetryItem> telemetryItems) {
160160 String instrumentationName = span .getInstrumentationLibraryInfo ().getName ();
161161 Matcher matcher = COMPONENT_PATTERN .matcher (instrumentationName );
162162 String stdComponent = matcher .matches () ? matcher .group (1 ) : null ;
163- if ("jms" .equals (stdComponent ) && !span .getParentSpanContext ().isValid () && kind == SpanKind .CONSUMER ) {
164- // no need to capture these, at least is consistent with prior behavior
165- // these tend to be frameworks pulling messages which are then pushed to consumers
166- // where we capture them
167- return ;
168- }
169163 if (kind == SpanKind .INTERNAL ) {
170164 if ("spring-scheduling" .equals (stdComponent ) && !span .getParentSpanContext ().isValid ()) {
171- // TODO (srnagar) need semantic convention for determining whether to map INTERNAL to request or dependency
172- // (or need clarification to use SERVER for this)
165+ // if (!span.getParentSpanContext().isValid()) {
166+ // TODO (trask) need semantic convention for determining whether to map INTERNAL to request or
167+ // dependency (or need clarification to use SERVER for this)
173168 exportRequest (span , telemetryItems );
174169 } else {
175170 exportRemoteDependency (span , true , telemetryItems );
176171 }
177172 } else if (kind == SpanKind .CLIENT || kind == SpanKind .PRODUCER ) {
178173 exportRemoteDependency (span , false , telemetryItems );
179174 } else if (kind == SpanKind .CONSUMER && !span .getParentSpanContext ().isRemote ()) {
180- // TODO (srnagar) need spec clarification, but it seems polling for messages can be CONSUMER also
181- // in which case the span will not have a remote parent and should be treated as a dependency instead of a request
182175 exportRemoteDependency (span , false , telemetryItems );
183176 } else if (kind == SpanKind .SERVER || kind == SpanKind .CONSUMER ) {
184177 exportRequest (span , telemetryItems );
@@ -199,6 +192,7 @@ private static List<TelemetryExceptionDetails> minimalParse(String errorStack) {
199192 } else {
200193 details .setTypeName (line );
201194 }
195+ // TODO (trask): map OpenTelemetry exception to Application Insights exception better
202196 details .setStack (errorStack );
203197 return Collections .singletonList (details );
204198 }
@@ -305,7 +299,7 @@ private void applyHttpClientSpan(Attributes attributes, RemoteDependencyData tel
305299 target += ":" + uri .getPort ();
306300 }
307301 } catch (URISyntaxException e ) {
308- // TODO (srnagar ) "log once"
302+ // TODO (trask ) "log once"
309303 logger .error (e .getMessage ());
310304 logger .verbose (e .getMessage (), e );
311305 }
@@ -323,7 +317,7 @@ private void applyHttpClientSpan(Attributes attributes, RemoteDependencyData tel
323317 } else {
324318 // using "Http (tracked component)" is important for dependencies that go cross-component (have an appId in their target field)
325319 // if you use just HTTP, Breeze will remove appid from the target
326- // TODO (srnagar ) remove this once confirmed by zakima that it is no longer needed
320+ // TODO (trask ) remove this once confirmed by zakima that it is no longer needed
327321 telemetry .setType ("Http (tracked component)" );
328322 telemetry .setTarget (target + " | " + targetAppId );
329323 }
@@ -413,9 +407,8 @@ private void applyMessagingClientSpan(Attributes attributes, RemoteDependencyDat
413407
414408 private static int getDefaultPortForDbSystem (String dbSystem ) {
415409 switch (dbSystem ) {
416- // TODO (srnagar) replace these with constants from OpenTelemetry API after upgrading to 0.10.0
417- // TODO (srnagar) add these default ports to the OpenTelemetry database semantic conventions spec
418- // TODO (srnagar) need to add more default ports once jdbc instrumentation reports net.peer.*
410+ // TODO (trask) add these default ports to the OpenTelemetry database semantic conventions spec
411+ // TODO (trask) need to add more default ports once jdbc instrumentation reports net.peer.*
419412 case "mongodb" :
420413 return 27017 ;
421414 case "cassandra" :
@@ -454,7 +447,7 @@ private void exportRequest(SpanData span, List<TelemetryItem> telemetryItems) {
454447 if (source == null ) {
455448 String messagingSystem = attributes .get (SemanticAttributes .MESSAGING_SYSTEM );
456449 if (messagingSystem != null ) {
457- // TODO (srnagar ) should this pass default port for messaging.system?
450+ // TODO (trask ) should this pass default port for messaging.system?
458451 source = nullAwareConcat (getTargetFromPeerAttributes (attributes , 0 ),
459452 attributes .get (SemanticAttributes .MESSAGING_DESTINATION ), "/" );
460453 if (source == null ) {
@@ -565,16 +558,10 @@ private void exportEvents(SpanData span, Double samplingPercentage, List<Telemet
565558
566559 if (event .getAttributes ().get (SemanticAttributes .EXCEPTION_TYPE ) != null
567560 || event .getAttributes ().get (SemanticAttributes .EXCEPTION_MESSAGE ) != null ) {
568- // TODO (srnagar): Remove this boolean after we can confirm that the exception duplicate
569- // is a bug from the opentelmetry-java-instrumentation
570- if (!foundException ) {
571- // TODO (srnagar): map OpenTelemetry exception to Application Insights exception better
572- String stacktrace = event .getAttributes ().get (SemanticAttributes .EXCEPTION_STACKTRACE );
573- if (stacktrace != null ) {
574- trackException (stacktrace , span , operationId , span .getSpanId (), samplingPercentage , telemetryItems );
575- }
561+ String stacktrace = event .getAttributes ().get (SemanticAttributes .EXCEPTION_STACKTRACE );
562+ if (stacktrace != null ) {
563+ trackException (stacktrace , span , operationId , span .getSpanId (), samplingPercentage , telemetryItems );
576564 }
577- foundException = true ;
578565 } else {
579566 telemetryItem .setSampleRate (samplingPercentage .floatValue ());
580567 telemetryItems .add (telemetryItem );
0 commit comments