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.9.0 to 0.10.0

build/src/BasicTracerProvider.js.map

6

build/src/BasicTracerProvider.js

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

if (!this._tracers.has(key)) {
this._tracers.set(key, new _1.Tracer(config || this._config, this));
this._tracers.set(key, new _1.Tracer({ name, version }, config || this._config, this));
}

@@ -71,3 +71,5 @@ return this._tracers.get(key);

if (config.propagator === undefined) {
config.propagator = new core_1.HttpTraceContext();
config.propagator = new core_1.CompositePropagator({
propagators: [new core_1.HttpCorrelationContext(), new core_1.HttpTraceContext()],
});
}

@@ -74,0 +76,0 @@ if (config.contextManager) {

@@ -1,2 +0,2 @@

import { LogLevel } from '@opentelemetry/core';
import { AlwaysOnSampler } from '@opentelemetry/core';
/** Default limit for Message events per span */

@@ -15,5 +15,4 @@ export declare const DEFAULT_MAX_EVENTS_PER_SPAN = 128;

export declare const DEFAULT_CONFIG: {
defaultAttributes: {};
logLevel: LogLevel;
sampler: import("@opentelemetry/core").ProbabilitySampler;
logLevel: import("@opentelemetry/core").LogLevel;
sampler: AlwaysOnSampler;
traceParams: {

@@ -20,0 +19,0 @@ numberOfAttributesPerSpan: number;

@@ -33,5 +33,4 @@ "use strict";

exports.DEFAULT_CONFIG = {
defaultAttributes: {},
logLevel: core_1.LogLevel.INFO,
sampler: core_1.ALWAYS_SAMPLER,
logLevel: core_1.getEnv().OTEL_LOG_LEVEL,
sampler: new core_1.AlwaysOnSampler(),
traceParams: {

@@ -38,0 +37,0 @@ numberOfAttributesPerSpan: exports.DEFAULT_MAX_ATTRIBUTES_PER_SPAN,

@@ -17,6 +17,6 @@ import { SpanProcessor } from '../SpanProcessor';

constructor(_exporter: SpanExporter, config?: BufferConfig);
forceFlush(): void;
forceFlush(cb?: () => void): void;
onStart(span: ReadableSpan): void;
onEnd(span: ReadableSpan): void;
shutdown(): void;
shutdown(cb?: () => void): void;
/** Add a span in the buffer. */

@@ -23,0 +23,0 @@ private _addToBuffer;

@@ -38,7 +38,8 @@ "use strict";

}
forceFlush() {
forceFlush(cb = () => { }) {
if (this._isShutdown) {
setTimeout(cb, 0);
return;
}
this._flush();
this._flush(cb);
}

@@ -53,7 +54,8 @@ // does nothing.

}
shutdown() {
shutdown(cb = () => { }) {
if (this._isShutdown) {
setTimeout(cb, 0);
return;
}
this.forceFlush();
this.forceFlush(cb);
this._isShutdown = true;

@@ -71,7 +73,9 @@ this._exporter.shutdown();

/** Send the span data list to exporter */
_flush() {
_flush(cb = () => { }) {
this._clearTimer();
if (this._finishedSpans.length === 0)
if (this._finishedSpans.length === 0) {
setTimeout(cb, 0);
return;
this._exporter.export(this._finishedSpans, () => { });
}
this._exporter.export(this._finishedSpans, cb);
this._finishedSpans = [];

@@ -78,0 +82,0 @@ }

import { SpanKind, Status, Attributes, HrTime, Link, SpanContext, TimedEvent } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { InstrumentationLibrary } from '@opentelemetry/core';
export interface ReadableSpan {

@@ -17,3 +18,4 @@ readonly name: string;

readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
}
//# sourceMappingURL=ReadableSpan.d.ts.map

@@ -14,7 +14,7 @@ import { SpanProcessor } from '../SpanProcessor';

private _isShutdown;
forceFlush(): void;
forceFlush(cb?: () => void): void;
onStart(span: ReadableSpan): void;
onEnd(span: ReadableSpan): void;
shutdown(): void;
shutdown(cb?: () => void): void;
}
//# sourceMappingURL=SimpleSpanProcessor.d.ts.map

@@ -30,4 +30,5 @@ "use strict";

}
forceFlush() {
forceFlush(cb = () => { }) {
// do nothing as all spans are being exported without waiting
setTimeout(cb, 0);
}

@@ -42,4 +43,5 @@ // does nothing.

}
shutdown() {
shutdown(cb = () => { }) {
if (this._isShutdown) {
setTimeout(cb, 0);
return;

@@ -49,2 +51,3 @@ }

this._exporter.shutdown();
setTimeout(cb, 0);
}

@@ -51,0 +54,0 @@ }

@@ -10,7 +10,7 @@ import { SpanProcessor } from './SpanProcessor';

constructor(_spanProcessors: SpanProcessor[]);
forceFlush(): void;
forceFlush(cb?: () => void): void;
onStart(span: ReadableSpan): void;
onEnd(span: ReadableSpan): void;
shutdown(): void;
shutdown(cb?: () => void): void;
}
//# sourceMappingURL=MultiSpanProcessor.d.ts.map

@@ -27,5 +27,11 @@ "use strict";

}
forceFlush() {
forceFlush(cb = () => { }) {
let finished = 0;
const total = this._spanProcessors.length;
for (const spanProcessor of this._spanProcessors) {
spanProcessor.forceFlush();
spanProcessor.forceFlush(() => {
if (++finished === total) {
cb();
}
});
}

@@ -43,5 +49,11 @@ }

}
shutdown() {
shutdown(cb = () => { }) {
let finished = 0;
const total = this._spanProcessors.length;
for (const spanProcessor of this._spanProcessors) {
spanProcessor.shutdown();
spanProcessor.shutdown(() => {
if (++finished === total) {
cb();
}
});
}

@@ -48,0 +60,0 @@ }

@@ -7,5 +7,5 @@ import { SpanProcessor } from './SpanProcessor';

onEnd(span: ReadableSpan): void;
shutdown(): void;
forceFlush(): void;
shutdown(cb?: () => unknown): void;
forceFlush(cb?: () => unknown): void;
}
//# sourceMappingURL=NoopSpanProcessor.d.ts.map

@@ -23,6 +23,10 @@ "use strict";

onEnd(span) { }
shutdown() { }
forceFlush() { }
shutdown(cb = () => { }) {
setTimeout(cb, 0);
}
forceFlush(cb = () => { }) {
setTimeout(cb, 0);
}
}
exports.NoopSpanProcessor = NoopSpanProcessor;
//# sourceMappingURL=NoopSpanProcessor.js.map
import * as api from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';

@@ -17,2 +18,3 @@ import { ReadableSpan } from './export/ReadableSpan';

readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
name: string;

@@ -19,0 +21,0 @@ status: api.Status;

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

this.resource = parentTracer.resource;
this.instrumentationLibrary = parentTracer.instrumentationLibrary;
this._logger = parentTracer.logger;

@@ -45,0 +46,0 @@ this._traceParams = parentTracer.getActiveTraceParams();

@@ -10,3 +10,3 @@ import { ReadableSpan } from './export/ReadableSpan';

*/
forceFlush(): void;
forceFlush(callback: () => void): void;
/**

@@ -28,4 +28,4 @@ * Called when a {@link ReadableSpan} is started, if the `span.isRecording()`

*/
shutdown(): void;
shutdown(callback: () => void): void;
}
//# sourceMappingURL=SpanProcessor.d.ts.map
import * as api from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';

@@ -10,6 +11,6 @@ import { BasicTracerProvider } from './BasicTracerProvider';

private _tracerProvider;
private readonly _defaultAttributes;
private readonly _sampler;
private readonly _traceParams;
readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly logger: api.Logger;

@@ -19,3 +20,3 @@ /**

*/
constructor(config: TracerConfig, _tracerProvider: BasicTracerProvider);
constructor(instrumentationLibrary: InstrumentationLibrary, config: TracerConfig, _tracerProvider: BasicTracerProvider);
/**

@@ -22,0 +23,0 @@ * Starts a new Span or returns the default NoopSpan based on the sampling

@@ -30,9 +30,9 @@ "use strict";

*/
constructor(config, _tracerProvider) {
constructor(instrumentationLibrary, config, _tracerProvider) {
this._tracerProvider = _tracerProvider;
const localConfig = utility_1.mergeConfig(config);
this._defaultAttributes = localConfig.defaultAttributes;
this._sampler = localConfig.sampler;
this._traceParams = localConfig.traceParams;
this.resource = _tracerProvider.resource;
this.instrumentationLibrary = instrumentationLibrary;
this.logger = config.logger || new core_1.ConsoleLogger(config.logLevel);

@@ -45,3 +45,3 @@ }

startSpan(name, options = {}, context = api.context.active()) {
var _a, _b;
var _a, _b, _c;
const parentContext = getParent(options, context);

@@ -62,3 +62,3 @@ const spanId = core_1.randomSpanId();

const links = (_b = options.links) !== null && _b !== void 0 ? _b : [];
const attributes = Object.assign(Object.assign({}, this._defaultAttributes), options.attributes);
const attributes = (_c = options.attributes) !== null && _c !== void 0 ? _c : {};
// make sampling decision

@@ -65,0 +65,0 @@ const samplingResult = this._sampler.shouldSample(parentContext, traceId, name, spanKind, attributes, links);

@@ -1,2 +0,2 @@

import { Attributes, HttpTextPropagator, Logger, Sampler } from '@opentelemetry/api';
import { HttpTextPropagator, Logger, Sampler } from '@opentelemetry/api';
import { LogLevel } from '@opentelemetry/core';

@@ -10,7 +10,2 @@ import { ContextManager } from '@opentelemetry/context-base';

/**
* Attributes that will be applied on every span created by Tracer.
* Useful to add infrastructure and environment information to your spans.
*/
defaultAttributes?: Attributes;
/**
* User provided logger.

@@ -17,0 +12,0 @@ */

import { TracerConfig } from './types';
import { ParentOrElseSampler } from '@opentelemetry/core';
/**

@@ -7,5 +8,4 @@ * Function to merge Default configuration (as specified in './config') with

export declare function mergeConfig(userConfig: TracerConfig): {
defaultAttributes: {};
logLevel: import("@opentelemetry/core").LogLevel;
sampler: import("@opentelemetry/core").ProbabilitySampler;
sampler: import("@opentelemetry/core").AlwaysOnSampler;
traceParams: {

@@ -16,3 +16,5 @@ numberOfAttributesPerSpan: number;

};
} & {
sampler: ParentOrElseSampler;
} & TracerConfig;
//# sourceMappingURL=utility.d.ts.map

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

const config_1 = require("./config");
const core_1 = require("@opentelemetry/core");
/**

@@ -27,3 +28,10 @@ * Function to merge Default configuration (as specified in './config') with

const traceParams = userConfig.traceParams;
const target = Object.assign({}, config_1.DEFAULT_CONFIG, userConfig);
const otelSamplingProbability = core_1.getEnv().OTEL_SAMPLING_PROBABILITY;
const target = Object.assign(config_1.DEFAULT_CONFIG,
// use default AlwaysOnSampler if otelSamplingProbability is 1
otelSamplingProbability !== undefined && otelSamplingProbability < 1
? {
sampler: new core_1.ParentOrElseSampler(new core_1.ProbabilitySampler(otelSamplingProbability)),
}
: {}, userConfig);
// the user-provided value will be used to extend the default value.

@@ -30,0 +38,0 @@ if (traceParams) {

@@ -1,2 +0,2 @@

export declare const VERSION = "0.9.0";
export declare const VERSION = "0.10.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.9.0';
exports.VERSION = '0.10.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/tracing",
"version": "0.9.0",
"version": "0.10.0",
"description": "OpenTelemetry Tracing",

@@ -43,2 +43,3 @@ "main": "build/src/index.js",

"build/src/**/*.js",
"build/src/**/*.js.map",
"build/src/**/*.d.ts",

@@ -53,7 +54,7 @@ "doc",

"devDependencies": {
"@types/mocha": "7.0.2",
"@types/node": "14.0.13",
"@types/mocha": "8.0.0",
"@types/node": "14.0.25",
"@types/sinon": "9.0.4",
"@types/webpack-env": "1.15.2",
"codecov": "3.7.0",
"codecov": "3.7.2",
"gts": "2.0.2",

@@ -71,14 +72,15 @@ "istanbul-instrumenter-loader": "3.0.1",

"sinon": "9.0.2",
"ts-loader": "7.0.5",
"ts-loader": "8.0.1",
"ts-mocha": "7.0.0",
"ts-node": "8.10.2",
"typescript": "3.9.5",
"webpack": "4.43.0"
"typescript": "3.9.7",
"webpack": "4.44.0"
},
"dependencies": {
"@opentelemetry/api": "^0.9.0",
"@opentelemetry/context-base": "^0.9.0",
"@opentelemetry/core": "^0.9.0",
"@opentelemetry/resources": "^0.9.0"
}
"@opentelemetry/api": "^0.10.0",
"@opentelemetry/context-base": "^0.10.0",
"@opentelemetry/core": "^0.10.0",
"@opentelemetry/resources": "^0.10.0"
},
"gitHead": "ab62a4d69b99b3a8c9c26100c04f3226af7859df"
}

@@ -46,2 +46,9 @@ # OpenTelemetry Tracing SDK

## Config
Tracing configuration is a merge of user supplied configuration with both the default
configuration as specified in [config.ts](./src/config.ts) and an
environmentally configurable (via `OTEL_SAMPLING_PROBABILITY`) probability
sampler delegate of a [ParentOrElse](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#parentorelse) sampler.
## Example

@@ -48,0 +55,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