Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding hook for adding span links to a lambda instrumentation span #1922

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat related to the question I have asked over in the main repo about links.

There might be another way, but this allows adding links when dealing with batch processing

? 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;
}
Loading