-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expose basic Otel classes and funtions to be importable through redis.observability to match the examples in the readthedocs #3996
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
Merged
petyaslavova
merged 3 commits into
master
from
ps_fix_otel_init_py_to_expose_base_objects
Mar 16, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
b8a70d1
Expose basic Otel classes and funtions to be importable through redis…
petyaslavova 202dd00
Merge branch 'master' into ps_fix_otel_init_py_to_expose_base_objects
petyaslavova 86656b3
Merge branch 'master' into ps_fix_otel_init_py_to_expose_base_objects
petyaslavova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """ | ||
| OpenTelemetry observability module for redis-py. | ||
|
|
||
| This module provides APIs for collecting and exporting Redis metrics using OpenTelemetry. | ||
|
|
||
| Usage: | ||
| from redis.observability import get_observability_instance, OTelConfig | ||
|
|
||
| otel = get_observability_instance() | ||
| otel.init(OTelConfig()) | ||
| """ | ||
|
|
||
| from redis.observability.config import MetricGroup, OTelConfig, TelemetryOption | ||
| from redis.observability.providers import ( | ||
| ObservabilityInstance, | ||
| get_observability_instance, | ||
| reset_observability_instance, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "OTelConfig", | ||
| "MetricGroup", | ||
| "TelemetryOption", | ||
| "ObservabilityInstance", | ||
| "get_observability_instance", | ||
| "reset_observability_instance", | ||
| ] | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """ | ||
| Unit tests for redis.observability public API exports. | ||
|
|
||
| These tests verify that all symbols exported from redis.observability | ||
| are correctly re-exported and match the original implementations. | ||
| """ | ||
|
|
||
|
|
||
| class TestPublicAPIExports: | ||
| """Tests for public API exports from redis.observability.""" | ||
|
|
||
| def test_otel_config_reexport(self): | ||
| """Test that OTelConfig is correctly re-exported.""" | ||
| from redis.observability import OTelConfig | ||
| from redis.observability.config import OTelConfig as OriginalOTelConfig | ||
|
|
||
| assert OTelConfig is OriginalOTelConfig | ||
|
|
||
| def test_metric_group_reexport(self): | ||
| """Test that MetricGroup is correctly re-exported.""" | ||
| from redis.observability import MetricGroup | ||
| from redis.observability.config import MetricGroup as OriginalMetricGroup | ||
|
|
||
| assert MetricGroup is OriginalMetricGroup | ||
|
|
||
| def test_telemetry_option_reexport(self): | ||
| """Test that TelemetryOption is correctly re-exported.""" | ||
| from redis.observability import TelemetryOption | ||
| from redis.observability.config import ( | ||
| TelemetryOption as OriginalTelemetryOption, | ||
| ) | ||
|
|
||
| assert TelemetryOption is OriginalTelemetryOption | ||
|
|
||
| def test_observability_instance_reexport(self): | ||
| """Test that ObservabilityInstance is correctly re-exported.""" | ||
| from redis.observability import ObservabilityInstance | ||
| from redis.observability.providers import ( | ||
| ObservabilityInstance as OriginalObservabilityInstance, | ||
| ) | ||
|
|
||
| assert ObservabilityInstance is OriginalObservabilityInstance | ||
|
|
||
| def test_get_observability_instance_reexport(self): | ||
| """Test that get_observability_instance is correctly re-exported.""" | ||
| from redis.observability import get_observability_instance | ||
| from redis.observability.providers import ( | ||
| get_observability_instance as original_get_observability_instance, | ||
| ) | ||
|
|
||
| assert get_observability_instance is original_get_observability_instance | ||
|
|
||
| def test_reset_observability_instance_reexport(self): | ||
| """Test that reset_observability_instance is correctly re-exported.""" | ||
| from redis.observability import reset_observability_instance | ||
| from redis.observability.providers import ( | ||
| reset_observability_instance as original_reset_observability_instance, | ||
| ) | ||
|
|
||
| assert reset_observability_instance is original_reset_observability_instance | ||
|
|
||
| def test_all_exports_defined(self): | ||
| """Test that __all__ contains all expected exports.""" | ||
| import redis.observability as obs | ||
|
|
||
| expected_exports = { | ||
| "OTelConfig", | ||
| "MetricGroup", | ||
| "TelemetryOption", | ||
| "ObservabilityInstance", | ||
| "get_observability_instance", | ||
| "reset_observability_instance", | ||
| } | ||
|
|
||
| assert set(obs.__all__) == expected_exports | ||
|
|
||
| def test_all_exports_are_accessible(self): | ||
| """Test that all items in __all__ are actually accessible.""" | ||
| import redis.observability as obs | ||
|
|
||
| for name in obs.__all__: | ||
| assert hasattr(obs, name), f"{name} is in __all__ but not accessible" | ||
| assert getattr(obs, name) is not None, f"{name} is None" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.