New APIs to add/remove metric readers at run-time#4863
New APIs to add/remove metric readers at run-time#4863JP-MY wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
aabmass
left a comment
There was a problem hiding this comment.
Thanks for the PR, sorry for the delay here.
ef20f0e to
9bb1567
Compare
|
@aabmass @herin049 I'm not sure why the lint is failing for protected access, I can see the same protected access in the same file. Should I add a |
aabmass
left a comment
There was a problem hiding this comment.
Thanks for fixing the concurrency issues, LGTM!
8a5c6ef to
04a652a
Compare
There was a problem hiding this comment.
You are introducing the last two typing errors, could you please take a look at them? The first one is the same as the second one so same fix should apply.
/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py:536:17 - error: Argument of type "(metric_reader: MetricReader, timeout_millis: float = 10000) -> (MetricsData | None)" cannot be assigned to parameter "func" of type "(MetricReader, AggregationTemporality) -> MetricsData" in function "_set_collect_callback"
Type "(metric_reader: MetricReader, timeout_millis: float = 10000) -> (MetricsData | None)" is not assignable to type "(MetricReader, AggregationTemporality) -> MetricsData"
Function return type "MetricsData | None" is incompatible with type "MetricsData"
Type "MetricsData | None" is not assignable to type "MetricsData"
"None" is not assignable to "MetricsData" (reportArgumentType)
/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py:704:17 - error: Argument of type "(metric_reader: MetricReader, timeout_millis: float = 10000) -> (MetricsData | None)" cannot be assigned to parameter "func" of type "(MetricReader, AggregationTemporality) -> MetricsData" in function "_set_collect_callback"
Type "(metric_reader: MetricReader, timeout_millis: float = 10000) -> (MetricsData | None)" is not assignable to type "(MetricReader, AggregationTemporality) -> MetricsData"
Function return type "MetricsData | None" is incompatible with type "MetricsData"
Type "MetricsData | None" is not assignable to type "MetricsData"
"None" is not assignable to "MetricsData" (reportArgumentType)
/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py:720:49 - error: Argument of type "None" cannot be assigned to parameter "func" of type "(MetricReader, AggregationTemporality) -> MetricsData" in function "_set_collect_callback"
Type "None" is not assignable to type "(MetricReader, AggregationTemporality) -> MetricsData" (reportArgumentType)
You can replicate with tox -e typecheck and
diff --git a/pyproject.toml b/pyproject.toml
index b9bcd3453..951aeb598 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -129,7 +129,6 @@ include = [
exclude = [
"opentelemetry-sdk/tests",
"opentelemetry-sdk/src/opentelemetry/sdk/_events",
- "opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_reservoir.py",
|
@JP-MY Please add a changelog entry |
|
@JP-MY we can't push to this PR unfortunately, probably because it's off of your main branch. Could you fix the merge conflict with diff --cc opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py
index e6cb5a3a,4109e129..a3388b06
--- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py
@@@ -58,8 -58,7 +58,8 @@@ class MeasurementConsumer(ABC)
class SynchronousMeasurementConsumer(MeasurementConsumer):
def __init__(
self,
- sdk_config: "opentelemetry.sdk.metrics._internal.SdkConfiguration",
+ sdk_config: "opentelemetry.sdk.metrics._internal.sdk_configuration.SdkConfiguration",
+ metric_readers: Iterable["opentelemetry.sdk.metrics.MetricReader"],
) -> None:
self._lock = Lock()
self._sdk_config = sdk_configAnd add changelog? |
Description
This change adds two public functions to MeterProvider that allow registering and deleting metric readers at run-time.
Fixes #4818
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: