Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/tracing

Package Overview
Dependencies
Maintainers
4
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/tracing - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

4

build/src/BasicTracer.js

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

const spanContext = { traceId, spanId, traceFlags, traceState };
const recordEvents = options.isRecordingEvents || false;
const recordEvents = options.isRecording || false;
if (!recordEvents && !samplingDecision) {

@@ -75,3 +75,3 @@ this.logger.debug('Sampling is off, starting no recording span');

}
const span = new Span_1.Span(this, name, spanContext, options.kind || types.SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.startTime);
const span = new Span_1.Span(this, name, spanContext, options.kind || types.SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.links || [], options.startTime);
// Set default attributes

@@ -78,0 +78,0 @@ span.setAttributes(Object.assign({}, this._defaultAttributes, options.attributes));

@@ -24,4 +24,23 @@ /*!

export declare class ConsoleSpanExporter implements SpanExporter {
/**
* Export spans.
* @param spans
* @param resultCallback
*/
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
/**
* Shutdown the exporter.
*/
shutdown(): void;
/**
* converts span info into more readable format
* @param span
*/
private _exportInfo;
/**
* Showing spans in console
* @param spans
* @param done
*/
private _sendSpans;
}

@@ -25,11 +25,49 @@ "use strict";

class ConsoleSpanExporter {
/**
* Export spans.
* @param spans
* @param resultCallback
*/
export(spans, resultCallback) {
return this._sendSpans(spans, resultCallback);
}
/**
* Shutdown the exporter.
*/
shutdown() {
return this._sendSpans([]);
}
/**
* converts span info into more readable format
* @param span
*/
_exportInfo(span) {
return {
traceId: span.spanContext.traceId,
parentId: span.parentSpanId,
name: span.name,
id: span.spanContext.spanId,
kind: span.kind,
timestamp: core_1.hrTimeToMicroseconds(span.startTime),
duration: core_1.hrTimeToMicroseconds(span.duration),
attributes: span.attributes,
status: span.status,
events: span.events,
};
}
/**
* Showing spans in console
* @param spans
* @param done
*/
_sendSpans(spans, done) {
for (const span of spans) {
console.log(`{name=${span.name}, traceId=${span.spanContext.traceId}, spanId=${span.spanContext.spanId}, kind=${span.kind}, parent=${span.parentSpanId}, duration=${core_1.hrTimeToMilliseconds(span.duration)}}}`);
console.log(this._exportInfo(span));
}
return resultCallback(base_1.ExportResult.SUCCESS);
if (done) {
return done(base_1.ExportResult.SUCCESS);
}
}
shutdown() { }
}
exports.ConsoleSpanExporter = ConsoleSpanExporter;
//# sourceMappingURL=ConsoleSpanExporter.js.map

@@ -23,3 +23,2 @@ /*!

export declare class Span implements types.Span, ReadableSpan {
private readonly _tracer;
readonly spanContext: types.SpanContext;

@@ -41,13 +40,18 @@ readonly kind: types.SpanKind;

/** Constructs a new Span instance. */
constructor(parentTracer: BasicTracer, spanName: string, spanContext: types.SpanContext, kind: types.SpanKind, parentSpanId?: string, startTime?: types.TimeInput);
tracer(): types.Tracer;
constructor(parentTracer: BasicTracer, spanName: string, spanContext: types.SpanContext, kind: types.SpanKind, parentSpanId?: string, links?: types.Link[], startTime?: types.TimeInput);
context(): types.SpanContext;
setAttribute(key: string, value: unknown): this;
setAttributes(attributes: types.Attributes): this;
addEvent(name: string, attributes?: types.Attributes): this;
addLink(spanContext: types.SpanContext, attributes?: types.Attributes): this;
/**
*
* @param name Span Name
* @param [attributesOrStartTime] Span attributes or start time
* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
*/
addEvent(name: string, attributesOrStartTime?: types.Attributes | types.TimeInput, startTime?: types.TimeInput): this;
setStatus(status: types.Status): this;
updateName(name: string): this;
end(endTime?: types.TimeInput): void;
isRecordingEvents(): boolean;
isRecording(): boolean;
toReadableSpan(): ReadableSpan;

@@ -54,0 +58,0 @@ readonly duration: types.HrTime;

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

