@@ -44,6 +44,8 @@ import { AwsXraySamplingClient } from '../src/sampler/aws-xray-sampling-client';
4444import { GetSamplingRulesResponse } from '../src/sampler/remote-sampler.types' ;
4545import { OTLPAwsSpanExporter } from '../src/otlp-aws-span-exporter' ;
4646import { BaggageSpanProcessor } from '@opentelemetry/baggage-span-processor' ;
47+ import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions' ;
48+ import { AWS_ATTRIBUTE_KEYS } from '../src/aws-attribute-keys' ;
4749
4850// Tests AwsOpenTelemetryConfigurator after running Environment Variable setup in register.ts
4951describe ( 'AwsOpenTelemetryConfiguratorTest' , ( ) => {
@@ -818,4 +820,38 @@ describe('AwsOpenTelemetryConfiguratorTest', () => {
818820 delete process . env . AGENT_OBSERVABILITY_ENABLED ;
819821 }
820822 } ) ;
823+
824+ it ( 'CustomizeResourceWithoutAgentObservability' , ( ) => {
825+ delete process . env . AGENT_OBSERVABILITY_ENABLED ;
826+
827+ let resource = new Resource ( { [ ATTR_SERVICE_NAME ] : 'test-service' } ) ;
828+ resource = awsOtelConfigurator [ 'customizeResource' ] ( resource ) ;
829+ expect ( resource . attributes [ ATTR_SERVICE_NAME ] ) . toEqual ( 'test-service' ) ;
830+ expect ( resource . attributes ) . not . toHaveProperty ( AWS_ATTRIBUTE_KEYS . AWS_SERVICE_TYPE ) ;
831+ } ) ;
832+
833+ it ( 'CustomizeResourceWithAgentObservabilityDefault' , ( ) => {
834+ process . env . AGENT_OBSERVABILITY_ENABLED = 'true' ;
835+
836+ let resource = new Resource ( { [ ATTR_SERVICE_NAME ] : 'test-service' } ) ;
837+ resource = awsOtelConfigurator [ 'customizeResource' ] ( resource ) ;
838+ expect ( resource . attributes [ ATTR_SERVICE_NAME ] ) . toEqual ( 'test-service' ) ;
839+ expect ( resource . attributes [ AWS_ATTRIBUTE_KEYS . AWS_SERVICE_TYPE ] ) . toEqual ( 'gen_ai_agent' ) ;
840+
841+ delete process . env . AGENT_OBSERVABILITY_ENABLED ;
842+ } ) ;
843+
844+ it ( 'CustomizeResourceWithoutAgentObservability' , ( ) => {
845+ process . env . AGENT_OBSERVABILITY_ENABLED = 'true' ;
846+
847+ let resource = new Resource ( {
848+ [ ATTR_SERVICE_NAME ] : 'test-service' ,
849+ [ AWS_ATTRIBUTE_KEYS . AWS_SERVICE_TYPE ] : 'existing-agent' ,
850+ } ) ;
851+ resource = awsOtelConfigurator [ 'customizeResource' ] ( resource ) ;
852+ expect ( resource . attributes [ ATTR_SERVICE_NAME ] ) . toEqual ( 'test-service' ) ;
853+ expect ( resource . attributes [ AWS_ATTRIBUTE_KEYS . AWS_SERVICE_TYPE ] ) . toEqual ( 'existing-agent' ) ;
854+
855+ delete process . env . AGENT_OBSERVABILITY_ENABLED ;
856+ } ) ;
821857} ) ;
0 commit comments