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-3853 feat(otel-tracer): add test cases for setting active span #1764

Merged

Conversation

ganeshnj
Copy link
Contributor

@ganeshnj ganeshnj commented Apr 5, 2024

What and why?

Some tests to cover active span cases.

How?

There are various a parent can be set

  1. Explicit parent
        let span = tracer.spanBuilder(spanName: "parentSpan").setSpanKind(spanKind: .client).startSpan()
        span.setAttribute(key: sampleKey, value: sampleValue)
        let childSpan = tracer.spanBuilder(spanName: "childSpan").setSpanKind(spanKind: .client).setParent(span).startSpan()
        childSpan.setAttribute(key: sampleKey, value: sampleValue)
        childSpan.end()
        span.end()
  1. On the context provider
        let span = tracer.spanBuilder(spanName: "parentSpan").setSpanKind(spanKind: .client).startSpan()
        span.setAttribute(key: sampleKey, value: sampleValue)
        OpenTelemetry.instance.contextProvider.setActiveSpan(span)
        let childSpan = tracer.spanBuilder(spanName: "childSpan").setSpanKind(spanKind: .client).startSpan()
        childSpan.setAttribute(key: sampleKey, value: sampleValue)
        childSpan.end()
        span.end()
  1. On span builder
        let span = tracer.spanBuilder(spanName: "parentSpan").setSpanKind(spanKind: .client).setActive(true).startSpan()
        span.setAttribute(key: sampleKey, value: sampleValue)
        let childSpan = tracer.spanBuilder(spanName: "childSpan").setSpanKind(spanKind: .client).startSpan()
        childSpan.setAttribute(key: sampleKey, value: sampleValue)
        childSpan.end()
        span.end()

These all have the same impact in the end.

We have all the cases covered and this PR only adds test coverage for them.

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 requested review from a team as code owners April 5, 2024 14:07
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Looks good 👍, I like how nice the integration test reads 👌

@ganeshnj ganeshnj merged commit 35ca3bd into ganeshnj/feat/otel-tracer Apr 8, 2024
8 checks passed
@ganeshnj ganeshnj deleted the ganeshnj/feat/otel-tracer-active-tests branch April 8, 2024 14:03
@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