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

WIP: otel baggage support initial PR #10389

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft

Conversation

rachelyangdog
Copy link
Contributor

@rachelyangdog rachelyangdog commented Aug 26, 2024

First PR introducing baggage support

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

Copy link
Contributor

github-actions bot commented Aug 26, 2024

CODEOWNERS have been resolved as:

releasenotes/notes/baggage-support-be7eed26293f1216.yaml                @DataDog/apm-python
ddtrace/_trace/context.py                                               @DataDog/apm-sdk-api-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/internal/constants.py                                           @DataDog/apm-core-python
ddtrace/internal/opentelemetry/context.py                               @DataDog/apm-sdk-api-python
ddtrace/propagation/http.py                                             @DataDog/apm-sdk-api-python
ddtrace/settings/config.py                                              @DataDog/python-guild @DataDog/apm-sdk-api-python
riotfile.py                                                             @DataDog/apm-python
tests/opentelemetry/test_context.py                                     @DataDog/apm-sdk-api-python
tests/tracer/test_propagation.py                                        @DataDog/apm-sdk-api-python
tests/tracer/test_span.py                                               @DataDog/apm-sdk-api-python

@pr-commenter
Copy link

pr-commenter bot commented Aug 26, 2024

Benchmarks

Benchmark execution time: 2024-10-07 20:17:20

Comparing candidate commit 6dc990a in PR branch rachel.yang/baggage with baseline commit 0bf1fe9 in branch main.

Found 0 performance improvements and 20 performance regressions! Performance is the same for 354 metrics, 52 unstable metrics.

scenario:httppropagationextract-b3_headers

  • 🟥 execution_time [+5.648µs; +5.772µs] or [+21.743%; +22.218%]

scenario:httppropagationextract-b3_single_headers

  • 🟥 execution_time [+5.511µs; +5.593µs] or [+24.096%; +24.452%]

scenario:httppropagationextract-full_t_id_datadog_headers

  • 🟥 execution_time [+5.726µs; +5.873µs] or [+12.093%; +12.403%]

scenario:httppropagationextract-invalid_priority_header

  • 🟥 execution_time [+4.795µs; +4.855µs] or [+27.945%; +28.293%]

scenario:httppropagationextract-invalid_span_id_header

  • 🟥 execution_time [+4.921µs; +4.997µs] or [+28.696%; +29.141%]

scenario:httppropagationextract-invalid_tags_header

  • 🟥 execution_time [+4.953µs; +5.000µs] or [+28.915%; +29.194%]

scenario:httppropagationextract-invalid_trace_id_header

  • 🟥 execution_time [+4.863µs; +4.920µs] or [+28.366%; +28.701%]

scenario:httppropagationextract-medium_header_no_matches

  • 🟥 execution_time [+4.780µs; +4.859µs] or [+17.159%; +17.443%]

scenario:httppropagationextract-medium_valid_headers_all

  • 🟥 execution_time [+4.813µs; +4.904µs] or [+15.150%; +15.437%]

scenario:httppropagationextract-tracecontext_headers

  • 🟥 execution_time [+5.640µs; +5.807µs] or [+8.148%; +8.388%]

scenario:httppropagationextract-valid_headers_all

  • 🟥 execution_time [+4.891µs; +4.985µs] or [+28.470%; +29.018%]

scenario:httppropagationextract-valid_headers_basic

  • 🟥 execution_time [+4.960µs; +5.015µs] or [+31.584%; +31.930%]

scenario:httppropagationextract-wsgi_invalid_priority_header

  • 🟥 execution_time [+4.911µs; +4.965µs] or [+28.637%; +28.955%]

scenario:httppropagationextract-wsgi_invalid_tags_header

  • 🟥 execution_time [+4.832µs; +4.938µs] or [+28.053%; +28.665%]

scenario:httppropagationextract-wsgi_invalid_trace_id_header

  • 🟥 execution_time [+4.864µs; +4.931µs] or [+28.384%; +28.773%]

scenario:httppropagationextract-wsgi_medium_header_no_matches

  • 🟥 execution_time [+4.855µs; +4.959µs] or [+17.340%; +17.711%]

scenario:httppropagationextract-wsgi_medium_valid_headers_all

  • 🟥 execution_time [+4.823µs; +4.927µs] or [+15.118%; +15.445%]

scenario:httppropagationextract-wsgi_valid_headers_all

  • 🟥 execution_time [+4.879µs; +4.965µs] or [+28.407%; +28.907%]

scenario:httppropagationextract-wsgi_valid_headers_basic

  • 🟥 execution_time [+4.892µs; +4.949µs] or [+31.056%; +31.418%]

scenario:span-start

  • 🟥 max_rss_usage [+3.968MB; +4.090MB] or [+10.978%; +11.316%]

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Aug 27, 2024

Datadog Report

