Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 618b9d6

Browse files
committed
doc: update tracer jsdoc for wrap and wraEmitter
1 parent 20fef5c commit 618b9d6

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

packages/opencensus-core/src/trace/model/tracer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ export class Tracer implements types.Tracer {
169169
}
170170

171171
/**
172-
* Wraps a function.
173-
* @param fn Function to wrap.
172+
* Binds the trace context to the given function.
173+
* This is necessary in order to create child spans correctly in functions
174+
* that are called asynchronously (for example, in a network response
175+
* handler).
176+
* @param fn A function to which to bind the trace context.
174177
*/
175178
wrap<T>(fn: types.Func<T>): types.Func<T> {
176179
if (!this.active) {
@@ -183,8 +186,11 @@ export class Tracer implements types.Tracer {
183186
}
184187

185188
/**
186-
* The wrap emitter.
187-
* @param emitter The emitter.
189+
* Binds the trace context to the given event emitter.
190+
* This is necessary in order to create child spans correctly in event
191+
* handlers.
192+
* @param emitter An event emitter whose handlers should have
193+
* the trace context binded to them.
188194
*/
189195
wrapEmitter(emitter: NodeJS.EventEmitter): void {
190196
if (!this.active) {

packages/opencensus-core/src/trace/model/types.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,23 @@ export interface Tracer extends OnEndSpanEventListener {
266266
startSpan(name?: string, type?: string, parentSpanId?: string): Span;
267267

268268
/**
269-
* Wraper to contextManager
270-
* @param fn Function that will wrap in contextManager
271-
* @returns The contextManager class wrapped
269+
* Binds the trace context to the given function.
270+
* This is necessary in order to create child spans correctly in functions
271+
* that are called asynchronously (for example, in a network response
272+
* handler).
273+
* @param fn A function to which to bind the trace context.
272274
*/
273275
wrap<T>(fn: Func<T>): Func<T>;
274276

275277
/**
276-
* Wrapper to contextManager emitter
277-
* @param emitter Function that will wrap in contextManager emitter
278-
* @returns The contextManager emitter wrapped
278+
* Binds the trace context to the given event emitter.
279+
* This is necessary in order to create child spans correctly in event
280+
* handlers.
281+
* @param emitter An event emitter whose handlers should have
282+
* the trace context binded to them.
279283
*/
280284
wrapEmitter(emitter: NodeJS.EventEmitter): void;
281-
}
285+
}
286+
287+
288+

0 commit comments

Comments
 (0)