Skip to content

Add semantic-convention conformance test for the requests instrumentation - #4967

Draft
ocelotl wants to merge 1 commit into
open-telemetry:mainfrom
ocelotl:requests_semconv_conformance
Draft

Add semantic-convention conformance test for the requests instrumentation#4967
ocelotl wants to merge 1 commit into
open-telemetry:mainfrom
ocelotl:requests_semconv_conformance

Conversation

@ocelotl

@ocelotl ocelotl commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a semantic-convention conformance test for the requests instrumentation, the HTTP-client counterpart of the Flask (server) conformance test in #4966. It runs as an ordinary pytest test in the requests instrumentation's existing test suite (no separate tox environment or workflow): the test drives the requests instrumentation over a defined set of HTTP requests against a mock server and checks that the emitted telemetry conforms to the HTTP semantic conventions. A convention violation is a normal test failure.

The check reuses the tooling from open-telemetry/semantic-conventions-conformance (the generic runner, the HTTP domain runner, the mock server, and the HTTP test client) via its pytest plugin, which collects the conformance.yaml and turns each scenario into a pytest item. The telemetry is validated with Weaver against a pinned semantic-conventions registry.

This is the second instrumentation in a planned series (Flask was first, in #4966): the intent is to add semantic-convention conformance tests to the Python instrumentations where this kind of testing applies, one at a time.

Shared harness / code reuse

The Weaver-and-registry provisioning conftest.py is a shared harness kept byte-for-byte identical across instrumentations (the same file as in #4966). Only the per-instrumentation parts differ: the scenario (which turns on RequestsInstrumentor), the conformance.yaml (client shape: it starts the HTTP mock server and runs a client scenario), the client workload, and the pinned tooling lines added to this package's test-requirements.txt.

What it adds

  • instrumentation/opentelemetry-instrumentation-requests/tests/semconv_conformance/: a client workload that drives the shared request contract with a requests.Session, a scenario that enables RequestsInstrumentor, a conformance.yaml (client scenario plus a server: block that runs the mock server), and the shared conftest.py.
  • The four conformance tooling packages added to the requests instrumentation's test-requirements.txt (and pytest>=8, which the tooling requires).

Draft status and open points

This is a draft for discussion. Known points, same as #4966:

  • The conformance tooling is not yet published to a package index, so it is currently installed from a pinned Git ref of the conformance repository. This would move to a released dependency once the tooling is published.
  • The long-term way to remove the duplicated conftest.py is to move the provisioning upstream into the conformance tooling itself.

Feedback on the approach is welcome.

…tion

Check the requests instrumentation against the HTTP semantic conventions using
the semantic-conventions-conformance tooling, run through its pytest plugin so a
convention violation is an ordinary test failure. The test is a normal pytest
test collected by the requests instrumentation's existing test suite: no
dedicated tox environment and no separate workflow.

requests is an HTTP client, so unlike the Flask (server) scenario the
conformance.yaml declares a mock HTTP server (otel-http-mock-server) for the
client to call, and the scenario drives the shared client workload at it with
RequestsInstrumentor enabled. The scenario exercises this repository's own
working-tree requests instrumentation, not a released pin.

The tooling is installed from a pinned git ref alongside the other test
dependencies (pytest bumped to >= 8, which the tooling requires). The shared
conftest that provisions the Weaver binary and the pinned registry on demand,
and skips cleanly when they cannot be obtained, is byte-for-byte identical to
the one used by the Flask conformance test.
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-20 17:54 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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.

1 participant