-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add OpenTelemetry instrumentator middleware #5
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: pushkarm029 <[email protected]>
Reviewer's Guide by SourceryThis pull request introduces an OpenTelemetryInstrumentor middleware for Starlette applications, enabling tracing and metrics collection using OpenTelemetry. The implementation includes setting up TracerProvider and MeterProvider with appropriate exporters, and integrates with the Starlette application using StarletteInstrumentor. File-Level Changes
Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Pushkarm029 - I've reviewed your changes - here's some feedback:
Overall Comments:
- The PR looks good overall, but it's important to add unit tests to verify the functionality of the new OpenTelemetryInstrumentor and init_middleware function. This will ensure the instrumentation works as expected and help prevent regressions in the future.
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Signed-off-by: pushkarm029 <[email protected]>
cloud_telemetry/middleware.py
Outdated
class OpenTelemetryInstrumentor: | ||
"""Instruments a Starlette application with OpenTelemetry.""" | ||
|
||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for staticmethod
specifically?
I think this ties us down from making custom choices, I think we would might want these methods to interact with other data and memebers, for example lets say you want to tracing and metric boolean to be defined at class level and then set the dafault from class member, this way user can have more flexibility when envoking these methods, unless ofc you are aiming for some desing pattern like factory patter
or singleton patter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I have pushed some changes, please have a look.
Signed-off-by: pushkarm029 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 8 8
=========================================
Hits 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
This PR introduces a middleware component for integrating OpenTelemetry instrumentation into a Starlette application. The OpenTelemetryInstrumentor class facilitates the setup of both tracing and metrics collection by configuring the necessary OpenTelemetry providers and exporters.
Key Features:
Exception Handling:
Checklist
of this project, including, in particular, with regard to any style guidelines
Conventional Commits specification; in particular, it clearly
indicates that a change is a breaking change
using the PR title as the commit message
changed behavior
or updated existing ones (only for Python, TypeScript, etc.)
(Google-style Python docstrings) for all
packages/modules/functions/classes/methods or updated existing ones
works
Comments
Summary by Sourcery
Integrate OpenTelemetry instrumentation into a Starlette application by adding a middleware component. This includes setting up tracing and metrics collection using OpenTelemetry providers and exporters, and handling exceptions during the setup process.
New Features:
Enhancements:
Documentation: