Skip to content
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

OpenTelemetry support #59

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

[mypy-mockito.*]
ignore_missing_imports = True

[mypy-opentelemetry.*]
ignore_missing_imports = True
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 9.3
===========

* Support OpenTelemetry trace propagation. `#59 <https://github.com/iqm-finland/iqm-client/pull/59>`_

Version 9.2
===========

Expand Down
11 changes: 11 additions & 0 deletions src/iqm_client/iqm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,17 @@ def submit_circuits(
if bearer_token:
headers['Authorization'] = bearer_token

try:
# check if someone is trying to profile us with OpenTelemetry
# pylint: disable=import-outside-toplevel
# pylint: disable=import-error
from opentelemetry import propagate

propagate.inject(headers)
except ImportError as _:
# no OpenTelemetry, no problem
pass

result = requests.post(
join(self._base_url, 'jobs'), json=data.dict(exclude_none=True), headers=headers, timeout=REQUESTS_TIMEOUT
)
Expand Down