Branch report: rachel.yang/baggage
Commit report: cfec962
Test service: dd-trace-py

❌ 426 Failed (0 Known Flaky), 163772 Passed, 10479 Skipped, 8h 40m 55.13s Total duration (7h 4m 44.34s time saved)
❄️ 47 New Flaky
⌛ 3 Performance Regressions

❌ Failed Tests (426)

This report shows up to 5 failed tests.

  • test_distributed_tracing[scope0] - test_asgi.py - Details

    Expand for error
     assert None == 1234
      +  where None = <Span(id=17947516139693682439,trace_id=136898361102384514869965136187096557328,parent_id=None,name=asgi.request)>.parent_id
    
  • test_distributed_tracing[scope0] - test_asgi.py - Details

    Expand for error
     assert None == 1234
      +  where None = <Span(id=7169614202445284496,trace_id=136898361736209814984239894516612396808,parent_id=None,name=asgi.request)>.parent_id
    
  • test_distributed_tracing[scope1] - test_asgi.py - Details

    Expand for error
     assert None == 1234
      +  where None = <Span(id=8388542101613764570,trace_id=136898361656981652483199378188304412895,parent_id=None,name=asgi.request)>.parent_id
    
  • test_distributed_tracing[scope1] - test_asgi.py - Details

    Expand for error
     assert None == 1234
      +  where None = <Span(id=214240755496349370,trace_id=136898361023156352351399415865192883834,parent_id=None,name=asgi.request)>.parent_id
    
  • test_distributed_tracing[scope2] - test_asgi.py - Details

    Expand for error
     assert None == 1234
      +  where None = <Span(id=920059719593173542,trace_id=136898361023156352364666405393914162644,parent_id=None,name=asgi.request)>.parent_id
    

New Flaky Tests (47)

  • test_django_login_events_disabled_explicitly - test_django_appsec.py - Last Failure

    Expand for error
     connection failed: could not connect to server: Connection refused
     	Is the server running on host "127.0.0.1" and accepting
     	TCP/IP connections on port 5432?
    
  • test_django_login_events_disabled_noappsec - test_django_appsec.py - Last Failure

    Expand for error
     connection failed: could not connect to server: Connection refused
     	Is the server running on host "127.0.0.1" and accepting
     	TCP/IP connections on port 5432?
    
  • test_django_login_failure_anonymization_but_user_set_login - test_django_appsec.py - Last Failure

    Expand for error
     connection failed: could not connect to server: Connection refused
     	Is the server running on host "127.0.0.1" and accepting
     	TCP/IP connections on port 5432?
    
  • test_django_login_failure_anonymization_user_does_exist - test_django_appsec.py - Last Failure

    Expand for error
     connection failed: could not connect to server: Connection refused
     	Is the server running on host "127.0.0.1" and accepting
     	TCP/IP connections on port 5432?
    
  • test_django_login_failure_identification_user_does_exist - test_django_appsec.py - Last Failure

    Expand for error
     connection failed: could not connect to server: Connection refused
     	Is the server running on host "127.0.0.1" and accepting
     	TCP/IP connections on port 5432?
    

⌛ Performance Regressions vs Default Branch (3)

  • test_distributed_trace_with_flask_app[with_ddtrace_run] - test_trace.py 10.52s (+9.39s, +830%) - Details
  • test_distributed_trace_with_flask_app[with_ddtrace_run] - test_trace.py 10.52s (+9.51s, +945%) - Details
  • test_distributed_trace_with_flask_app[with_ddtrace_run] - test_trace.py 10.33s (+9.29s, +892%) - Details

return

header_value = ",".join(
f"{_BaggageHeader._encode_key(str(key).strip())}={_BaggageHeader._encode_value(str(value).strip())}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we raise an unhandled exception if value can not be converted to a string? How should we handle dicts,arrays,booleans,etc. The format needs to be consistent across languages (ex: encoding True vs true)

Copy link
Contributor Author

@rachelyangdog rachelyangdog Aug 27, 2024

Choose a reason for hiding this comment

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

When "extracting baggage from propagation headers, they may encounter malformed header contents." When this occurs, we "should ignore the entire header." (RFC) So instead of an error, we could potentially just ignore it? As of now, I think it would just do something like a type error

Copy link
Member

@lucaspimentel lucaspimentel Sep 11, 2024

Choose a reason for hiding this comment

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

Should we raise an unhandled exception if value can not be converted to a string?

I don't know who errors are handles in Python, but an invalid header should not break the service we are instrumenting. We could definitely log a warning or whatever you usually do in cases like this.

"should ignore the entire header." (RFC)

The main point here was that we should not try to extract individual values while ignore that bad ones. If something is wrong, don't try to extract anything. I clear this up in the RFC, thanks.

ddtrace/_trace/span.py Outdated Show resolved Hide resolved
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