Skip to content

Commit 26119ef

Browse files
committed
Address comments
1 parent 1064023 commit 26119ef

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_configurator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
AWS_LAMBDA_FUNCTION_NAME_CONFIG = "AWS_LAMBDA_FUNCTION_NAME"
7878
AWS_XRAY_DAEMON_ADDRESS_CONFIG = "AWS_XRAY_DAEMON_ADDRESS"
7979
OTEL_AWS_PYTHON_DEFER_TO_WORKERS_ENABLED_CONFIG = "OTEL_AWS_PYTHON_DEFER_TO_WORKERS_ENABLED"
80+
SYSTEM_METRICS_INSTRUMENTATION_SCOPE_NAME = "opentelemetry.instrumentation.system_metrics"
8081

8182
_logger: Logger = getLogger(__name__)
8283

@@ -122,7 +123,6 @@ def _initialize_components():
122123

123124
auto_resource: Dict[str, any] = {}
124125
auto_resource = _customize_versions(auto_resource)
125-
# auto_resource = _set_aws_attributes(auto_resource)
126126
resource = _customize_resource(
127127
get_aggregated_resources(
128128
[
@@ -330,17 +330,17 @@ def _customize_span_processors(provider: TracerProvider, resource: Resource) ->
330330

331331
def _customize_metric_exporters(metric_readers: List[MetricReader], views: List[View]) -> None:
332332
if _is_application_signals_runtime_enabled():
333-
system_metrics_scope_name = "opentelemetry.instrumentation.system_metrics"
333+
runtime_metrics_scope_name = SYSTEM_METRICS_INSTRUMENTATION_SCOPE_NAME
334334
if 0 == len(metric_readers):
335-
_logger.info("Registered scope %s", system_metrics_scope_name)
336-
views.append(View(meter_name=system_metrics_scope_name, aggregation=DefaultAggregation()))
335+
_logger.info("Registered scope %s", runtime_metrics_scope_name)
336+
views.append(View(meter_name=runtime_metrics_scope_name, aggregation=DefaultAggregation()))
337337
views.append(View(instrument_name="*", aggregation=DropAggregation()))
338338

339-
otel_metric_exporter = ApplicationSignalsExporterProvider().create_exporter()
339+
application_signals_metric_exporter = ApplicationSignalsExporterProvider().create_exporter()
340340
scope_based_periodic_exporting_metric_reader = ScopeBasedPeriodicExportingMetricReader(
341-
exporter=otel_metric_exporter,
341+
exporter=application_signals_metric_exporter,
342342
export_interval_millis=_get_metric_export_interval(),
343-
registered_scope_names={system_metrics_scope_name},
343+
registered_scope_names={runtime_metrics_scope_name},
344344
)
345345
metric_readers.append(scope_based_periodic_exporting_metric_reader)
346346

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelementry_configurator.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,23 +237,26 @@ def test_not_using_xray_sampler_does_not_modify_url_exclusion_env_vars(self):
237237
def test_is_application_signals_enabled(self):
238238
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "True")
239239
self.assertTrue(_is_application_signals_enabled())
240-
self.assertTrue(_is_application_signals_runtime_enabled())
240+
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
241+
242+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "False")
243+
self.assertFalse(_is_application_signals_enabled())
244+
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
245+
self.assertFalse(_is_application_signals_enabled())
241246

247+
def test_is_application_signals_runtime_enabled(self):
248+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "True")
249+
self.assertTrue(_is_application_signals_runtime_enabled())
242250
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", "False")
243-
self.assertTrue(_is_application_signals_enabled())
244251
self.assertFalse(_is_application_signals_runtime_enabled())
245-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
246-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
247252

248253
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "False")
249254
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", "True")
250-
self.assertFalse(_is_application_signals_enabled())
251255
self.assertFalse(_is_application_signals_runtime_enabled())
252256

253257
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
254-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
258+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
255259
self.assertFalse(_is_application_signals_enabled())
256-
self.assertFalse(_is_application_signals_runtime_enabled())
257260

258261
def test_customize_sampler(self):
259262
mock_sampler: Sampler = MagicMock()

0 commit comments

Comments
 (0)