Skip to content

Comments

feat(ddtrace/opentelemetry): add AddLink & RecordError#4462

Open
ablaine wants to merge 2 commits intoDataDog:mainfrom
ablaine:otelAddLink
Open

feat(ddtrace/opentelemetry): add AddLink & RecordError#4462
ablaine wants to merge 2 commits intoDataDog:mainfrom
ablaine:otelAddLink

Conversation

@ablaine
Copy link

@ablaine ablaine commented Feb 21, 2026

What does this PR do?

This implements AddLink and RecordError in the opentelemetry to DD adaptor span.

Motivation

I am trying to use OTel's AddLink and discovered that it currently delegates to the noop.Span handler. I temporarily swapped noop.Span with embedded.Span to also discover RecordError was missing.

I looked at OpenTelemetry's RecordError implementation's for the appropriate attributes (exception.type, exception.message and exception.stacktrace), for example: sdk/trace/span.go

For AddLink, I re-used the basic logic from ddtrace/opentelemetry/tracer.go.

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!

@ablaine ablaine requested a review from a team as a code owner February 21, 2026 17:30
@@ -206,6 +210,62 @@ func (s *span) AddEvent(name string, opts ...oteltrace.EventOption) {
s.events = append(s.events, e)
Copy link
Author

Choose a reason for hiding this comment

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

side note, it looks as if s.events is missing mutex protection when being written on this line. Let me know and I am happy to add lock/unlock to the AddEvent method.

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