Skip to content

Commit

Permalink
Add more IDs to log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer committed Dec 13, 2022
1 parent 49efc4c commit 183423a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,37 @@ public OpenTelemetryLinkErrorEventProcessor() {
.getLogger()
.log(
SentryLevel.DEBUG,
"Linking Sentry event to span %s created via OpenTelemetry.",
spanId);
"Linking Sentry event %s to span %s created via OpenTelemetry (trace %s).",
event.getEventId(),
spanId,
traceId);
} else {
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Not linking Sentry event to any transaction created via OpenTelemetry as none has been found.");
"Not linking Sentry event %s to any transaction created via OpenTelemetry as none has been found for span %s (trace %s).",
event.getEventId(),
spanId,
traceId);
}
} else {
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Not linking Sentry event to any transaction created via OpenTelemetry as traceId or spanId are invalid.");
"Not linking Sentry event %s to any transaction created via OpenTelemetry as traceId %s or spanId %s are invalid.",
event.getEventId(),
traceId,
spanId);
}
} else {
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Not linking Sentry event to any transaction created via OpenTelemetry as instrumenter is set to %s.",
"Not linking Sentry event %s to any transaction created via OpenTelemetry as instrumenter is set to %s.",
event.getEventId(),
instrumenter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public <C> void inject(final Context context, final C carrier, final TextMapSett
.getLogger()
.log(
SentryLevel.DEBUG,
"Not injecting Sentry tracing information as no Sentry span has been found or it is a NoOp.");
"Not injecting Sentry tracing information for span %s as no Sentry span has been found or it is a NoOp (trace %s). This might simply mean this is a request to Sentry.",
otelSpanContext.getSpanId(),
otelSpanContext.getTraceId());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ public void onStart(final @NotNull Context parentContext, final @NotNull ReadWri
return;
}

final @NotNull TraceData traceData = getTraceData(otelSpan, parentContext);

if (isSentryRequest(otelSpan)) {
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Not forwarding OpenTelemetry Span to Sentry as this looks like a span for a request to Sentry.");
"Not forwarding OpenTelemetry span %s to Sentry as this looks like a span for a request to Sentry (trace %s).",
traceData.getSpanId(),
traceData.getTraceId());
return;
}

final @NotNull TraceData traceData = getTraceData(otelSpan, parentContext);
final @Nullable ISpan sentryParentSpan =
traceData.getParentSpanId() == null ? null : spanStorage.get(traceData.getParentSpanId());

Expand All @@ -77,8 +79,9 @@ public void onStart(final @NotNull Context parentContext, final @NotNull ReadWri
.getLogger()
.log(
SentryLevel.DEBUG,
"Creating Sentry child span %s for OpenTelemetry span. Parent span is %s.",
"Creating Sentry child span for OpenTelemetry span %s (trace %s). Parent span is %s.",
traceData.getSpanId(),
traceData.getTraceId(),
traceData.getParentSpanId());
final @NotNull Date startDate =
DateUtils.nanosToDate(otelSpan.toSpanData().getStartEpochNanos());
Expand All @@ -91,8 +94,9 @@ public void onStart(final @NotNull Context parentContext, final @NotNull ReadWri
.getLogger()
.log(
SentryLevel.DEBUG,
"Creating Sentry transaction %s for OpenTelemetry span.",
traceData.getSpanId());
"Creating Sentry transaction for OpenTelemetry span %s (trace %s).",
traceData.getSpanId(),
traceData.getTraceId());
final @NotNull String transactionName = otelSpan.getName();
final @NotNull TransactionNameSource transactionNameSource = TransactionNameSource.CUSTOM;
final @Nullable String op = otelSpan.getName();
Expand Down Expand Up @@ -147,8 +151,9 @@ public void onEnd(final @NotNull ReadableSpan otelSpan) {
.getLogger()
.log(
SentryLevel.DEBUG,
"Unable to find Sentry span for OpenTelemetry span %s.",
traceData.getSpanId());
"Unable to find Sentry span for OpenTelemetry span %s (trace %s).",
traceData.getSpanId(),
traceData.getTraceId());
return;
}

Expand All @@ -157,27 +162,33 @@ public void onEnd(final @NotNull ReadableSpan otelSpan) {
.getLogger()
.log(
SentryLevel.DEBUG,
"Not forwarding OpenTelemetry Span to Sentry as this looks like a span for a request to Sentry.");
"Not forwarding OpenTelemetry span %s to Sentry as this looks like a span for a request to Sentry (trace %s).",
traceData.getSpanId(),
traceData.getTraceId());
return;
}

if (sentrySpan instanceof ITransaction) {
ITransaction sentryTransaction = (ITransaction) sentrySpan;
final @NotNull ITransaction sentryTransaction = (ITransaction) sentrySpan;
updateTransactionWithOtelData(sentryTransaction, otelSpan);
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Finishing Sentry transaction for OpenTelemetry span %s.",
traceData.getSpanId());
"Finishing Sentry transaction %s for OpenTelemetry span %s (trace %s).",
sentryTransaction.getEventId(),
traceData.getSpanId(),
traceData.getTraceId());
} else {
updateSpanWithOtelData(sentrySpan, otelSpan);
hub.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Finishing Sentry span for OpenTelemetry span %s.",
traceData.getSpanId());
"Finishing Sentry span for OpenTelemetry span %s (trace %s). Parent span is %s.",
traceData.getSpanId(),
traceData.getTraceId(),
traceData.getParentSpanId());
}

final @NotNull SpanStatus sentryStatus = mapOtelStatus(otelSpan);
Expand All @@ -197,7 +208,7 @@ private boolean ensurePrerequisites(final @NotNull ReadableSpan otelSpan) {
.getLogger()
.log(
SentryLevel.DEBUG,
"Not forwarding OpenTelemetry Span to Sentry as Sentry has not yet been initialized.");
"Not forwarding OpenTelemetry span to Sentry as Sentry has not yet been initialized.");
return false;
}

Expand All @@ -207,7 +218,7 @@ private boolean ensurePrerequisites(final @NotNull ReadableSpan otelSpan) {
.getLogger()
.log(
SentryLevel.DEBUG,
"Not forwarding OpenTelemetry Span to Sentry as instrumenter has been set to %s.",
"Not forwarding OpenTelemetry span to Sentry as instrumenter has been set to %s.",
instrumenter);
return false;
}
Expand All @@ -218,7 +229,7 @@ private boolean ensurePrerequisites(final @NotNull ReadableSpan otelSpan) {
.getLogger()
.log(
SentryLevel.DEBUG,
"Not forwarding OpenTelemetry Span to Sentry as the span is invalid.");
"Not forwarding OpenTelemetry span to Sentry as the span is invalid.");
return false;
}

Expand Down

0 comments on commit 183423a

Please sign in to comment.