opentelemetry-python-contrib This Week: Query Redaction, GCP Cloud Run Detection and urllib Fixes
I looked at the last week of commits in opentelemetry-python-contrib, the home of the Python instrumentation packages, resource detectors and distro code. Eleven commits landed, mostly on November 19. The highlights are a new query string redaction helper, richer GCP resource detection including Cloud Run Jobs, and a batch of fixes in the urllib instrumentation.
Query string redaction lands in util-http
The biggest change is the redact_query_string helper (#4944). It adds a redact_query_string function to opentelemetry-util-http and applies it in the WSGI instrumentation, touching the main util-http module and the WSGI instrumentation.
Why it matters: WSGI spans often carry the full request URL, query string included. Tokens and session ids in the query end up on spans and in your backend. Redaction is now centralized in the util package instead of each instrumentation doing its own thing.
Related hardening in the same area: a fix that ignores blank entries in captured and sanitized header lists (#5305). Empty strings in header config no longer produce confusing capture behavior.
GCP resource detector: Cloud Run Jobs and cloud.resource_id
The GCP detector got a meaningful update in PR #5352, merged as this commit. Two things changed:
- The detector populates the
cloud.resource_idsemantic convention attribute - It detects Cloud Run Jobs, not just Cloud Run services, with the new FaaS detection logic in
_faas.py
If you run jobs on Cloud Run, your resource attributes should now identify them correctly instead of falling back to generic values. The change comes with new tests and updated snapshots for the detector output.
On the Azure side, the resource detector was prepared and released as v0.4.0 and then bumped to v0.5.0 development.
urllib client metrics and timeouts
The urllib instrumentation saw two user visible fixes:
- server.address and server.port added to client metrics (#5216). HTTP client metrics emitted by urllib now carry these attributes, which matches the latest client metrics conventions. Before this, HTTP client metrics emitted by urllib lacked server identity, which made dashboards hard to split by host.
- The default timeout is preserved in OpenerDirector.open (#5347). Instrumentation wraps
open(), and a previous pattern could drop the timeout your code passed or relied on. If you had urllib calls suddenly ignoring timeouts, this is the fix. Most of the edits went into the urllib instrumentation module.
Also in the HTTP family: the Starlette docs were corrected around capturing all headers, and the Tornado instrumentation now passes client span attributes at span creation (#5348), which avoids sampling decisions made before attributes are attached.
Distro, logging API and test bumps
Smaller but useful items:
- Optional arguments to get_logger are passed by keyword (#5337). This protects against future signature changes in the logging API and is flagged with the gen-ai label.
- The distro now tests the default logs exporter (#5179). The test asserts
OTEL_LOGS_EXPORTERis set tootlp, matching the existing traces and metrics assertions:
self.assertEqual("otlp", os.environ.get(OTEL_LOGS_EXPORTER))
- The docker test suite bumped Django from 4.2.30 to 5.2.17. Test only change, no shipped package impact.
What to watch
- The WSGI redaction change is a good template. Expect the same
redact_query_stringhelper to show up in ASGI and other HTTP instrumentations. - Check your urllib HTTP client metric dashboards after the next release. New
server.addressandserver.portattributes change metric cardinality. - If you run Cloud Run Jobs on GCP, verify the detected resource attributes after upgrading the GCP detector package.