Skip to content

Add error priorities for dynamic instrumentation and manual instrumentation #9098

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -15,6 +15,8 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext;
import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper;
import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities;
import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities;
import datadog.trace.bootstrap.instrumentation.api.WithAgentSpan;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
Expand Down Expand Up @@ -105,11 +107,11 @@ public Span setStatus(StatusCode statusCode, String description) {
if (this.recording) {
if (this.statusCode == UNSET) {
this.statusCode = statusCode;
this.delegate.setError(statusCode == ERROR);
this.delegate.setError(statusCode == ERROR, ErrorPriorities.MANUAL_INSTRUMENTATION);
this.delegate.setErrorMessage(statusCode == ERROR ? description : null);
} else if (this.statusCode == ERROR && statusCode == OK) {
this.statusCode = statusCode;
this.delegate.setError(false);
this.delegate.setError(false, ErrorPriorities.MANUAL_INSTRUMENTATION);
this.delegate.setErrorMessage(null);
}
}
Expand All @@ -132,7 +134,7 @@ public Span recordException(Throwable exception, Attributes additionalAttributes
@Override
public Span updateName(String name) {
if (this.recording) {
this.delegate.setResourceName(name);
this.delegate.setResourceName(name, ResourceNamePriorities.MANUAL_INSTRUMENTATION);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datadog.trace.api.interceptor.MutableSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities;
import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.api.WithAgentSpan;
Expand Down Expand Up @@ -73,7 +74,7 @@ public boolean isError() {

@Override
public OTSpan setError(final boolean value) {
delegate.setError(value);
delegate.setError(value, ErrorPriorities.MANUAL_INSTRUMENTATION);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datadog.trace.api.interceptor.MutableSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities;
import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.api.WithAgentSpan;
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean isError() {

@Override
public OTSpan setError(final boolean value) {
delegate.setError(value);
delegate.setError(value, ErrorPriorities.MANUAL_INSTRUMENTATION);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private boolean interceptDbStatement(DDSpanContext span, Object value) {
}

private boolean interceptError(DDSpanContext span, Object value) {
span.setErrorFlag(asBoolean(value), ErrorPriorities.DEFAULT);
span.setErrorFlag(asBoolean(value), ErrorPriorities.TAG_INTERCEPTOR);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would still use the default here. The ones using the interceptor, are setting a tag to infer the error flag.Both are falling hence into the manual instrumentation use case

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion dd-trace-ot/src/main/java/datadog/opentracing/OTSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datadog.trace.api.interceptor.MutableSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities;
import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.api.WithAgentSpan;
Expand Down Expand Up @@ -73,7 +74,7 @@ public boolean isError() {

@Override
public OTSpan setError(final boolean value) {
delegate.setError(value);
delegate.setError(value, ErrorPriorities.MANUAL_INSTRUMENTATION);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public class ErrorPriorities {
public static final byte HTTP_SERVER_DECORATOR = -1;

public static final byte DEFAULT = 0;
public static final byte TAG_INTERCEPTOR = 1;
public static final byte MANUAL_INSTRUMENTATION = 2;
}
Loading