Skip to content

Export metrics to OTel collector and define custom metrics#649

Open
p-j-smith wants to merge 16 commits into
mainfrom
paul/642-otel-metrics
Open

Export metrics to OTel collector and define custom metrics#649
p-j-smith wants to merge 16 commits into
mainfrom
paul/642-otel-metrics

Conversation

@p-j-smith

Copy link
Copy Markdown
Contributor

Description

Fixes #642

  • enable sending metrics to an otlp endpoint
  • add a new function core.telemetry.configure_metrics to configure a metric provider
  • define three custom metrics:
    • number of studies exported per project (used in the export API)
    • number of studies that failed to be de-identified, per project and failure reason (used in Orthanc anon)
    • number of instances that failed to be de-identified, per project, study_uid, and failure reason
  • to get the queue depth, we can configure a scrate config in the OTel Collector, and RabbitMQ already exposes these metrics via prometheus. Add a config to the integration tests to scrape metrics RabbitMQ
  • add unit tests for the custom metrics
  • add note in the documentation about adding new metrics

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
Number of studies exported pixl-metrics-studies-exported
Study de-identification failures pixl-metrics-study-deidentification-failures

If we don't catch the SQLAlchemy DBAPIError exceptions and extract the first line, the error message contains the full SQL that caused the failure, which would make the message unsuitable for filtering / aggregating:

pixl-metrics-study-deidentification-failures-high-cardinality
Instance de-identification failures pixl-metrics-instance-deidentification-failures
Queue depth pixl-metrics-queue-depth

@p-j-smith p-j-smith requested a review from stefpiatek July 1, 2026 16:17
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.86275% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.10%. Comparing base (407861a) to head (a9f74a5).

Files with missing lines Patch % Lines
pixl_core/src/core/telemetry.py 31.57% 13 Missing ⚠️
pixl_core/src/core/metrics.py 71.42% 8 Missing ⚠️
pixl_export/src/pixl_export/main.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
- Coverage   88.52%   88.10%   -0.43%     
==========================================
  Files          80       81       +1     
  Lines        3834     3883      +49     
==========================================
+ Hits         3394     3421      +27     
- Misses        440      462      +22     

☔ 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.

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.

Export metrics to the OTel collector

1 participant