Skip to content

Commit

Permalink
fix: createSpanMetadata function
Browse files Browse the repository at this point in the history
  • Loading branch information
RonitKissis committed Aug 22, 2024
1 parent 1f73b03 commit 5a8c27c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,19 @@ export const generateGeoIdentifier = (geo: FeatureCollection): string => {
export function createSpanMetadata(
functionName?: string,
spanKind?: SpanKind,
parentContext?: { traceId: string; spanId: string }
context?: { traceId: string; spanId: string }
): { traceContext: SpanContext | undefined; spanOptions: SpanOptions | undefined } {
if (!parentContext) {
return { spanOptions: undefined, traceContext: undefined };
}
const traceContext: SpanContext = {
...parentContext,
traceFlags: FLAG_SAMPLED,
};
const traceContext = context ? { ...context, traceFlags: FLAG_SAMPLED } : undefined;

const spanOptions: SpanOptions = {
kind: spanKind,
links: [
{
context: traceContext,
},
],
...(traceContext && { links: [{ context: traceContext }] }),
attributes: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'code.function': functionName,
},
};

return { traceContext, spanOptions };
}

Expand Down

0 comments on commit 5a8c27c

Please sign in to comment.