Skip to content

OpenTelemetry - fix Span.kind property to return SpanKind instead of str #13159

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

przlada
Copy link

@przlada przlada commented Apr 10, 2025

I found that the Span.kind property from the OpenTelemetry integration is returning a string value instead of a SpanKind enum. Because of this, the logic for setting the operation name cannot work properly

I propose to merge these changes as they:

  • Fix the Span.kind property to return the SpanKind enum as it should, instead of a string value
  • Thanks to this fix, the Span._datadog_operation_name property will start to work properly (as it is comparing to SpanKind enum values). I also fixed the logic for when the network.protocol.name attribute is set
  • I added tests to validate that span names are properly set now, and updated some snapshot files

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@przlada przlada marked this pull request as ready for review April 10, 2025 20:37
@przlada przlada requested review from a team as code owners April 10, 2025 20:37
@rachelyangdog rachelyangdog requested a review from mabdinur April 14, 2025 13:30
@@ -95,6 +95,66 @@ def test_otel_span_kind(oteltracer):
pass


@pytest.mark.snapshot(wait_for_num_traces=1)
@pytest.mark.parametrize("span_kind", [OtelSpanKind.CLIENT, OtelSpanKind.SERVER])
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix!

Can you add a fix release note as well.

Here's the docs on how to generate and write a release note: https://github.com/DataDog/dd-trace-py/blob/main/docs/releasenotes.rst#generating-a-release-note.

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.

3 participants