feat: Add custom span naming for dbapi and requests #3675
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request contains custom modifications to the
opentelemetry-instrumentation-dbapi
andopentelemetry-instrumentation-requests
packages. The primary goal of these changes is to enrich the default span names for database and HTTP client operations with more specific, low-cardinality information.dbapi
instrumentation: The span name is modified to include the table name, derived from parsing the SQL statement. For example, a span forSELECT * FROM users
will be namedSELECT users
.requests
instrumentation: The span name is modified to include the URL path. For example, a span for aGET
request tohttps://example.com/api/v1/users
will be namedGET /api/v1/users
.Note: This pull request is for internal use and serves as a proof of concept. The changes bypass standard extension points and would not be suitable for general use. We are using this fork to deploy our custom instrumentation packages via a git dependency in our
requirements.txt
.No issue is fixed in the upstream repository, as this addresses a specific configuration challenge we encountered.
Type of change
How Has This Been Tested?
This change was tested in a local Dockerized Python 3.11 environment.
psycopg2
and execute a DML query (e.g.,SELECT
,INSERT
).{OPERATION} {table_name}
.GET
request using therequests
library to a specific URL (e.g.,http://example.com/users/123
).{METHOD} {url_path}
.Does This PR Require a Core Repo Change?
Checklist: