Skip to content

Commit 1bb3a1a

Browse files
committed
Address comments
1 parent 67979ef commit 1bb3a1a

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
AWS_LAMBDA_FUNCTION_NAME_CONFIG = "AWS_LAMBDA_FUNCTION_NAME"
7979
AWS_XRAY_DAEMON_ADDRESS_CONFIG = "AWS_XRAY_DAEMON_ADDRESS"
8080
OTEL_AWS_PYTHON_DEFER_TO_WORKERS_ENABLED_CONFIG = "OTEL_AWS_PYTHON_DEFER_TO_WORKERS_ENABLED"
81+
SYSTEM_METRICS_INSTRUMENTATION_SCOPE_NAME = "opentelemetry.instrumentation.system_metrics"
8182
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
8283
# UDP package size is not larger than 64KB
8384
LAMBDA_SPAN_EXPORT_BATCH_SIZE = 10
@@ -347,17 +348,17 @@ def _customize_span_processors(provider: TracerProvider, resource: Resource) ->
347348

348349
def _customize_metric_exporters(metric_readers: List[MetricReader], views: List[View]) -> None:
349350
if _is_application_signals_runtime_enabled():
350-
system_metrics_scope_name = "opentelemetry.instrumentation.system_metrics"
351+
runtime_metrics_scope_name = SYSTEM_METRICS_INSTRUMENTATION_SCOPE_NAME
351352
if 0 == len(metric_readers):
352-
_logger.info("Registered scope %s", system_metrics_scope_name)
353-
views.append(View(meter_name=system_metrics_scope_name, aggregation=DefaultAggregation()))
353+
_logger.info("Registered scope %s", runtime_metrics_scope_name)
354+
views.append(View(meter_name=runtime_metrics_scope_name, aggregation=DefaultAggregation()))
354355
views.append(View(instrument_name="*", aggregation=DropAggregation()))
355356

356-
otel_metric_exporter = ApplicationSignalsExporterProvider().create_exporter()
357+
application_signals_metric_exporter = ApplicationSignalsExporterProvider().create_exporter()
357358
scope_based_periodic_exporting_metric_reader = ScopeBasedPeriodicExportingMetricReader(
358-
exporter=otel_metric_exporter,
359+
exporter=application_signals_metric_exporter,
359360
export_interval_millis=_get_metric_export_interval(),
360-
registered_scope_names={system_metrics_scope_name},
361+
registered_scope_names={runtime_metrics_scope_name},
361362
)
362363
metric_readers.append(scope_based_periodic_exporting_metric_reader)
363364

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
@@ -239,23 +239,26 @@ def test_not_using_xray_sampler_does_not_modify_url_exclusion_env_vars(self):
239239
def test_is_application_signals_enabled(self):
240240
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "True")
241241
self.assertTrue(_is_application_signals_enabled())
242-
self.assertTrue(_is_application_signals_runtime_enabled())
242+
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
243+
244+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "False")
245+
self.assertFalse(_is_application_signals_enabled())
246+
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
247+
self.assertFalse(_is_application_signals_enabled())
243248

249+
def test_is_application_signals_runtime_enabled(self):
250+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "True")
251+
self.assertTrue(_is_application_signals_runtime_enabled())
244252
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", "False")
245-
self.assertTrue(_is_application_signals_enabled())
246253
self.assertFalse(_is_application_signals_runtime_enabled())
247-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
248-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
249254

250255
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "False")
251256
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", "True")
252-
self.assertFalse(_is_application_signals_enabled())
253257
self.assertFalse(_is_application_signals_runtime_enabled())
254258

255259
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
256-
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
260+
os.environ.setdefault("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
257261
self.assertFalse(_is_application_signals_enabled())
258-
self.assertFalse(_is_application_signals_runtime_enabled())
259262

260263
def test_customize_sampler(self):
261264
mock_sampler: Sampler = MagicMock()

0 commit comments

Comments
 (0)