/** Constructs a new Span instance. */
constructor(parentTracer, spanName, spanContext, kind, parentSpanId, startTime = core_1.hrTime()) {
constructor(parentTracer, spanName, spanContext, kind, parentSpanId, links = [], startTime = core_1.hrTime()) {
this.attributes = {};

@@ -36,3 +36,2 @@ this.links = [];

this._duration = [-1, -1];
this._tracer = parentTracer;
this.name = spanName;

@@ -42,2 +41,3 @@ this.spanContext = spanContext;

this.kind = kind;
this.links = links;
this.startTime = core_1.timeInputToHrTime(startTime);

@@ -49,5 +49,2 @@ this._logger = parentTracer.logger;

}
tracer() {
return this._tracer;
}
context() {

@@ -76,3 +73,10 @@ return this.spanContext;

}
addEvent(name, attributes) {
/**
*
* @param name Span Name
* @param [attributesOrStartTime] Span attributes or start time
* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
*/
addEvent(name, attributesOrStartTime, startTime) {
if (this._isSpanEnded())

@@ -84,13 +88,16 @@ return this;

}
this.events.push({ name, attributes, time: core_1.hrTime() });
return this;
}
addLink(spanContext, attributes) {
if (this._isSpanEnded())
return this;
if (this.links.length >= this._traceParams.numberOfLinksPerSpan) {
this._logger.warn('Dropping extra links.');
this.links.shift();
if (core_1.isTimeInput(attributesOrStartTime)) {
if (typeof startTime === 'undefined') {
startTime = attributesOrStartTime;
}
attributesOrStartTime = undefined;
}
this.links.push({ spanContext, attributes });
if (typeof startTime === 'undefined') {
startTime = core_1.hrTime();
}
this.events.push({
name,
attributes: attributesOrStartTime,
time: core_1.timeInputToHrTime(startTime),
});
return this;

@@ -123,3 +130,3 @@ }

}
isRecordingEvents() {
isRecording() {
return true;

@@ -126,0 +133,0 @@ }

@@ -23,3 +23,3 @@ /*!

/**
* Called when a {@link Span} is started, if the `span.isRecordingEvents()`
* Called when a {@link Span} is started, if the `span.isRecording()`
* returns true.

@@ -30,3 +30,3 @@ * @param span the Span that just started.

/**
* Called when a {@link Span} is ended, if the `span.isRecordingEvents()`
* Called when a {@link Span} is ended, if the `span.isRecording()`
* returns true.

@@ -33,0 +33,0 @@ * @param span the Span that just ended.

{
"name": "@opentelemetry/tracing",
"version": "0.1.1",
"version": "0.2.0",
"description": "OpenTelemetry Tracing",

@@ -13,11 +13,12 @@ "main": "build/src/index.js",

"scripts": {
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts' --exclude 'test/index-webpack.ts'",
"test:browser": "karma start --single-run",
"tdd": "yarn test -- --watch-extensions ts --watch",
"check": "gts check",
"clean": "rimraf build/*",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"clean": "rimraf build/*",
"check": "gts check",
"compile": "tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile"
"prepare": "npm run compile",
"tdd": "yarn test -- --watch-extensions ts --watch",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts' --exclude 'test/index-webpack.ts'",
"test:browser": "nyc karma start --single-run",
"watch": "tsc -w"
},

@@ -50,7 +51,10 @@ "keywords": [

"@types/node": "^12.6.8",
"@types/sinon": "^7.0.13",
"@types/webpack-env": "1.13.9",
"codecov": "^3.1.0",
"gts": "^1.0.0",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-mocha": "^1.3.0",

@@ -62,7 +66,8 @@ "karma-spec-reporter": "^0.0.32",

"rimraf": "^3.0.0",
"tslint-consistent-codestyle": "^1.15.1",
"tslint-microsoft-contrib": "^6.2.0",
"sinon": "^7.5.0",
"ts-loader": "^6.0.4",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"tslint-consistent-codestyle": "^1.16.0",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.6.3",

@@ -72,7 +77,7 @@ "webpack": "^4.35.2"

"dependencies": {
"@opentelemetry/core": "^0.1.0",
"@opentelemetry/scope-base": "^0.1.0",
"@opentelemetry/base": "^0.1.0",
"@opentelemetry/types": "^0.1.0"
"@opentelemetry/base": "^0.2.0",
"@opentelemetry/core": "^0.2.0",
"@opentelemetry/scope-base": "^0.2.0",
"@opentelemetry/types": "^0.2.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc