-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [.NET and JS Feature Parity] Support for new AWS Resources in J…
…S SDK (#121) *Description of changes:* Adding support for new AWS resources in JS SDK. Part of an ongoing project to increase the ADOT SDK support in Node and .NET. Changes in this PR support the exact same features as the Python version: aws-observability/aws-otel-python-instrumentation#265 Manual Testing: <img width="1236" alt="Screenshot 2024-11-15 at 1 36 01 PM" src="https://github.com/user-attachments/assets/7480f865-2927-4376-91b5-76048b0bcdf4"> <img width="1234" alt="Screenshot 2024-11-15 at 2 07 05 PM" src="https://github.com/user-attachments/assets/1a5d00b4-9ac8-45e9-b51d-02d7c669f5f1"> <img width="939" alt="Screenshot 2024-11-15 at 2 26 10 PM" src="https://github.com/user-attachments/assets/120892ec-03cf-4b70-80c7-167369cd9e27"> <img width="996" alt="Screenshot 2024-11-18 at 9 47 33 AM" src="https://github.com/user-attachments/assets/08019f4c-507c-46cf-baa0-db77a4175d02"> <img width="934" alt="Screenshot 2024-11-18 at 9 57 22 AM" src="https://github.com/user-attachments/assets/3fb79fa9-689f-4361-b671-79e23c68193d"> <img width="852" alt="Screenshot 2024-11-18 at 10 00 34 AM" src="https://github.com/user-attachments/assets/bde63f88-cdbc-43c9-aa16-068790556ebe"> Unit Tests for Instrumentation Patches and Metric Attribute Generators: <img width="1070" alt="image" src="https://github.com/user-attachments/assets/df01814c-49fb-4561-879b-c88cedb35e5c"> By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
- Loading branch information
Showing
14 changed files
with
1,641 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
aws-distro-opentelemetry-node-autoinstrumentation/src/patches/aws/services/secretsmanager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Attributes, Span, SpanKind, Tracer } from '@opentelemetry/api'; | ||
import { | ||
AwsSdkInstrumentationConfig, | ||
NormalizedRequest, | ||
NormalizedResponse, | ||
} from '@opentelemetry/instrumentation-aws-sdk'; | ||
import { AWS_ATTRIBUTE_KEYS } from '../../../aws-attribute-keys'; | ||
import { RequestMetadata, ServiceExtension } from '../../../third-party/otel/aws/services/ServiceExtension'; | ||
|
||
export class SecretsManagerServiceExtension implements ServiceExtension { | ||
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata { | ||
const secretId = request.commandInput?.SecretId; | ||
|
||
const spanKind: SpanKind = SpanKind.CLIENT; | ||
let spanName: string | undefined; | ||
|
||
const spanAttributes: Attributes = {}; | ||
|
||
if (typeof secretId === 'string' && secretId.startsWith('arn:aws:secretsmanager:')) { | ||
spanAttributes[AWS_ATTRIBUTE_KEYS.AWS_SECRETSMANAGER_SECRET_ARN] = secretId; | ||
} | ||
|
||
const isIncoming = false; | ||
|
||
return { | ||
isIncoming, | ||
spanAttributes, | ||
spanKind, | ||
spanName, | ||
}; | ||
} | ||
|
||
responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void { | ||
const secretArn = response.data.ARN; | ||
|
||
if (secretArn) { | ||
span.setAttribute(AWS_ATTRIBUTE_KEYS.AWS_SECRETSMANAGER_SECRET_ARN, secretArn); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
aws-distro-opentelemetry-node-autoinstrumentation/src/patches/aws/services/step-functions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Attributes, SpanKind } from '@opentelemetry/api'; | ||
import { AwsSdkInstrumentationConfig, NormalizedRequest } from '@opentelemetry/instrumentation-aws-sdk'; | ||
import { AWS_ATTRIBUTE_KEYS } from '../../../aws-attribute-keys'; | ||
import { RequestMetadata, ServiceExtension } from '../../../third-party/otel/aws/services/ServiceExtension'; | ||
|
||
export class StepFunctionsServiceExtension implements ServiceExtension { | ||
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata { | ||
const stateMachineArn = request.commandInput?.stateMachineArn; | ||
const activityArn = request.commandInput?.activityArn; | ||
|
||
const spanKind: SpanKind = SpanKind.CLIENT; | ||
let spanName: string | undefined; | ||
|
||
const spanAttributes: Attributes = {}; | ||
|
||
if (stateMachineArn) { | ||
spanAttributes[AWS_ATTRIBUTE_KEYS.AWS_STEPFUNCTIONS_STATEMACHINE_ARN] = stateMachineArn; | ||
} | ||
|
||
if (activityArn) { | ||
spanAttributes[AWS_ATTRIBUTE_KEYS.AWS_STEPFUNCTIONS_ACTIVITY_ARN] = activityArn; | ||
} | ||
|
||
const isIncoming = false; | ||
|
||
return { | ||
isIncoming, | ||
spanAttributes, | ||
spanKind, | ||
spanName, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.