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

feature(tracing): add support for inferred proxy spans to support AWS API Gateway tracing #12053

Draft
wants to merge 30 commits into
base: conti/standardize-web-frameworks-to-use-core
Choose a base branch
from

Conversation

wconti27
Copy link
Contributor

Motivation

Adds support for inferred proxy spans created from distributed headers for web server integrations.

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

@wconti27 wconti27 changed the base branch from main to conti/standardize-web-frameworks-to-use-core January 23, 2025 19:16
Copy link
Contributor

github-actions bot commented Jan 23, 2025

CODEOWNERS have been resolved as:

ddtrace/_trace/_inferred_proxy.py                                       @DataDog/apm-sdk-api-python
tests/tracer/utils_inferred_spans/__init__.py                           @DataDog/apm-sdk-api-python
tests/tracer/utils_inferred_spans/test_helpers.py                       @DataDog/apm-sdk-api-python
ddtrace/_trace/trace_handlers.py                                        @DataDog/apm-sdk-api-python
ddtrace/ext/__init__.py                                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/settings/config.py                                              @DataDog/python-guild @DataDog/apm-sdk-api-python
tests/contrib/aiohttp/test_middleware.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/django/test_django.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/flask/test_request.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/utils.py                                                          @DataDog/python-guild

ddtrace/_trace/_inferred_proxy.py Outdated Show resolved Hide resolved
ddtrace/_trace/_inferred_proxy.py Outdated Show resolved Hide resolved
ddtrace/_trace/_inferred_proxy.py Outdated Show resolved Hide resolved
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jan 23, 2025

Datadog Report

Branch report: conti/support-aws-api-gateway
Commit report: d3eea29
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1468 Skipped, 4m 34.05s Total duration (36m 10.42s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jan 23, 2025

Benchmarks

Benchmark execution time: 2025-01-25 00:35:26

Comparing candidate commit 85bcab2 in PR branch conti/support-aws-api-gateway with baseline commit ee226aa in branch conti/standardize-web-frameworks-to-use-core.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

core.dispatch("inferred_proxy.start", (ctx, tracer, span_kwargs, call_trace, distributed_headers_config))
# re-get span_kwargs in case an inferred span was created and we have a new span_kwargs.child_of field
span_kwargs = ctx.get_item("span_kwargs")

span_kwargs.update(kwargs)
span = (tracer.trace if call_trace else tracer.start_span)(ctx["span_name"], **span_kwargs)
Copy link
Collaborator

@wantsui wantsui Jan 24, 2025

Choose a reason for hiding this comment

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

Just adding a note to fix/investigate this: Even if the above line was fixed: span_kwargs = ctx.get_item("span_kwargs"), when it hits this line, it throws an error about tracer.trace not accepting a child of argument:

TypeError: Tracer.trace() got an unexpected keyword argument 'child_of'

In https://github.com/DataDog/dd-trace-py/pull/11938/files, it used start_span which supports it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be fixed, there has to be a check to ensure trace() is not being called since it auto-handles context.

wantsui and others added 6 commits January 24, 2025 11:30
…des, adjust span creation, and fix time conversion from ms to ns for the inferred span
…creating multiple aws apigateway spans for one request and adjust the test.
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