feat(telemetry): decouple module/operation identifiers from enums#240
Draft
jeanscherf wants to merge 2 commits into
Draft
feat(telemetry): decouple module/operation identifiers from enums#240jeanscherf wants to merge 2 commits into
jeanscherf wants to merge 2 commits into
Conversation
…fiers Module and Operation enums are still fully supported, but record_metrics, record_request_metric, record_error_metric, and default_attributes now accept any str so external packages can plug into the telemetry layer without needing entries in the OSS enums.
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.
Description
The
record_metricsdecorator and the underlyingrecord_request_metric,record_error_metric, anddefault_attributesfunctions previously requiredModuleandOperationenum values defined inside this package. This made it impossible for external packages to use the OSS telemetry infrastructure without adding entries to those enums via a PR to this repo.This change relaxes the type constraints from
Module/Operationenums to plainstrthroughout. SinceModuleandOperationalready extendstr, all existing callsites are unaffected — enum values continue to work exactly as before. External packages can now pass plain strings (e.g.@record_metrics("my_module", "my_operation")) and plug into the same OTel infrastructure without any changes here.The
isinstance(source_kwarg, Module)guard in the decorator is also relaxed toisinstance(source_kwarg, str)for the same reason.Type of Change
How to Test
OTEL_EXPORTER_OTLP_ENDPOINTis set.Module.DESTINATION,Operation.GET_DESTINATION) continues to work unchanged.uv run pytest tests/core/unit/telemetry/test_metrics_decorator.py— all tests including the newTestRecordMetricsDecoratorPlainStringsclass should pass.Checklist
Additional Notes
The
ModuleandOperationenums remain the canonical, recommended way to call the API for OSS consumers — they are still exported and fully supported. This change only opens the contract so external packages are not forced to contribute to this repo to use the telemetry layer.