Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't capture exception records on dependencies #2307

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about !(telemetryItem.getData().getBaseData() instanceof RemoteDependencyData)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the same, since we map spans to either requests or dependencies, I think I like instance of RequestData because this is how I am thinking about it after the discussion with Osvaldo:

Application Insights "exceptions" are meant for top-level exceptions (exceptions on request telemetry or logged exceptions)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it imply that it can be MessageData too?

// (exceptions on request telemetry or logged exceptions)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is in LogDataMapper:

String stack = log.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);
if (stack == null) {
consumer.accept(createMessageTelemetryItem(log));
} else {
consumer.accept(createExceptionTelemetryItem(log, stack));
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(where we create either message or exception record, but not both)

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