Skip to content

Commit

Permalink
Don't capture exception records on dependencies (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Jun 1, 2022
1 parent 024e347 commit 993f6f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.azure.monitor.opentelemetry.exporter.implementation.builders.RemoteDependencyTelemetryBuilder;
import com.azure.monitor.opentelemetry.exporter.implementation.builders.RequestTelemetryBuilder;
import com.azure.monitor.opentelemetry.exporter.implementation.models.ContextTagKeys;
import com.azure.monitor.opentelemetry.exporter.implementation.models.RequestData;
import com.azure.monitor.opentelemetry.exporter.implementation.models.TelemetryItem;
import com.azure.monitor.opentelemetry.exporter.implementation.utils.FormattedDuration;
import com.azure.monitor.opentelemetry.exporter.implementation.utils.FormattedTime;
Expand Down Expand Up @@ -166,6 +167,7 @@ public void map(SpanData span, Consumer<TelemetryItem> consumer) {
consumer.accept(telemetryItem);
exportEvents(
span,
telemetryItem.getData().getBaseData() instanceof RequestData,
telemetryItem.getTags().get(ContextTagKeys.AI_OPERATION_NAME.toString()),
samplingPercentage,
consumer);
Expand Down Expand Up @@ -775,6 +777,7 @@ private static String nullAwareConcat(

private void exportEvents(
SpanData span,
boolean captureExceptionEvents,
@Nullable String operationName,
float samplingPercentage,
Consumer<TelemetryItem> consumer) {
Expand All @@ -786,11 +789,13 @@ private void exportEvents(

if (event.getAttributes().get(SemanticAttributes.EXCEPTION_TYPE) != null
|| event.getAttributes().get(SemanticAttributes.EXCEPTION_MESSAGE) != null) {
// TODO (trask) map OpenTelemetry exception to Application Insights exception better
String stacktrace = event.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);
if (stacktrace != null) {
consumer.accept(
createExceptionTelemetryItem(stacktrace, span, operationName, samplingPercentage));
if (captureExceptionEvents) {
// TODO (trask) map OpenTelemetry exception to Application Insights exception better
String stacktrace = event.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);
if (stacktrace != null) {
consumer.accept(
createExceptionTelemetryItem(stacktrace, span, operationName, samplingPercentage));
}
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public boolean test(Envelope input) {
return !data.getProperties().containsKey("LoggerName");
}
},
2,
1,
10,
TimeUnit.SECONDS);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Expand All @@ -155,8 +155,8 @@ public boolean test(Envelope input) {
assertTrue(rdd1.getProperties().isEmpty());
assertFalse(rdd1.getSuccess());

assertParentChild(rd, rdEnvelope, edEnvelope1, "GET /SpringBootTest/throwsException");
assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /SpringBootTest/throwsException");
assertParentChild(rdd1, rddEnvelope1, edEnvelope1, "GET /SpringBootTest/throwsException");
}

@Test
Expand Down

0 comments on commit 993f6f5

Please sign in to comment.