Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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 @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 suggestion: ‏For readability, I would recommend to use static imports 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use a static import for ErrorPriorities.MANUAL_INSTRUMENTATION but since we're also using ResourceNamePriorities.MANUAL_INSTRUMENTATION in the same file, I'm not sure it's the best. Happy to make the change for ErrorPriorities.MANUAL_INSTRUMENTATION if you think it's worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sure, nevermind, I missed it during the review 👌

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 @@ -457,6 +457,11 @@ class DDSpanTest extends DDCoreSpecification {
then:
!span.isError()

when:
span.setError(true, ErrorPriorities.MANUAL_INSTRUMENTATION)
then:
span.isError()

when:
span.setError(true, Byte.MAX_VALUE)
then:
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,5 @@ public class ErrorPriorities {
public static final byte HTTP_SERVER_DECORATOR = -1;

public static final byte DEFAULT = 0;
public static final byte MANUAL_INSTRUMENTATION = 1;
}