Skip to content

Commit 52ffbd3

Browse files
Remove is_lambda parameter and rename to app signals based dimensions
- Remove is_lambda parameter from BaseEmfExporter and subclasses - Rename _add_lambda_dimensions to _add_service_environment_dimensions - Update CHANGELOG to reflect Application Signals based behavior - Remove is_lambda test since parameter no longer exists 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3cdbfa7 commit 52ffbd3

File tree

6 files changed

+9
-29
lines changed

6 files changed

+9
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ For any change that affects end users of this package, please add an entry under
1111
If your change does not need a CHANGELOG entry, add the "skip changelog" label to your PR.
1212

1313
## Unreleased
14-
- Add Service and Environment dimensions to EMF metrics for Lambda
14+
- Add Service and Environment dimensions to EMF metrics when Application Signals is enabled
1515
([#548](https://github.com/aws-observability/aws-otel-python-instrumentation/pull/548))
1616
- Add Resource and CFN Attributes for Bedrock AgentCore spans
1717
([#495](https://github.com/aws-observability/aws-otel-python-instrumentation/pull/495))

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def _create_emf_exporter():
835835
# pylint: disable=import-outside-toplevel
836836
from amazon.opentelemetry.distro.exporter.aws.metrics.console_emf_exporter import ConsoleEmfExporter
837837

838-
return ConsoleEmfExporter(namespace=log_header_setting.namespace, is_lambda=_is_lambda_environment())
838+
return ConsoleEmfExporter(namespace=log_header_setting.namespace)
839839

840840
# For non-Lambda environment or Lambda with valid headers - use CloudWatch EMF exporter
841841
session = get_aws_session()
@@ -857,7 +857,6 @@ def _create_emf_exporter():
857857
namespace=log_header_setting.namespace,
858858
log_group_name=log_header_setting.log_group,
859859
log_stream_name=log_header_setting.log_stream,
860-
is_lambda=_is_lambda_environment(),
861860
)
862861
# pylint: disable=broad-exception-caught
863862
except Exception as errors:

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/exporter/aws/metrics/aws_cloudwatch_emf_exporter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def __init__(
3434
aws_region: Optional[str] = None,
3535
preferred_temporality: Optional[Dict[type, AggregationTemporality]] = None,
3636
preferred_aggregation: Optional[Dict[type, Any]] = None,
37-
is_lambda: bool = False,
3837
**kwargs,
3938
):
4039
"""
@@ -47,10 +46,9 @@ def __init__(
4746
aws_region: AWS region (auto-detected if None)
4847
preferred_temporality: Optional dictionary mapping instrument types to aggregation temporality
4948
preferred_aggregation: Optional dictionary mapping instrument types to preferred aggregation
50-
is_lambda: Whether the exporter is running in AWS Lambda environment
5149
**kwargs: Additional arguments passed to botocore client
5250
"""
53-
super().__init__(namespace, preferred_temporality, preferred_aggregation, is_lambda=is_lambda)
51+
super().__init__(namespace, preferred_temporality, preferred_aggregation)
5452

5553
self.log_group_name = log_group_name
5654

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/exporter/aws/metrics/base_emf_exporter.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def __init__(
126126
namespace: str = "default",
127127
preferred_temporality: Optional[Dict[type, AggregationTemporality]] = None,
128128
preferred_aggregation: Optional[Dict[type, Any]] = None,
129-
is_lambda: bool = False,
130129
):
131130
"""
132131
Initialize the base EMF exporter.
@@ -135,9 +134,7 @@ def __init__(
135134
namespace: CloudWatch namespace for metrics
136135
preferred_temporality: Optional dictionary mapping instrument types to aggregation temporality
137136
preferred_aggregation: Optional dictionary mapping instrument types to preferred aggregation
138-
is_lambda: Whether the exporter is running in AWS Lambda environment
139137
"""
140-
self._is_lambda = is_lambda
141138
# Set up temporality preference default to DELTA if customers not set
142139
if preferred_temporality is None:
143140
preferred_temporality = {
@@ -192,7 +189,9 @@ def _get_dimension_names(self, attributes: Attributes) -> List[str]:
192189
# For now, use all attributes as dimensions
193190
return list(attributes.keys())
194191

195-
def _add_lambda_dimensions(self, emf_log: Dict, dimension_names: List[str], resource: Resource) -> List[str]:
192+
def _add_service_environment_dimensions(
193+
self, emf_log: Dict, dimension_names: List[str], resource: Resource
194+
) -> List[str]:
196195
"""
197196
Add Service and Environment dimensions when Application Signals is enabled.
198197
@@ -532,8 +531,8 @@ def _create_emf_log(
532531
for name, value in all_attributes.items():
533532
emf_log[name] = str(value)
534533

535-
# Add Service and Environment dimensions for Lambda
536-
dimension_names = self._add_lambda_dimensions(emf_log, dimension_names, resource)
534+
# Add Service and Environment dimensions when Application Signals is enabled
535+
dimension_names = self._add_service_environment_dimensions(emf_log, dimension_names, resource)
537536

538537
# Add CloudWatch Metrics if we have metrics, include dimensions only if they exist
539538
if metric_definitions:

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/exporter/aws/metrics/console_emf_exporter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def __init__(
3030
namespace: str = "default",
3131
preferred_temporality: Optional[Dict[type, AggregationTemporality]] = None,
3232
preferred_aggregation: Optional[Dict[type, Any]] = None,
33-
is_lambda: bool = False,
3433
**kwargs: Any,
3534
) -> None:
3635
"""
@@ -40,13 +39,12 @@ def __init__(
4039
namespace: CloudWatch namespace for metrics (defaults to "default")
4140
preferred_temporality: Optional dictionary mapping instrument types to aggregation temporality
4241
preferred_aggregation: Optional dictionary mapping instrument types to preferred aggregation
43-
is_lambda: Whether the exporter is running in AWS Lambda environment
4442
**kwargs: Additional arguments (unused, kept for compatibility)
4543
"""
4644
# No need to check for None since namespace has a default value
4745
if namespace is None:
4846
namespace = "default"
49-
super().__init__(namespace, preferred_temporality, preferred_aggregation, is_lambda=is_lambda)
47+
super().__init__(namespace, preferred_temporality, preferred_aggregation)
5048

5149
def _export(self, log_event: Dict[str, Any]) -> None:
5250
"""

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/exporter/aws/metrics/test_base_emf_exporter.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,6 @@ def test_export_failure_handling(self):
287287
result = self.exporter.export(metrics_data)
288288
self.assertEqual(result, MetricExportResult.FAILURE)
289289

290-
def test_is_lambda_initialization(self):
291-
"""Test is_lambda parameter initialization."""
292-
# Default should be False
293-
exporter = ConcreteEmfExporter()
294-
self.assertFalse(exporter._is_lambda)
295-
296-
# Explicit False
297-
exporter = ConcreteEmfExporter(is_lambda=False)
298-
self.assertFalse(exporter._is_lambda)
299-
300-
# Explicit True
301-
exporter = ConcreteEmfExporter(is_lambda=True)
302-
self.assertTrue(exporter._is_lambda)
303-
304290
@patch.dict(os.environ, {"OTEL_AWS_APPLICATION_SIGNALS_ENABLED": "true"})
305291
def test_create_emf_log_with_app_signals_dimensions(self):
306292
"""Test EMF log creation includes Service and Environment dimensions when app signals enabled."""

0 commit comments

Comments
 (0)