Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUM-1836 feat(otel-tracer): add support for span links #1630

Merged

Conversation

ganeshnj
Copy link
Contributor

@ganeshnj ganeshnj commented Jan 15, 2024

What and why?

Span link is an otel concept which allows casual relationship among spans. This is similar to parent but it can be many-many.

How?

In datadog, span links are supported via _dd.span_links tag which takes a list of links.

A link is represented with

 {
     "trace_id": "<exactly 32 character, zero-padded lower-case hexadecimal encoded trace id>",
     "span_id": "<exactly 16 character, zero-padded lower-case hexadecimal encoded span id>",
     "attributes": {"key":"value", "pairs":"of", "arbitrary":"values"},
     "dropped_attributes_count": <decimal 64 bit integer>,
     "tracestate": "a tracestate as defined in the W3C standard",
     "flags": <an integer representing the flags as defined in the W3C standard>
 }

Because RUM backend only supports [String: String] tags, this implementation escapes the span links JSON to make it a string value.

This

let tracer = Tracer.shared()
let span1 = tracer.spanBuilder(spanName: "span1").setSpanKind(spanKind: .client).startSpan()
span1.end()

let span2 = tracer.spanBuilder(spanName: "span2").setSpanKind(spanKind: .client).startSpan()
span2.end()

let spanBuilder = tracer.spanBuilder(spanName: "span3").setSpanKind(spanKind: .client)
spanBuilder.addLink(spanContext: span1.context)
spanBuilder.addLink(spanContext: span2.context)
let span3 = spanBuilder.startSpan()
span3.end()

results in
image

We are also using lower 64 bits for trace id as the SDK doesn't support 128 bit ids yet.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests for Core, RUM, Trace, Logs, CR and WVT
  • Run unit tests for Session Replay
  • Run integration tests
  • Run smoke tests
  • Run tests for tools/

@ganeshnj ganeshnj marked this pull request as ready for review January 15, 2024 11:51
@ganeshnj ganeshnj requested review from a team as code owners January 15, 2024 11:51
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jan 15, 2024

Datadog Report

Branch report: ganeshnj/feat/otel-tracer-span-links
Commit report: 8ce2edf
Test service: dd-sdk-ios

✅ 0 Failed, 2753 Passed, 0 Skipped, 11m 36.73s Wall Time
❄️ 2 New Flaky
🔻 Test Sessions change in coverage: 8 decreased, 6 increased

New Flaky Tests (2)

  • testIfIPv6AddressIsPrivate - KronosInternetAddressTests - Last Failure

    Expand for error
     Assertion Failure at KronosInternetAddressTests.swift:67: XCTAssertFalse failed - ff:b2f:bb94:fd44:4f9:75a6:4d80:1ae5 should not be private IP
    
  • testGivenDelegateSubclass_whenInterceptingRequests_itDetectFirstPartyHost - NetworkInstrumentationFeatureTests - Last Failure

    Expand for error
     Abort trap. Check error.crash_log for the full crash log.
    

🔻 Code Coverage Decreases vs Default Branch (8)

This report shows up to 5 code coverage decreases.

  • test DatadogCoreTests tvOS 75.28% (Δ-4.29%) - Details
  • test DatadogTraceTests iOS 45.57% (Δ-3.63%) - Details
  • test DatadogTraceTests tvOS 45.71% (Δ-3.59%) - Details
  • test DatadogCoreTests iOS 69.13% (Δ-3.32%) - Details
  • test DatadogInternalTests iOS 79.61% (Δ-1.61%) - Details

Copy link
Member

@maciejburda maciejburda left a comment

Choose a reason for hiding this comment

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

LGTM

@ganeshnj ganeshnj merged commit 6fd9e73 into ganeshnj/feat/otel-tracer Jan 17, 2024
8 checks passed
@ganeshnj ganeshnj deleted the ganeshnj/feat/otel-tracer-span-links branch January 17, 2024 16:42
@ncreated ncreated mentioned this pull request May 31, 2024
8 tasks
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.

2 participants