Skip to content

Commit

Permalink
Merge branch 'aws-observability:main' into gen-ai-support
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyuan-he authored Oct 29, 2024
2 parents 3aa360d + b6d2752 commit 2061da2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/application-signals-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,32 @@ jobs:
aws-region: us-east-1
staging-instrumentation-name: ${{ inputs.staging-instrumentation-name }}
caller-workflow-name: 'main-build'


ec2-different-node-version:
strategy:
fail-fast: false
matrix:
node-version: [ '14', '16', '18', '20', '22' ]
needs: [ upload-main-build ]
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/node-ec2-default-test.yml@main
secrets: inherit
with:
aws-region: 'us-east-1'
staging-instrumentation-name: ${{ inputs.staging-instrumentation-name }}
node-version: ${{ matrix.node-version }}
cpu-architecture: 'x86_64'
caller-workflow-name: 'main-build'

ec2-arm64-cpu-architecture:
needs: [ upload-main-build ]
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/node-ec2-default-test.yml@main
secrets: inherit
with:
aws-region: 'us-east-1'
staging-instrumentation-name: ${{ inputs.staging-instrumentation-name }}
cpu-architecture: 'arm64'
caller-workflow-name: 'main-build'

eks:
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/node-eks-test.yml@main
secrets: inherit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
InstrumentationNodeModuleFile,
isWrapped,
} from '@opentelemetry/instrumentation';
import { diag } from '@opentelemetry/api';
import { diag, Span, SpanStatusCode } from '@opentelemetry/api';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
export class AwsLambdaInstrumentationPatch extends AwsLambdaInstrumentation {
override init() {
// Custom logic before calling the original implementation
Expand Down Expand Up @@ -117,4 +119,38 @@ export class AwsLambdaInstrumentationPatch extends AwsLambdaInstrumentation {
];
}
}

// Override the upstream private _endSpan method to remove the unnecessary metric force-flush error message
// https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts#L358-L398
override _endSpan(span: Span, err: string | Error | null | undefined, callback: () => void) {
if (err) {
span.recordException(err);
}

let errMessage;
if (typeof err === 'string') {
errMessage = err;
} else if (err) {
errMessage = err.message;
}
if (errMessage) {
span.setStatus({
code: SpanStatusCode.ERROR,
message: errMessage,
});
}

span.end();

const flushers = [];
if ((this as any)._traceForceFlusher) {
flushers.push((this as any)._traceForceFlusher());
} else {
diag.error(
'Spans may not be exported for the lambda function because we are not force flushing before callback.'
);
}

Promise.all(flushers).then(callback, callback);
}
}

0 comments on commit 2061da2

Please sign in to comment.