Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 2775dd7

Browse files
author
naseemkullah
committed
feat: add tracer.startActiveSpan()
Signed-off-by: naseemkullah <[email protected]>
1 parent e938882 commit 2775dd7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/trace/tracer.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,25 @@ export interface Tracer {
3737
* span.end();
3838
*/
3939
startSpan(name: string, options?: SpanOptions, context?: Context): Span;
40+
41+
/**
42+
* Starts a new {@link Span} and activates it in the current Context.
43+
*
44+
* @param name The name of the span
45+
* @param [options] SpanOptions used for span creation
46+
* @param [context] Context to use to extract parent
47+
* @param callback called in the context of the span and receives the newly created span as an argument
48+
* @returns what is returned by the callback
49+
* @example
50+
* const span = tracer.startActiveSpan('op', {}, undefined, (err, span) => {
51+
* span.setAttribute('key', 'value');
52+
* span.end();
53+
* });
54+
*/
55+
startActiveSpan<F extends (err: Error, span: Span) => ReturnType<F>>(
56+
name: string,
57+
options?: SpanOptions,
58+
context?: Context,
59+
callback?: F
60+
): ReturnType<F>;
4061
}

0 commit comments

Comments
 (0)