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

Commit

Permalink
feat(span): make tracer available on span
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jul 13, 2019
1 parent 5b8165e commit b2b19b9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { NoRecordSpan } from './no-record-span';

/** Implementation for the Span class that does not record trace events. */
export class NoRecordRootSpan extends NoRecordSpan {
/** A tracer object */
private tracer: types.TracerBase;
/** Its trace ID. */
private traceIdLocal: string;
/** Its trace state. */
Expand All @@ -31,6 +29,8 @@ export class NoRecordRootSpan extends NoRecordSpan {
* parent was likely started on another machine.
*/
private parentSpanIdLocal: string;
/** A tracer object */
tracer: types.TracerBase;

/**
* Constructs a new NoRecordRootSpanImpl instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class NoRecordSpan implements types.Span {
private endedLocal = false;
/** The Span ID of this span */
readonly id: string;
/** A tracer object */
tracer: types.TracerBase;
/** An object to log information to */
logger: Logger = noopLogger;
/** A set of attributes, each in the format [KEY]:[VALUE] */
Expand Down Expand Up @@ -66,7 +68,8 @@ export class NoRecordSpan implements types.Span {
droppedMessageEventsCount = 0;

/** Constructs a new SpanBaseModel instance. */
constructor(parent?: NoRecordSpan) {
constructor(tracer: types.TracerBase, parent?: NoRecordSpan) {
this.tracer = tracer;
this.id = randomSpanId();
if (parent) {
this.root = parent.root;
Expand Down
3 changes: 3 additions & 0 deletions packages/opencensus-core/src/trace/model/root-span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class RootSpan extends Span {
* parent was likely started on another machine.
*/
private parentSpanIdLocal: string;
/** A tracer object */
tracer: types.TracerBase;

/**
* Constructs a new RootSpanImpl instance.
Expand All @@ -49,6 +51,7 @@ export class RootSpan extends Span {
traceState?: types.TraceState
) {
super(tracer);
this.tracer = tracer;
this.traceIdLocal = traceId;
this.name = name;
this.kind = kind;
Expand Down
4 changes: 2 additions & 2 deletions packages/opencensus-core/src/trace/model/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const STATUS_OK = {
/** Defines a base model for spans. */
export class Span implements types.Span {
protected className: string;
/** A tracer object */
private tracer: types.TracerBase;
/** The clock used to mesure the beginning and ending of a span */
private clock!: Clock;
/** Indicates if this span was started */
Expand All @@ -41,6 +39,8 @@ export class Span implements types.Span {
private spansLocal: types.Span[];
/** The Span ID of this span */
readonly id: string;
/** A tracer object */
tracer: types.TracerBase;
/** An object to log information to */
logger: Logger = noopLogger;
/** A set of attributes, each in the format [KEY]:[VALUE] */
Expand Down
5 changes: 5 additions & 0 deletions packages/opencensus-core/src/trace/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ export interface Span {
/** The Span ID of this span */
readonly id: string;

/** A tracer object, exposong the tracer makes it possible to create child
* spans from the span instance like. span.tracer.startChildSpan()
*/
tracer: TracerBase;

/** If the parent span is in another process. */
remoteParent: boolean;

Expand Down

0 comments on commit b2b19b9

Please sign in to comment.