Skip to content

Commit e387583

Browse files
committed
removed lambda function name/arn attributes and tests
1 parent d8bffd5 commit e387583

File tree

4 files changed

+2
-84
lines changed

4 files changed

+2
-84
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/aws-metric-attribute-generator.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,6 @@ export class AwsMetricAttributeGenerator implements MetricAttributeGenerator {
401401
remoteResourceType = NORMALIZED_STEPFUNCTIONS_SERVICE_NAME + '::Activity';
402402
remoteResourceIdentifier = AwsMetricAttributeGenerator.escapeDelimiters(this.simplifyARNAttribute(activityArn));
403403
cloudFormationIdentifier = AwsMetricAttributeGenerator.escapeDelimiters(activityArn);
404-
} else if (AwsSpanProcessingUtil.isKeyPresent(span, AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME)) {
405-
remoteResourceType = NORMALIZED_LAMBDA_SERVICE_NAME + '::Function';
406-
remoteResourceIdentifier = AwsMetricAttributeGenerator.escapeDelimiters(
407-
span.attributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME]
408-
);
409-
cloudFormationIdentifier = span.attributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN];
410404
} else if (AwsSpanProcessingUtil.isKeyPresent(span, AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_RESOURCE_MAPPING_ID)) {
411405
remoteResourceType = NORMALIZED_LAMBDA_SERVICE_NAME + '::EventSourceMapping';
412406
remoteResourceIdentifier = AwsMetricAttributeGenerator.escapeDelimiters(

aws-distro-opentelemetry-node-autoinstrumentation/test/aws-metric-attribute-generator.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,7 @@ describe('AwsMetricAttributeGeneratorTest', () => {
774774
validateRemoteResourceAttributes('AWS::SecretsManager::Secret', 'testSecret');
775775
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_SECRETSMANAGER_SECRET_ARN, undefined);
776776

777-
// Validate behaviour of AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_FUNCTION_ARN, and AWS_LAMBDA_RESOURCE_MAPPING_ID attributes then remove them.
778-
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME, 'aws_lambda_function_name');
779-
mockAttribute(
780-
AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN,
781-
'arn:aws:lambda:us-east-1:123456789012:function:aws_lambda_function_name'
782-
);
783-
784-
validateRemoteResourceAttributes('AWS::Lambda::Function', 'aws_lambda_function_name');
785-
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME, undefined);
786-
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN, undefined);
787-
777+
// Validate behaviour of AWS_LAMBDA_RESOURCE_MAPPING_ID attribute then remove it.
788778
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_RESOURCE_MAPPING_ID, 'aws_lambda_resource_mapping_id');
789779
validateRemoteResourceAttributes('AWS::Lambda::EventSourceMapping', 'aws_lambda_resource_mapping_id');
790780
mockAttribute(AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_RESOURCE_MAPPING_ID, undefined);

aws-distro-opentelemetry-node-autoinstrumentation/test/patches/aws/services/lamba.test.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,7 @@ describe('Lambda', () => {
3030
},
3131
});
3232
});
33-
34-
describe('GetFunction', () => {
35-
{
36-
it('span has lambda functionName and function ARN in its attributes', async () => {
37-
const funcName = 'testFunction';
38-
const arn = 'arn:aws:lambda:us-east-1:123456789012:function:testFunction';
39-
40-
nock(`https://lambda.${region}.amazonaws.com/`)
41-
.get(/.*/)
42-
.reply(200, {
43-
Configuration: {
44-
FunctionArn: arn,
45-
},
46-
});
47-
48-
await lambda
49-
.getFunction({
50-
FunctionName: funcName,
51-
})
52-
.catch((err: any) => {});
53-
54-
const testSpans: ReadableSpan[] = getTestSpans();
55-
const getFunctionNameSpans: ReadableSpan[] = testSpans.filter((s: ReadableSpan) => {
56-
return s.name === 'Lambda.GetFunction';
57-
});
58-
59-
expect(getFunctionNameSpans.length).toBe(1);
60-
61-
const functionAttributeSpan = getFunctionNameSpans[0];
62-
63-
expect(functionAttributeSpan.attributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME]).toBe(funcName);
64-
expect(functionAttributeSpan.attributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN]).toBe(arn);
65-
expect(functionAttributeSpan.kind).toBe(SpanKind.CLIENT);
66-
});
67-
}
68-
});
69-
33+
7034
describe('GetEventSourceMapping', () => {
7135
it('span has eventSourceMapping attribute in its attributes', async () => {
7236
const uuid = '14e0db71-abcd-4eb5-b481-8945cf9d10c2';

aws-distro-opentelemetry-node-autoinstrumentation/test/patches/instrumentation-patch.test.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import { SinonStub } from 'sinon';
2727
const _STREAM_NAME: string = 'streamName';
2828
const _BUCKET_NAME: string = 'bucketName';
2929
const _QUEUE_NAME: string = 'queueName';
30-
const _FUNCTION_NAME: string = 'testFunction';
31-
const _FUNCTION_ARN: string = `arn:aws:lambda:us-east-1:123456789012:function:${_FUNCTION_NAME}`;
3230
const _ACTIVITY_ARN: string = 'arn:aws:states:us-east-1:007003123456789012:activity:testActivity';
3331
const _STATE_MACHINE_ARN: string = 'arn:aws:states:us-east-1:007003123456789012:stateMachine:testStateMachine';
3432
const _SECRETS_ARN: string = 'arn:aws:secretsmanager:us-east-1:123456789123:secret:testId123456';
@@ -66,7 +64,6 @@ describe('InstrumentationPatchTest', () => {
6664
// From patching but shouldn't be applied
6765
expect(services.get('SNS').requestPreSpanHook).toBeTruthy();
6866
expect(services.get('Lambda').requestPreSpanHook).toBeTruthy();
69-
expect(services.get('Lambda').responseHook).toBeTruthy();
7067
expect(services.get('SecretsManager')).toBeFalsy();
7168
expect(services.get('SFN')).toBeFalsy();
7269
expect(services.has('S3')).toBeFalsy();
@@ -94,7 +91,6 @@ describe('InstrumentationPatchTest', () => {
9491
// From patching
9592
expect(services.get('SNS').requestPreSpanHook).toBeTruthy();
9693
expect(services.get('Lambda').requestPreSpanHook).toBeTruthy();
97-
expect(services.get('Lambda').responseHook).toBeTruthy();
9894
expect(services.has('SecretsManager')).toBeTruthy();
9995
expect(services.has('SFN')).toBeTruthy();
10096
expect(services.has('S3')).toBeTruthy();
@@ -150,8 +146,6 @@ describe('InstrumentationPatchTest', () => {
150146
expect(() => doExtractLambdaAttributes(services)).not.toThrow();
151147

152148
const lambdaAttributes: Attributes = doExtractLambdaAttributes(services);
153-
expect(lambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME]).toBeUndefined();
154-
expect(lambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN]).toBeUndefined();
155149
expect(lambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_RESOURCE_MAPPING_ID]).toBeUndefined();
156150
});
157151

@@ -215,13 +209,7 @@ describe('InstrumentationPatchTest', () => {
215209
const patchedAwsSdkInstrumentation: AwsInstrumentation = extractAwsSdkInstrumentation(PATCHED_INSTRUMENTATIONS);
216210
const services: Map<string, any> = extractServicesFromAwsSdkInstrumentation(patchedAwsSdkInstrumentation);
217211
const requestLambdaAttributes: Attributes = doExtractLambdaAttributes(services);
218-
expect(requestLambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN]).toBeUndefined();
219-
expect(requestLambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_NAME]).toEqual(_FUNCTION_NAME);
220212
expect(requestLambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_RESOURCE_MAPPING_ID]).toEqual(_UUID);
221-
222-
const responseLambdaAttributes = doResponseHookLambda(services);
223-
224-
expect(responseLambdaAttributes[AWS_ATTRIBUTE_KEYS.AWS_LAMBDA_FUNCTION_ARN]).toEqual(_FUNCTION_ARN);
225213
});
226214

227215
it('SFN with patching', () => {
@@ -415,7 +403,6 @@ describe('InstrumentationPatchTest', () => {
415403
serviceName: serviceName,
416404
commandName: 'mockCommandName',
417405
commandInput: {
418-
FunctionName: _FUNCTION_ARN,
419406
UUID: _UUID,
420407
},
421408
};
@@ -479,23 +466,6 @@ describe('InstrumentationPatchTest', () => {
479466
return requestMetadata.spanAttributes || {};
480467
}
481468

482-
function doResponseHookLambda(services: Map<string, ServiceExtension>): Attributes {
483-
const results: Partial<NormalizedResponse> = {
484-
data: {
485-
Configuration: {
486-
FunctionArn: _FUNCTION_ARN,
487-
},
488-
},
489-
request: {
490-
commandInput: {},
491-
commandName: 'dummy_operation',
492-
serviceName: 'Lambda',
493-
},
494-
};
495-
496-
return doResponseHook(services, 'Lambda', results as NormalizedResponse);
497-
}
498-
499469
function doResponseHookSecretsManager(services: Map<string, ServiceExtension>): Attributes {
500470
const results: Partial<NormalizedResponse> = {
501471
data: {

0 commit comments

Comments
 (0)