-
Notifications
You must be signed in to change notification settings - Fork 2
Manually instrument traces in pixl_cli, orthanc_raw, and orthanc_anon
#644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4aad370
Add a configure_tracing function to set up a trace provider
p-j-smith 78ee163
Remove unused OTEL_EXPORTER_OTLP_HEADERS env var
p-j-smith d4237b7
Add a instrument_pika_producer to producer.py to instrument and enric…
p-j-smith d0c01dd
Instrument the cli
p-j-smith 09075ae
Instrument orthanc raw
p-j-smith 4048d7c
Instrument orthanc anon
p-j-smith 9ee48d9
Use logging fixtures from the conftest
p-j-smith 41fd1be
Add tests for configure_tracing
p-j-smith 23f426c
Manually create a span before publishing the message
p-j-smith bea0c56
Remove test of configure_tracing as we're no longer returning a bool
p-j-smith fe104ac
Add OTEL_SDK_DISABLED environment variable to disable sending telemetry
p-j-smith 1109433
Merge branch 'main' into paul/638-manually-instrument-traces
p-j-smith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) University College London Hospitals NHS Foundation Trust | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Configure OpenTelemetry tracing for services not wrapped by opentelemetry-instrument.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import atexit | ||
| import os | ||
|
|
||
| from opentelemetry import trace | ||
| from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter | ||
| from opentelemetry.sdk.resources import Resource | ||
| from opentelemetry.sdk.trace import TracerProvider | ||
| from opentelemetry.sdk.trace.export import BatchSpanProcessor | ||
|
|
||
| __all__ = ["configure_tracing"] | ||
|
p-j-smith marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def configure_tracing() -> None: | ||
| """ | ||
| Set up an OTLP span exporter when OTEL_EXPORTER_OTLP_ENDPOINT is set. | ||
|
|
||
| When the endpoint is not set, tracing and spans are no-ops. | ||
| """ | ||
| if not os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT"): | ||
| return | ||
|
|
||
| exporter = OTLPSpanExporter() | ||
| processor = BatchSpanProcessor(exporter) | ||
| provider = TracerProvider(resource=Resource.create()) | ||
| provider.add_span_processor(processor) | ||
| trace.set_tracer_provider(provider) | ||
| atexit.register(provider.shutdown) | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.