Skip to content

Commit 21ba7fc

Browse files
authored
Rename aws.ai.agent.type to aws.service.type for agent observability (#415)
*Description of changes:* - Rename `aws.ai.agent.type` to/and set ` aws.service.type` with default value `gen_ai_agent` if no custom set - rename By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent c3e1190 commit 21ba7fc

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
AWS_LAMBDA_FUNCTION_NAME: str = "aws.lambda.function.name"
3434
AWS_LAMBDA_RESOURCEMAPPING_ID: str = "aws.lambda.resource_mapping.id"
3535
AWS_LAMBDA_FUNCTION_ARN: str = "aws.lambda.function.arn"
36-
AWS_AI_AGENT_TYPE: str = "aws.ai.agent.type"
36+
AWS_SERVICE_TYPE: str = "aws.service.type"

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from importlib_metadata import version
1010
from typing_extensions import override
1111

12-
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_AI_AGENT_TYPE, AWS_LOCAL_SERVICE
12+
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_LOCAL_SERVICE, AWS_SERVICE_TYPE
1313
from amazon.opentelemetry.distro._aws_resource_attribute_configurator import get_service_attribute
1414
from amazon.opentelemetry.distro._utils import is_agent_observability_enabled, is_installed
1515
from amazon.opentelemetry.distro.always_record_sampler import AlwaysRecordSampler
@@ -558,10 +558,10 @@ def _customize_resource(resource: Resource) -> Resource:
558558
custom_attributes = {AWS_LOCAL_SERVICE: service_name}
559559

560560
if is_agent_observability_enabled():
561-
# Add aws.ai.agent.type if it doesn't exist in the resource
562-
if resource and resource.attributes.get(AWS_AI_AGENT_TYPE) is None:
561+
# Add aws.service.type if it doesn't exist in the resource
562+
if resource and resource.attributes.get(AWS_SERVICE_TYPE) is None:
563563
# Set a default agent type for AI agent observability
564-
custom_attributes[AWS_AI_AGENT_TYPE] = "default"
564+
custom_attributes[AWS_SERVICE_TYPE] = "gen_ai_agent"
565565

566566
return resource.merge(Resource.create(custom_attributes))
567567

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from requests import Session
1212

13-
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_AI_AGENT_TYPE, AWS_LOCAL_SERVICE
13+
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_LOCAL_SERVICE, AWS_SERVICE_TYPE
1414
from amazon.opentelemetry.distro.always_record_sampler import AlwaysRecordSampler
1515
from amazon.opentelemetry.distro.attribute_propagating_span_processor import AttributePropagatingSpanProcessor
1616
from amazon.opentelemetry.distro.aws_batch_unsampled_span_processor import BatchUnsampledSpanProcessor
@@ -1106,7 +1106,7 @@ def test_customize_resource_without_agent_observability(self, mock_get_service_a
11061106

11071107
# Should only have AWS_LOCAL_SERVICE added
11081108
self.assertEqual(result.attributes[AWS_LOCAL_SERVICE], "test-service")
1109-
self.assertNotIn(AWS_AI_AGENT_TYPE, result.attributes)
1109+
self.assertNotIn(AWS_SERVICE_TYPE, result.attributes)
11101110

11111111
@patch("amazon.opentelemetry.distro.aws_opentelemetry_configurator.is_agent_observability_enabled")
11121112
@patch("amazon.opentelemetry.distro.aws_opentelemetry_configurator.get_service_attribute")
@@ -1120,9 +1120,9 @@ def test_customize_resource_with_agent_observability_default(
11201120
resource = Resource.create({ResourceAttributes.SERVICE_NAME: "test-service"})
11211121
result = _customize_resource(resource)
11221122

1123-
# Should have both AWS_LOCAL_SERVICE and AWS_AI_AGENT_TYPE with default value
1123+
# Should have both AWS_LOCAL_SERVICE and AWS_SERVICE_TYPE with default value
11241124
self.assertEqual(result.attributes[AWS_LOCAL_SERVICE], "test-service")
1125-
self.assertEqual(result.attributes[AWS_AI_AGENT_TYPE], "default")
1125+
self.assertEqual(result.attributes[AWS_SERVICE_TYPE], "gen_ai_agent")
11261126

11271127
@patch("amazon.opentelemetry.distro.aws_opentelemetry_configurator.is_agent_observability_enabled")
11281128
@patch("amazon.opentelemetry.distro.aws_opentelemetry_configurator.get_service_attribute")
@@ -1133,13 +1133,13 @@ def test_customize_resource_with_existing_agent_type(self, mock_get_service_attr
11331133

11341134
# Create resource with existing agent type
11351135
resource = Resource.create(
1136-
{ResourceAttributes.SERVICE_NAME: "test-service", AWS_AI_AGENT_TYPE: "existing-agent"}
1136+
{ResourceAttributes.SERVICE_NAME: "test-service", AWS_SERVICE_TYPE: "existing-agent"}
11371137
)
11381138
result = _customize_resource(resource)
11391139

11401140
# Should preserve existing agent type and not override it
11411141
self.assertEqual(result.attributes[AWS_LOCAL_SERVICE], "test-service")
1142-
self.assertEqual(result.attributes[AWS_AI_AGENT_TYPE], "existing-agent")
1142+
self.assertEqual(result.attributes[AWS_SERVICE_TYPE], "existing-agent")
11431143

11441144

11451145
def validate_distro_environ():

0 commit comments

Comments
 (0)