Skip to content

fix(ddtrace/opentelemetry): do not override otel custom errors#4572

Draft
rarguelloF wants to merge 1 commit intomainfrom
rarguelloF/fix-otel-override-custom-errors
Draft

fix(ddtrace/opentelemetry): do not override otel custom errors#4572
rarguelloF wants to merge 1 commit intomainfrom
rarguelloF/fix-otel-override-custom-errors

Conversation

@rarguelloF
Copy link
Copy Markdown
Contributor

@rarguelloF rarguelloF commented Mar 20, 2026

What does this PR do?

#3708

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official bot commented Mar 20, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 4 Tests failed

TestSetStatusShouldNotOverwriteUserDefinedErrorFields from github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry (Datadog) (Fix with Cursor)
Failed

=== RUN   TestSetStatusShouldNotOverwriteUserDefinedErrorFields
--- FAIL: TestSetStatusShouldNotOverwriteUserDefinedErrorFields (0.01s)
TestSetStatusShouldNotOverwriteUserDefinedErrorFields/all_error_fields_are_overwritten_when_SetStatus_is_called from github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry (Datadog) (Fix with Cursor)
Failed

=== RUN   TestSetStatusShouldNotOverwriteUserDefinedErrorFields/all_error_fields_are_overwritten_when_SetStatus_is_called
    span_test.go:475: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:475
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.stack:custom stack trace error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" does not contain "custom error message"
        	Test:       	TestSetStatusShouldNotOverwriteUserDefinedErrorFields/all_error_fields_are_overwritten_when_SetStatus_is_called
    span_test.go:475: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:475
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.stack:custom stack trace error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" does not contain "custom.ErrorType"
...
TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.message_is_overwritten_by_SetStatus_description from github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry (Datadog) (Fix with Cursor)
Failed

=== RUN   TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.message_is_overwritten_by_SetStatus_description
    span_test.go:475: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:475
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" does not contain "custom error message"
        	Test:       	TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.message_is_overwritten_by_SetStatus_description
    span_test.go:478: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:478
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" should not contain "status description from SetStatus"
...
TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.type_is_overwritten_by_SetStatus_description from github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry (Datadog) (Fix with Cursor)
Failed

=== RUN   TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.type_is_overwritten_by_SetStatus_description
    span_test.go:475: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:475
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" does not contain "custom.ErrorType"
        	Test:       	TestSetStatusShouldNotOverwriteUserDefinedErrorFields/error.type_is_overwritten_by_SetStatus_description
    span_test.go:478: 
        	Error Trace:	D:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:478
        	Error:      	"map[_dd.p.dm:-1 _dd.p.tid:69bd499f00000000 _dd.tags.process:entrypoint.basedir:b539,entrypoint.name:opentelemetry.test.exe,entrypoint.type:executable,entrypoint.workdir:opentelemetry error.handling_stack:github.com/DataDog/dd-trace-go/v2/internal/stacktrace.SkipAndCaptureWithInternalFrames\n\tD:/a/dd-trace-go/dd-trace-go/internal/stacktrace/stacktrace.go:274\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.takeStacktrace\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:719\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).setTagErrorLocked\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:692\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer.(*Span).Finish\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/tracer/span.go:921\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.(*span).End\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span.go:98\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry.TestSetStatusShouldNotOverwriteUserDefinedErrorFields.func1\n\tD:/a/dd-trace-go/dd-trace-go/ddtrace/opentelemetry/span_test.go:464\ntesting.tRunner\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/testing/testing.go:2036\nruntime.goexit\n\tC:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/asm_amd64.s:1771 error.message:status description from SetStatus error.type:*errors.errorString language:go runtime-id:23fdd18c-07d0-4230-97fc-5b7a22f08a1f span.kind:internal]" should not contain "*errors.errorString"
...
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 59.46% (+3.60%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 818bf59 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 20, 2026

Benchmarks

Benchmark execution time: 2026-03-20 13:41:56

Comparing candidate commit 818bf59 in PR branch rarguelloF/fix-otel-override-custom-errors with baseline commit 5160dbf in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 156 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@rarguelloF rarguelloF changed the title fix: do not override otel custom errors fix(ddtrace/opentelemetry): do not override otel custom errors Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant