Skip to content

Commit

Permalink
adding hook for adding span links to a lambda instrumentation span
Browse files Browse the repository at this point in the history
  • Loading branch information
peterabbott committed Feb 2, 2024
1 parent 84e1a6b commit b5b2d65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export class AwsLambdaInstrumentation extends InstrumentationBase {
context.invokedFunctionArn
),
},
links: config.eventSpanLinksExtractor
? config.eventSpanLinksExtractor(event, context)
: [],
},
parent
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Span, Context as OtelContext } from '@opentelemetry/api';
import { Span, Context as OtelContext, Link } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import type { Context } from 'aws-lambda';

Expand All @@ -31,6 +31,8 @@ export type ResponseHook = (
}
) => void;

export type EventSpanLinksExtractor = (event: any, context: Context) => Link[];

export type EventContextExtractor = (
event: any,
context: Context
Expand All @@ -40,5 +42,7 @@ export interface AwsLambdaInstrumentationConfig extends InstrumentationConfig {
responseHook?: ResponseHook;
disableAwsContextPropagation?: boolean;
eventContextExtractor?: EventContextExtractor;
/** for batch processing, link a span to multiple spans instead of just single propagated context */
eventSpanLinksExtractor?: EventSpanLinksExtractor;
lambdaHandler?: string;
}

0 comments on commit b5b2d65

Please sign in to comment.