Skip to content

Commit

Permalink
chore: add missing server address tags to snapshot tests (#11349)
Browse files Browse the repository at this point in the history
Continuation of #10064 to add `server.address` tags to DB clients to
comply with OTel standards.

Update `django` snapshot files, and modify the logic to set
`server_address` using the existing internal method (for future
instrumentations).

## 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)
  • Loading branch information
quinna-h committed Nov 13, 2024
1 parent 4cf2aaf commit 470bf81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ddtrace/contrib/trace_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def set_http_meta(
method=None, # type: Optional[str]
url=None, # type: Optional[str]
target_host=None, # type: Optional[str]
server_address=None, # type: Optional[str]
status_code=None, # type: Optional[Union[int, str]]
status_msg=None, # type: Optional[str]
query=None, # type: Optional[str]
Expand Down Expand Up @@ -474,6 +475,9 @@ def set_http_meta(
if target_host is not None:
span.set_tag_str(net.TARGET_HOST, target_host)

if server_address is not None:
span.set_tag_str(net.SERVER_ADDRESS, server_address)

if status_code is not None:
try:
int_status_code = int(status_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"db.system": "postgresql",
"db.user": "postgres",
"out.host": "127.0.0.1",
"server.address": "127.0.0.1",
"span.kind": "client"
},
"metrics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"db.system": "postgresql",
"db.user": "postgres",
"out.host": "127.0.0.1",
"server.address": "127.0.0.1",
"span.kind": "client"
},
"metrics": {
Expand Down

0 comments on commit 470bf81

Please sign in to comment.