Skip to content

Add option to disable sending telemetry to an Otel Collector#647

Merged
p-j-smith merged 16 commits into
mainfrom
paul/646-disable-otel
Jul 1, 2026
Merged

Add option to disable sending telemetry to an Otel Collector#647
p-j-smith merged 16 commits into
mainfrom
paul/646-disable-otel

Conversation

@p-j-smith

@p-j-smith p-j-smith commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #646

  • use the OTEL_SDK_DISABLED environment variable to determine whether telemetry should be disabled
  • also disable telemetry if OTEL_SDK_DISABLED is False but OTEL_EXPORTER_OTLP_ENDPOINT is empty (otherwise we will still see errors in the logs)
  • reuse the existing LoggerProvider created by opentelemetry, otherwise we see a warning in the logs: Overriding of current LoggerProvider is not allowed
  • add tests to check the sdk can be disabled and the default logging provider reused
  • update the docs

I've tested this on the GAE and it stops the error messages. If the sdk is enabled, we also need to make sure the service name of the endpoint is added to the no_proxy variable (or use docker.host.internal as the hostname for the endpoint)

Type of change

Please delete options accordingly to the description.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Suggested Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have passed on my local host device. (see further details at the CONTRIBUTING document)
  • Make sure your branch is up-to-date with main branch. See CONTRIBUTING for a general example to syncronise your branch with the main branch.
  • I have requested review to this PR.
  • I have addressed and marked as resolved all the review comments in my PR.
  • Finally, I have selected squash and merge

…_anon` (#644)

* Add a configure_tracing function to set up a trace provider

* Remove unused OTEL_EXPORTER_OTLP_HEADERS env var

* Add a instrument_pika_producer to producer.py to instrument and enrich the producer

* Instrument the cli

Add a function to get set the relevent otel env vars before calling configure_logging and configure_tracing

* Instrument orthanc raw

* Instrument orthanc anon

* Use logging fixtures from the conftest

* Add tests for configure_tracing

* Manually create a span before publishing the message

This way the span belongs to the CLI rather than to the queue

* Remove test of configure_tracing as we're no longer returning a bool

* Add OTEL_SDK_DISABLED environment variable to disable sending telemetry
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.52%. Comparing base (f4ad704) to head (2405278).

Files with missing lines Patch % Lines
pixl_core/src/core/telemetry.py 88.37% 5 Missing ⚠️
pixl_imaging/src/pixl_imaging/main.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #647      +/-   ##
==========================================
- Coverage   88.53%   88.52%   -0.02%     
==========================================
  Files          80       80              
  Lines        3813     3834      +21     
==========================================
+ Hits         3376     3394      +18     
- Misses        437      440       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread cli/src/pixl_cli/main.py Outdated
Comment thread pixl_core/src/core/logging.py
@p-j-smith p-j-smith changed the title Paul/646 disable otel Add option to disable sending telemetry to an Otel Collector Jun 30, 2026
@p-j-smith p-j-smith force-pushed the paul/646-disable-otel branch from adc735e to b66196e Compare June 30, 2026 12:08
@p-j-smith p-j-smith requested a review from stefpiatek June 30, 2026 13:21

@stefpiatek stefpiatek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Paul, looking good

Comment thread pixl_core/src/core/telemetry.py Outdated
Comment thread pixl_core/src/core/logging.py
@p-j-smith p-j-smith merged commit 407861a into main Jul 1, 2026
11 checks passed
@p-j-smith p-j-smith deleted the paul/646-disable-otel branch July 1, 2026 11:03
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.

OTel is not disabled by default

2 participants