1515 */
1616
1717import * as loggerTypes from '../../common/types' ;
18- import { NodeJsEventEmitter } from '../../node/types' ;
1918import * as configTypes from '../config/types' ;
2019import { Propagation } from '../propagation/types' ;
2120import * as samplerTypes from '../sampler/types' ;
21+ import { NodeJsEventEmitter } from '../../node/types' ;
2222
2323/** Default type for functions */
2424// tslint:disable:no-any
@@ -191,7 +191,13 @@ export interface MessageEvent {
191191 timestamp : number ;
192192 /** Indicates whether the message was sent or received. */
193193 type : MessageEventType ;
194- /** An identifier for the MessageEvent's message. */
194+ /**
195+ * An identifier for the MessageEvent's message. This should be a hexadecimal
196+ * value that fits within 64-bits. Message event ids should start with 1 for
197+ * both sent and received messages and increment by 1 for each message
198+ * sent/received. See:
199+ * https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/gRPC.md#message-events
200+ */
195201 id : string ;
196202 /** The number of uncompressed bytes sent or received. */
197203 uncompressedSize ?: number ;
@@ -225,6 +231,18 @@ export interface TraceOptions {
225231 spanContext ?: SpanContext ;
226232 /** Span kind */
227233 kind ?: SpanKind ;
234+ /** Determines the sampling rate. Ranges from 0.0 to 1.0 */
235+ samplingRate ?: number ;
236+ }
237+
238+ /** Defines the span options */
239+ export interface SpanOptions {
240+ /** Span name */
241+ name : string ;
242+ /** Span kind */
243+ kind ?: SpanKind ;
244+ /** Span parent ID */
245+ parentSpanId ?: string ;
228246}
229247
230248export type TraceState = string ;
@@ -417,8 +435,17 @@ export interface Span {
417435 * @param type The type of message event.
418436 * @param id An identifier for the message event.
419437 * @param timestamp A timestamp for this event.
420- */
421- addMessageEvent ( type : MessageEventType , id : string , timestamp ?: number ) : void ;
438+ * @param uncompressedSize The number of uncompressed bytes sent or received.
439+ * @param compressedSize The number of compressed bytes sent or received. If
440+ * zero or undefined, assumed to be the same size as uncompressed.
441+ */
442+ addMessageEvent (
443+ type : MessageEventType ,
444+ id : string ,
445+ timestamp ?: number ,
446+ uncompressedSize ?: number ,
447+ compressedSize ?: number
448+ ) : void ;
422449
423450 /**
424451 * Sets a status to the span.
@@ -442,8 +469,13 @@ export interface RootSpan extends Span {
442469 /** Get the span list from RootSpan instance */
443470 readonly spans : Span [ ] ;
444471
472+ /** Gets the number of child span created for this span. */
473+ readonly numberOfChildren : number ;
474+
445475 /** Starts a new Span instance in the RootSpan instance */
446- startChildSpan ( name : string , kind : SpanKind ) : Span ;
476+ startChildSpan ( name ?: string , kind ?: SpanKind ) : Span ;
477+ startChildSpan ( options ?: SpanOptions ) : Span ;
478+ startChildSpan ( nameOrOptions ?: string | SpanOptions , kind ?: SpanKind ) : Span ;
447479}
448480
449481/** Interface for Tracer */
@@ -505,11 +537,12 @@ export interface Tracer extends SpanEventListener {
505537 /**
506538 * Start a new Span instance to the currentRootSpan
507539 * @param name Span name
508- * @param type Span type
509- * @param parentSpanId Parent SpanId
540+ * @param kind Span kind
541+ * @param options Span Options
510542 * @returns The new Span instance started
511543 */
512- startChildSpan ( name ?: string , type ?: SpanKind , parentSpanId ?: string ) : Span ;
544+ startChildSpan ( name ?: string , kind ?: SpanKind ) : Span ;
545+ startChildSpan ( options ?: SpanOptions ) : Span ;
513546
514547 /**
515548 * Binds the trace context to the given function.
0 commit comments