Skip to content

[receiver/datadog] Implement support for span links#37449

Merged
jpkrohling merged 19 commits into
open-telemetry:mainfrom
lopes-felipe:datadog-receiver/span-link2
Feb 11, 2025
Merged

[receiver/datadog] Implement support for span links#37449
jpkrohling merged 19 commits into
open-telemetry:mainfrom
lopes-felipe:datadog-receiver/span-link2

Conversation

@lopes-felipe

@lopes-felipe lopes-felipe commented Jan 23, 2025

Copy link
Copy Markdown
Member

Description

Currently, there is no way to create Span Links from Datadog spans through the Datadog receiver.

This implements support for Span Links via DD tracing library's own attribute (_dd.span_links).

The payload format is also the same adopted by the tracing library and the agent

Link to tracking issue

Fixes

Testing

Documentation

@MovieStoreGuy MovieStoreGuy self-requested a review February 3, 2025 22:48
@lopes-felipe

Copy link
Copy Markdown
Member Author

Any comments on this, @MovieStoreGuy? :)

// UnmarshalJSON inflates trace id from hex string, possibly enclosed in quotes.
// TODO: Find a way to avoid this duplicate code. Consider to expose this in pdata.
func unmarshalJSON(dst []byte, src []byte) error {
func UnmarshalJSON(dst []byte, src []byte) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As the TODO comment states, this code is duplicated from internal core pdata, see here https://github.com/open-telemetry/opentelemetry-collector/blob/v0.119.0/pdata/internal/data/bytesid.go. As such, I'm not sure it's a good idea to expose this function from this package (certainly not with this name, as it does not at all give a good idea of what's it's doing). I think that ideally this function would be exposed from pdata.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might not even need this after all, if you use the suggestion I made on the ddreceiver component itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That worked; thanks!

Comment thread receiver/datadogreceiver/internal/translator/traces_translator.go
Comment thread receiver/datadogreceiver/internal/translator/traces_translator.go Outdated
// UnmarshalJSON inflates trace id from hex string, possibly enclosed in quotes.
// TODO: Find a way to avoid this duplicate code. Consider to expose this in pdata.
func unmarshalJSON(dst []byte, src []byte) error {
func UnmarshalJSON(dst []byte, src []byte) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might not even need this after all, if you use the suggestion I made on the ddreceiver component itself.

@lopes-felipe

Copy link
Copy Markdown
Member Author

Thank you for the suggestion @jpkrohling; just implemented it, and it worked like a charm! Would you mind taking another look? Thanks! :)

@andrzej-stencel andrzej-stencel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, thanks Juraci and Felipe!

@jpkrohling

Copy link
Copy Markdown
Member

There's a merge conflict there, once that's sorted out, this is ready to be merged.

@lopes-felipe

lopes-felipe commented Feb 11, 2025

Copy link
Copy Markdown
Member Author

There's a merge conflict there, once that's sorted out, this is ready to be merged.

Fixed, @jpkrohling.

@jpkrohling jpkrohling merged commit 9bedf62 into open-telemetry:main Feb 11, 2025
@github-actions github-actions Bot added this to the next release milestone Feb 11, 2025
yiquanzhou added a commit to dash0hq/opentelemetry-collector-contrib that referenced this pull request Feb 11, 2025
* main: (76 commits)
  Update All OpenTelemetry Collector Contrib packages (open-telemetry#37839)
  [chore] fix codeowners allowlist (open-telemetry#37856)
  Update module github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp to v1.26.0 (open-telemetry#37841)
  Update module github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common to v1.0.1095 (open-telemetry#37825)
  Update module github.com/grpc-ecosystem/grpc-gateway/v2 to v2.26.1 (open-telemetry#37821)
  [chore][exporter/elasticsearch] Bump go-docappender to v2.5.0 (open-telemetry#37852)
  Update All github.com/aws packages (open-telemetry#37816)
  Update module google.golang.org/protobuf to v1.36.5 (open-telemetry#37827)
  Update module github.com/SAP/go-hdb to v1.12.12 (open-telemetry#37817)
  Update module github.com/huaweicloud/huaweicloud-sdk-go-v3 to v0.1.135 (open-telemetry#37822)
  Update module github.com/ClickHouse/clickhouse-go/v2 to v2.31.0 (open-telemetry#37835)
  [receiver/datadog] Implement support for span links (open-telemetry#37449)
  receiver/prometheusreceiver: allow cumulative resets when using the adjuster (open-telemetry#37718)
  Update README.md (open-telemetry#37826)
  [receiver/github] add workflow run event trace handling (open-telemetry#37578)
  Update All github.com/datadog packages to v0.62.2 (open-telemetry#37838)
  [chore] Update types used in extensiontest.NewNopSettingsWithType (open-telemetry#37844)
  [processor/redaction] introduce `allowed_values` parameter in processor config (open-telemetry#37638)
  [chore] Update otel version (open-telemetry#37808)
  [testbed] Include CPU and memory limits to benchmark results file (open-telemetry#36753)
  ...
khushijain21 pushed a commit to khushijain21/opentelemetry-collector-contrib that referenced this pull request Feb 14, 2025
…7449)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Currently, there is no way to create [Span
Links](https://opentelemetry.io/docs/concepts/signals/traces/#span-links)
from Datadog spans through the Datadog receiver.

This implements support for Span Links via DD tracing library's own
attribute
([_dd.span_links](https://github.com/DataDog/dd-trace-java/blob/78e523d5bb643d9fc3f3b02a00cbb4889befe454/dd-trace-api/src/main/java/datadog/trace/api/DDTags.java#L56)).

The [payload
format](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/37449/files#diff-776d8a37714f68338101d91e29a20c8244f19acba413426ad638ed111d8cf9b9R42)
is also the same adopted by the [tracing
library](https://github.com/DataDog/dd-trace-java/blob/96dcbbe6144ef50e7e3b13e838bcdc4f412b841b/dd-trace-core/src/main/java/datadog/trace/core/DDSpanLink.java#L62-L94)
and the
[agent](https://github.com/DataDog/datadog-agent/blob/57115d85853ba1e6007594ddfdf320bba7477e63/pkg/trace/api/otlp_test.go#L4057-L4158)

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants