Skip to content

RUM-15422: Support addEvent for OTel spans (logging events)#3377

Merged
satween merged 5 commits into
developfrom
tvaleev/feature/RUM-15422
May 15, 2026
Merged

RUM-15422: Support addEvent for OTel spans (logging events)#3377
satween merged 5 commits into
developfrom
tvaleev/feature/RUM-15422

Conversation

@satween

@satween satween commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements addEvent support for OtelSpan, routing OpenTelemetry span events to Datadog's logging infrastructure.

  • Added logAttributes(attributes: Map<String, Any>) and logAttributes(attributes: Map<String, Any>, timestampMs: Long) to DatadogSpan interface
  • Implemented addEvent(String, Attributes) and addEvent(String, Attributes, long, TimeUnit) in OtelSpan.java — converts OTel Attributes to a map and delegates to DatadogSpan.logAttributes()
  • Implemented logAttributes in DatadogSpanAdapter, routing to DatadogSpanLogger
  • Extended DatadogSpanLogger to support optional custom timestampMs

Motivation

OTel API requires Span.addEvent() to forward span events as logs. Without this, events added via the OTel API were silently dropped.

Additional Notes

  • The detekt --custom-rules step reports 210 pre-existing weighted issues (in cronet, ApmNetworkInstrumentation, etc.) unrelated to this PR
  • dd-sdk-android-sqldelight.api updated to reflect the new default logAttributes impl in the DatadogSpan interface

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@satween
satween requested review from a team as code owners April 16, 2026 17:00
@codecov-commenter

codecov-commenter commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.89%. Comparing base (e71690e) to head (aafc48f).
⚠️ Report is 67 commits behind head on develop.

Files with missing lines Patch % Lines
...java/com/datadog/opentelemetry/trace/OtelSpan.java 91.67% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3377      +/-   ##
===========================================
+ Coverage    71.49%   71.89%   +0.40%     
===========================================
  Files          947      947              
  Lines        34919    34930      +11     
  Branches      5921     5806     -115     
===========================================
+ Hits         24965    25111     +146     
+ Misses        8290     8228      -62     
+ Partials      1664     1591      -73     
Files with missing lines Coverage Δ
...tadog/android/trace/api/DatadogTracingConstants.kt 0.00% <ø> (ø)
...atadog/android/trace/internal/DatadogSpanLogger.kt 80.39% <100.00%> (+0.80%) ⬆️
...java/com/datadog/opentelemetry/trace/OtelSpan.java 65.79% <91.67%> (+7.98%) ⬆️

... and 110 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@satween
satween marked this pull request as draft April 17, 2026 08:46
satween added 2 commits April 27, 2026 14:57
The `forge` parameter on the `fall back to timeProvider` test case
was never referenced; kotlinc with -Werror failed the build because
of the unused-parameter warning. Removing it lets the trace module's
unit tests compile cleanly.
@satween
satween marked this pull request as ready for review April 28, 2026 08:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aafc48f4af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +108 to +110
if (value != null) fields.put(item.getKey().getKey(), value);
}
fields.put(DatadogTracingConstants.LogAttributes.MESSAGE, name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve attributes that use reserved log keys

When an OTel event includes an attribute whose key matches a span-log control key, this map stores it in the same namespace used by DatadogSpanLogger. In particular Attributes.of(stringKey("message"), value) is overwritten here by the event name, and keys such as status or _dd.timestamp_ms are later removed/interpreted as logger controls instead of being emitted as event attributes. Since OTel event attributes are arbitrary user data, route the event name/timestamp separately or escape these reserved keys before delegating so those attributes are not silently lost or repurposed.

Useful? React with 👍 / 👎.

@satween
satween requested a review from 0xnm April 28, 2026 12:11
@satween
satween merged commit f8d9df5 into develop May 15, 2026
26 checks passed
@satween
satween deleted the tvaleev/feature/RUM-15422 branch May 15, 2026 16:48
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.

4 participants