Skip to content

feat(apm): add referrer hostname as span tag #12778

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

Merged
merged 12 commits into from
Apr 2, 2025
Merged

Conversation

cgcote
Copy link
Contributor

@cgcote cgcote commented Mar 18, 2025

Parses referrer hostname from http header when presents and adds it to span tags as http.referrer_hostname. This will be used to identify frontend clients without leaking the PII which can be contained in the entire referrer.

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 Mar 18, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/referrer-hostname-8aa6dc6edb9d53b1.yaml              @DataDog/apm-python
ddtrace/contrib/internal/trace_utils.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/ext/http.py                                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/tracer/test_trace_utils.py                                        @DataDog/apm-sdk-api-python

Copy link
Contributor

github-actions bot commented Mar 18, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 232 ± 4 ms.

The average import time from base is: 233 ± 4 ms.

The import time difference between this PR and base is: -0.5 ± 0.2 ms.

Import time breakdown

The following import paths have grown:

ddtrace.auto 1.186 ms (0.51%)
ddtrace.bootstrap.sitecustomize 1.098 ms (0.47%)
ddtrace.bootstrap.preload 1.098 ms (0.47%)
ddtrace.internal.products 1.098 ms (0.47%)
importlib.metadata 0.936 ms (0.40%)
importlib.abc 0.752 ms (0.32%)
importlib.resources 0.752 ms (0.32%)
importlib.resources._legacy 0.752 ms (0.32%)
csv 0.114 ms (0.05%)
importlib.metadata._itertools 0.069 ms (0.03%)
ddtrace.internal.remoteconfig._connectors 0.085 ms (0.04%)
ctypes 0.085 ms (0.04%)
_ctypes 0.085 ms (0.04%)
ddtrace.debugging._config 0.077 ms (0.03%)
ddtrace.settings.exception_replay 0.077 ms (0.03%)
ddtrace 0.088 ms (0.04%)
ddtrace.trace 0.088 ms (0.04%)
ddtrace._trace.tracer 0.088 ms (0.04%)
ddtrace.internal.processor.endpoint_call_counter 0.088 ms (0.04%)

The following import paths have shrunk:

ddtrace.auto 2.897 ms (1.25%)
ddtrace.bootstrap.sitecustomize 2.214 ms (0.95%)
ddtrace.bootstrap.preload 2.214 ms (0.95%)
ddtrace.internal.products 2.214 ms (0.95%)
importlib.metadata 0.896 ms (0.39%)
importlib.abc 0.785 ms (0.34%)
importlib.resources 0.063 ms (0.03%)
csv 0.110 ms (0.05%)
_csv 0.110 ms (0.05%)
ddtrace.internal.remoteconfig.client 0.616 ms (0.27%)
ddtrace.internal.remoteconfig._connectors 0.065 ms (0.03%)
ctypes 0.065 ms (0.03%)
ddtrace 0.683 ms (0.29%)
ddtrace.trace 0.080 ms (0.03%)
ddtrace._trace.tracer 0.080 ms (0.03%)
ddtrace.internal.schema.processor 0.080 ms (0.03%)

@cgcote cgcote force-pushed the charles.cote/referrer_host branch from 6c5ff75 to e5468e5 Compare March 18, 2025 13:24
@pr-commenter
Copy link

pr-commenter bot commented Mar 18, 2025

Benchmarks

Benchmark execution time: 2025-04-02 09:34:48

Comparing candidate commit 8ab9a24 in PR branch charles.cote/referrer_host with baseline commit 961a8dc in branch main.

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

@cgcote cgcote force-pushed the charles.cote/referrer_host branch 2 times, most recently from feb42a7 to 503a329 Compare March 19, 2025 14:58
@cgcote cgcote changed the title Add http.referrer_host tag feat(rum) Add http.referrer_host tag Mar 21, 2025
@cgcote cgcote changed the title feat(rum) Add http.referrer_host tag feat(rum): Add http.referrer_host tag Mar 21, 2025
@cgcote cgcote changed the title feat(rum): Add http.referrer_host tag feat(rum): add http.referrer_host tag Mar 21, 2025
@cgcote cgcote changed the title feat(rum): add http.referrer_host tag feat(apm): add http.referrer_host tag Mar 21, 2025
@cgcote cgcote force-pushed the charles.cote/referrer_host branch from 503a329 to e80421e Compare March 21, 2025 10:41
@cgcote cgcote marked this pull request as ready for review March 21, 2025 16:54
@cgcote cgcote requested review from a team as code owners March 21, 2025 16:54
@cgcote cgcote changed the title feat(apm): add http.referrer_host tag feat(apm): add referrer hostname as span tag Mar 21, 2025
@cgcote cgcote force-pushed the charles.cote/referrer_host branch from dee3b21 to 875e4c5 Compare March 25, 2025 11:39
Copy link
Contributor

@mabdinur mabdinur left a comment

Choose a reason for hiding this comment

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

Left some non blocking suggestions

Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

SGTM!

@cgcote cgcote force-pushed the charles.cote/referrer_host branch from 8e6d2a9 to 8ab9a24 Compare April 2, 2025 08:45
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

SGTM

@cgcote cgcote merged commit e7ebd87 into main Apr 2, 2025
537 of 538 checks passed
@cgcote cgcote deleted the charles.cote/referrer_host branch April 2, 2025 14:41
chojomok pushed a commit that referenced this pull request Apr 7, 2025
Parses referrer hostname from http header when presents and adds it to
span tags as `http.referrer_hostname`. This will be used to identify
frontend clients without leaking the PII which can be contained in the
entire referrer.

## Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
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