Skip to content

feature: add open telemetry integration#3

Open
fcarreno-collab wants to merge 9 commits into
masterfrom
feature/olt_middleware
Open

feature: add open telemetry integration#3
fcarreno-collab wants to merge 9 commits into
masterfrom
feature/olt_middleware

Conversation

@fcarreno-collab
Copy link
Copy Markdown

@fcarreno-collab fcarreno-collab marked this pull request as ready for review January 16, 2026 20:01
Copy link
Copy Markdown

@caseylocker caseylocker left a comment

Choose a reason for hiding this comment

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

You're defining randomString in api/tests/open_telemetry_instrumentation_tests.py but not using it:

class OpenTelemetryInstrumentationTest(APITestCase):
    def randomString(self, str_len):
...

Wrapt was downgraded in the requirements.txt. Was that intentional?
wrapt==2.0.1 -> wrapt==1.17.3

@fcarreno-collab
Copy link
Copy Markdown
Author

You're defining randomString in api/tests/open_telemetry_instrumentation_tests.py but not using it:

class OpenTelemetryInstrumentationTest(APITestCase):
    def randomString(self, str_len):

@caseylocker I removed this code you are right, its not been used, this was to generate a random string for the access_token we use to authenticate the requests on the other endpoints but here that does not happen

Wrapt was downgraded in the requirements.txt. Was that intentional? wrapt==2.0.1 -> wrapt==1.17.3

@caseylocker it was on propuse because newer versions create dependency conflicts when we try to install the open telemetry instrumentation libraries

Copy link
Copy Markdown

@caseylocker caseylocker left a comment

Choose a reason for hiding this comment

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

LGTM. I've confirmed that the wrapt downgrade was a requirement by the Opentelementry instrumentation packages. They explicitly require wrapt<2.0.0. No other packages require wrapt 2.x

Comment thread backend/otel_instrumentation.py
Copy link
Copy Markdown
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@fcarreno-collab please review comments

@dariobressanExo
Copy link
Copy Markdown

@smarcet please can you review this.

Comment thread backend/settings.py Outdated
Comment thread api/tests/open_telemetry_instrumentation_tests.py Outdated
Comment thread api/tests/open_telemetry_instrumentation_tests.py Outdated
Comment thread api/tests/open_telemetry_instrumentation_tests.py
Copy link
Copy Markdown
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@fcarreno-collab please review

@fcarreno-collab
Copy link
Copy Markdown
Author

@smarcet changes related your comments already on PR

Comment thread requirements.txt
Comment thread backend/otel_instrumentation.py Outdated
Comment thread backend/otel_instrumentation.py Outdated
Copy link
Copy Markdown
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@fcarreno-collab please review comments

@fcarreno-collab
Copy link
Copy Markdown
Author

@smarcet branch updated with requested changes

@matiasperrone-exo
Copy link
Copy Markdown

@smarcet please review again as all the requested/agreed changes were incorporated.

Comment thread backend/otel_instrumentation.py Outdated
return

# Attach CF-Ray header
cf_ray = span.set_attribute("cf.ray_id", request.headers.get("Cf-Ray"))
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.

span.set_attribute() returns None, so cf_ray is always falsy and the second attribute is never set. The cf.ray_id attribute is written correctly (as a side-effect of the first call), so
the test test_cf_ray_header passes despite this bug, masking it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you

Comment thread backend/settings.py Outdated

DEV_EMAIL = os.getenv('DEV_EMAIL')

OTEL_INSTRUMENTATION_ENABLED = env_bool('OTEL_INSTRUMENTATION_ENABLED', True)
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.

Any environment without this variable explicitly set to false will try to instrument. If OTEL_EXPORTER_OTLP_ENDPOINT is not configured, otel_endpoint mode will fail silently or log errors
on every request. Defaulting to False is safer.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you

@andrestejerina97
Copy link
Copy Markdown

It's ready to review @romanetar

@andrestejerina97 andrestejerina97 requested a review from romanetar May 8, 2026 11:31
Copy link
Copy Markdown
Contributor

@romanetar romanetar left a comment

Choose a reason for hiding this comment

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

LGTM

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.

9 participants