feat: add OpenTelemetry metrics support#553
Open
ajbozarth wants to merge 6 commits intogenerative-computing:mainfrom
Open
feat: add OpenTelemetry metrics support#553ajbozarth wants to merge 6 commits intogenerative-computing:mainfrom
ajbozarth wants to merge 6 commits intogenerative-computing:mainfrom
Conversation
Refactored telemetry module structure to follow Python best practices: - Moved tracing implementation from __init__.py to new tracing.py module - Updated __init__.py to only contain imports and exports - Updated backend_instrumentation.py to import from tracing module This improves code organization and maintainability by separating implementation from the package interface. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Implemented comprehensive metrics support using OpenTelemetry Metrics API: - Created mellea/telemetry/metrics.py with: - Lazy MeterProvider initialization (similar to tracing pattern) - Environment-based configuration (MELLEA_METRICS_ENABLED, MELLEA_METRICS_CONSOLE) - Zero overhead when disabled (no-op instrument classes) - Named meter: mellea.metrics - Instrument creation helpers: - create_counter() - for monotonically increasing values - create_histogram() - for value distributions - create_up_down_counter() - for values that can increase/decrease - Updated mellea/telemetry/__init__.py to export metrics functions Environment Variables: - MELLEA_METRICS_ENABLED (default: false) - Enable metrics collection - MELLEA_METRICS_CONSOLE (default: false) - Print metrics to console Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Fixes test failures after f449d9a moved tracing code to submodule. Test fixtures now reload mellea.telemetry.tracing to pick up env var changes. Also moved test file to test/telemetry/test_tracing.py to mirror source structure. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Comprehensive test coverage for metrics configuration, lazy initialization, instrument creation, no-op behavior, and functional operations. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
After moving tracing code from __init__.py to tracing.py, the test fixture needs to import from mellea.telemetry.tracing instead of mellea.telemetry. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Contributor
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Contributor
Author
|
Opening this with what I have at EOD for peer review, I want to spend more time re-reviewing this myself before final merge as it was primarily ai generated and I've only done one manual review pass so far |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Misc PR
Type of PR
Description
Implemented OpenTelemetry metrics support for Mellea:
Changes:
__init__.pyto dedicatedtracing.pymodule for better organizationmellea/telemetry/metrics.pywith full OpenTelemetry metrics support including:Testing:
test/telemetry/test_metrics.pywith extensive coverage of metric creation, recording, and exportThe implementation follows OpenTelemetry standards and integrates seamlessly with Mellea's existing tracing infrastructure.
Testing