Repository navigation
refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake - #2541
Merged
Conversation
Owner
Author
|
Test evidence:
Pending a person: review the diff in tuicr ( |
11 tasks
dan-petty
marked this pull request as ready for review
October 28, 2026 21:16
…a shared fake The tracer posted traces, metrics and logs through the private `_send_payload` and `_send_payload_sync`, over a raw httpx2 client, and probed the collector with a second raw client or a socket. A gRPC protocol or endpoint posted OTLP/HTTP to the gRPC port, and every export failed with only a count. Tests patched the private methods to read what was exported. - `telemetry/exporter.py` holds the `OtlpExporter` seam and the real `HttpOtlpExporter`, which posts through the egress-checked client at the private level and gives each failure one text. The probe posts an empty trace export request. - `otlp_exporter` refuses a gRPC protocol or endpoint with an `OtlpProtocolError` that names the setting. The process tracer then keeps the command running with export off and warns once. - The client takes its exporter; `install_exporter` and `remove_exporter` put one in place of the configured exporter. - The gRPC exporter, the cached client and the socket probe are deleted, and `opentelemetry-sdk` replaces `opentelemetry-exporter-otlp-proto-grpc` in the direct dependencies. - `FakeCollector` and the `otlp` fixture, with the contract suite in `tests/telemetry/`, replace the `captured` fixture and the patches of the migrated tests.
dan-petty
force-pushed
the
refactor/1319-otlp-exporter-seam
branch
from
October 28, 2026 21:20
2c13fca to
dc68aba
Compare
dan-petty
pushed a commit
that referenced
this pull request
Oct 28, 2026
🤖 I have created a release *beep* *boop* --- ## [0.11.3](v0.11.2...v0.11.3) (2026-10-28) ### Bug Fixes * **roadmap:** refine wraps no link in the model's code, and wraps each reference and link that GitHub makes from its text ([#2540](#2540)) ([2d38f8d](2d38f8d)), closes [#2525](#2525) ### Code Refactoring * **docker:** DockerEngineService is the Docker engine seam, with an in-memory engine fake and its contract suite ([#2534](#2534)) ([1244cbf](1244cbf)), closes [#1316](#1316) * **security:** one keyring seam owns the keyring and the Secret Service, with a shared fake and its contract suite ([#2532](#2532)) ([866d2cb](866d2cb)), closes [#1318](#1318) * **telemetry:** OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake ([#2541](#2541)) ([8da35e6](8da35e6)), closes [#1319](#1319) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty
added a commit
that referenced
this pull request
Oct 28, 2026
…ort, 4318 (#2549) The egress rule of the `devops` perimeter to the `otel` namespace (`k8s/devops/networkpolicy.yaml`, rule 3) names the one port TCP 4318, the collector's OTLP/HTTP port. It no longer allows TCP 4317. devops-cli sends OTLP over HTTP only since #1319 (PR #2541): a gRPC protocol or an endpoint on port 4317 is refused. No pod of the namespace sends OTLP over gRPC: the devops config names port 4318, and Logfire sends to its own HTTPS endpoint. So the open gRPC port was more than the namespace needs. - A manifest test, `test_devops_egress_to_otel_admits_only_otlp_http`, fails when that rule names another port. - The `otel` perimeter still admits 4317 from every namespace for other clients, and the collector and Tempo keep their gRPC receivers. - The `otlp-export` capability records the rule. `k8s/README.md` names no port for this egress, so it stays correct. Closes #2548 Change: `openspec/changes/archive/2026-10-28-2548-devops-otlp-http-egress/`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
OTLP export goes through one exporter seam, and tests read what the tracer exports from a shared OTLP fake instead of patching its private methods.
src/devops_cli/telemetry/exporter.pyis the edge between the tracer and the collector.OtlpExporterexports one signal's encoded request (/v1/traces,/v1/metrics,/v1/logs) and probes the collector.HttpOtlpExporter, the real exporter, posts through the egress-checked client (new_http_client, private level), so the telemetry clients that fix(security): the pre-flight resolve paths go, the kept pre-flight checks call vet_addresses, and the docs say every http client is checked at the connect #2437 waits on are on the factory. Each failure has one text:HTTP <status>, "Cannot connect to the collector" or "The collector did not answer in time".pingspan of the servicedevops-cli-ping.OTEL_EXPORTER_OTLP_PROTOCOL=grpc(or another value that is nothttp/jsonorhttp/protobuf), or with no protocol an endpoint with thegrpcscheme or port 4317, fails with anOtlpProtocolErrorthat names the setting. Before, every export to that port failed with only a count. The process tracer keeps the command running with export off, logs one warning, and its probe indevops telemetry statusreports the message.OTelTelemetryClienttakes anexporterand keeps its executor, dry-run suppression and counters.install_exporterandremove_exporterput an exporter in place of the configured one, with export on; the floor removes it after each test._get_grpc_exporter,_get_http_client, the raw-socket gRPC probe and theprotocolattribute.opentelemetry-exporter-otlp-proto-grpcleaves the direct dependencies, andopentelemetry-sdk1.45.1, whichsrcimports for theMeterProvider, joins them.FakeCollectorintests/support/fakes/otlp.py, behind theotlpfixture, records each export and gives spans, metric data points and log records as plain values. The contract suitetests/telemetry/test_otlp_exporter_contract.pyruns each case on the fake and onHttpOtlpExporterover a loopback receiver. The export tests oftests/test_telemetry_collector_export.pyandtests/test_telemetry.py, and every user of thecapturedfixture, read the fake;tests/support/telemetry_capture.pyis deleted. The swallowed-failures ceiling oftelemetry/tracer.pyfalls from 16 to 12.Closes #1319
Change:
openspec/changes/archive/2026-10-28-1319-otlp-exporter-seam/