Socket
Socket
Sign inDemoInstall

@opencensus/core

Package Overview
Dependencies
7
Maintainers
7
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.15 to 0.0.16

6

build/src/internal/clock.d.ts

@@ -28,6 +28,8 @@ /**

private diff;
/** Constructs a new SamplerImpl instance. */
constructor();
/** Constructs a new Clock instance. */
constructor(startTime?: Date);
/** Ends the clock. */
end(): void;
/** Gets the current date from ellapsed milliseconds and start time. */
readonly currentDate: Date;
/** Gets the duration of the clock. */

@@ -34,0 +36,0 @@ readonly duration: number;

@@ -22,4 +22,4 @@ "use strict";

class Clock {
/** Constructs a new SamplerImpl instance. */
constructor() {
/** Constructs a new Clock instance. */
constructor(startTime) {
/** Indicates if the clock is endend. */

@@ -29,3 +29,5 @@ this.endedLocal = false;

this.diff = [0, 0];
this.startTimeLocal = new Date();
// In some cases clocks need to be relative to other resources, passing a
// startTime makes it possible.
this.startTimeLocal = startTime || new Date();
this.hrtimeLocal = process.hrtime();

@@ -41,2 +43,9 @@ }

}
/** Gets the current date from ellapsed milliseconds and start time. */
get currentDate() {
const diff = process.hrtime(this.hrtimeLocal);
const ns = diff[0] * 1e9 + diff[1];
const ellapsed = ns / 1e6;
return new Date(this.startTime.getTime() + ellapsed);
}
/** Gets the duration of the clock. */

@@ -43,0 +52,0 @@ get duration() {

@@ -20,4 +20,2 @@ /**

export declare class NoRecordRootSpan extends NoRecordSpan {
/** A tracer object */
private tracer;
/** Its trace ID. */

@@ -32,2 +30,4 @@ private traceIdLocal;

private parentSpanIdLocal;
/** A tracer object */
readonly tracer: types.TracerBase;
/**

@@ -34,0 +34,0 @@ * Constructs a new NoRecordRootSpanImpl instance.

@@ -33,3 +33,3 @@ "use strict";

constructor(tracer, name, kind, traceId, parentSpanId, traceState) {
super();
super(tracer);
this.tracer = tracer;

@@ -36,0 +36,0 @@ this.traceIdLocal = traceId;

@@ -12,2 +12,4 @@ import { Logger } from '../../../common/types';

readonly id: string;
/** A tracer object */
readonly tracer: types.TracerBase;
/** An object to log information to */

@@ -46,3 +48,3 @@ logger: Logger;

/** Constructs a new SpanBaseModel instance. */
constructor(parent?: NoRecordSpan);
constructor(tracer: types.TracerBase, parent?: NoRecordSpan);
/** Returns whether a span is root or not. */

@@ -49,0 +51,0 @@ isRootSpan(): boolean;

@@ -27,3 +27,3 @@ "use strict";

/** Constructs a new SpanBaseModel instance. */
constructor(parent) {
constructor(tracer, parent) {
/** Indicates if this span was started */

@@ -61,2 +61,3 @@ this.startedLocal = false;

this.droppedMessageEventsCount = 0;
this.tracer = tracer;
this.id = util_1.randomSpanId();

@@ -158,3 +159,3 @@ if (parent) {

startChildSpan(options) {
const noRecordChild = new NoRecordSpan(this);
const noRecordChild = new NoRecordSpan(this.tracer, this);
if (options && options.name)

@@ -161,0 +162,0 @@ noRecordChild.name = options.name;

@@ -29,2 +29,4 @@ /**

private parentSpanIdLocal;
/** A tracer object */
readonly tracer: types.TracerBase;
/**

@@ -31,0 +33,0 @@ * Constructs a new RootSpanImpl instance.

@@ -34,2 +34,3 @@ "use strict";

super(tracer);
this.tracer = tracer;
this.traceIdLocal = traceId;

@@ -36,0 +37,0 @@ this.name = name;

@@ -7,4 +7,2 @@ import { Logger } from '../../common/types';

protected className: string;
/** A tracer object */
private tracer;
/** The clock used to mesure the beginning and ending of a span */

@@ -20,2 +18,4 @@ private clock;

readonly id: string;
/** A tracer object */
readonly tracer: types.TracerBase;
/** An object to log information to */

@@ -22,0 +22,0 @@ logger: Logger;

@@ -250,3 +250,9 @@ "use strict";

}
this.clock = new clock_1.Clock();
// start child span's clock from root's current time to preserve integrity.
if (this.parentSpan) {
this.clock = new clock_1.Clock(this.parentSpan.clock.currentDate);
}
else {
this.clock = new clock_1.Clock();
}
this.startedLocal = true;

@@ -301,7 +307,7 @@ this.logger.debug('starting %s %o', this.className, {

this.logger.debug('calling %s.startSpan() on ended %s %o', this.className, this.className, { id: this.id, name: this.name, kind: this.kind });
return new no_record_span_1.NoRecordSpan();
return new no_record_span_1.NoRecordSpan(this.tracer);
}
if (!this.started) {
this.logger.debug('calling %s.startSpan() on un-started %s %o', this.className, this.className, { id: this.id, name: this.name, kind: this.kind });
return new no_record_span_1.NoRecordSpan();
return new no_record_span_1.NoRecordSpan(this.tracer);
}

@@ -308,0 +314,0 @@ const child = new Span(this.tracer, this);

@@ -174,3 +174,3 @@ "use strict";

this.logger.debug('no current trace found - must start a new root span first');
return new no_record_span_1.NoRecordSpan();
return new no_record_span_1.NoRecordSpan(this);
}

@@ -177,0 +177,0 @@ const span = options.childOf.startChildSpan(options);

@@ -98,3 +98,3 @@ "use strict";

}
return super.startChildSpan(Object.assign({ childOf: this.currentRootSpan || new no_record_span_1.NoRecordSpan() }, options));
return super.startChildSpan(Object.assign({ childOf: this.currentRootSpan || new no_record_span_1.NoRecordSpan(this) }, options));
}

@@ -101,0 +101,0 @@ /**

@@ -300,2 +300,6 @@ /**

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. */

@@ -302,0 +306,0 @@ remoteParent: boolean;

{
"name": "@opencensus/core",
"version": "0.0.15",
"version": "0.0.16",
"description": "OpenCensus is a toolkit for collecting application performance and behavior data.",

@@ -5,0 +5,0 @@ "main": "build/src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc