Skip to content

Commit

Permalink
feat(tracing): context binding util (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
galta95 committed Jul 14, 2021
1 parent 47e9a9a commit 9725ed7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tracing/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { Tracing } from './tracing';
export { getTraceContexHeaderMiddleware } from './middleware/traceOnHeaderMiddleware';
export { contexBindingHelper } from './utils/tracing';
export { logMethod } from './loggerHook';
6 changes: 6 additions & 0 deletions src/tracing/utils/tracing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import api, { Span } from '@opentelemetry/api';

export const contexBindingHelper = <T>(parentSpan: Span, func: T): T => {
const ctx = api.trace.setSpan(api.context.active(), parentSpan);
return api.context.bind(ctx, func);
};

0 comments on commit 9725ed7

Please sign in to comment.