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

@opentelemetry/api

Package Overview
Dependencies
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/api - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

5

build/src/api/global-utils.d.ts
import { ContextManager } from '@opentelemetry/context-base';
import { TextMapPropagator } from '../context/propagation/TextMapPropagator';
import { MeterProvider } from '../metrics/MeterProvider';
import { TracerProvider } from '../trace/tracer_provider';
export declare const GLOBAL_CONTEXT_MANAGER_API_KEY: unique symbol;
export declare const GLOBAL_METRICS_API_KEY: unique symbol;
export declare const GLOBAL_PROPAGATION_API_KEY: unique symbol;

@@ -12,3 +10,2 @@ export declare const GLOBAL_TRACE_API_KEY: unique symbol;

[GLOBAL_CONTEXT_MANAGER_API_KEY]: Get<ContextManager>;
[GLOBAL_METRICS_API_KEY]: Get<MeterProvider>;
[GLOBAL_PROPAGATION_API_KEY]: Get<TextMapPropagator>;

@@ -33,4 +30,4 @@ [GLOBAL_TRACE_API_KEY]: Get<TracerProvider>;

*/
export declare const API_BACKWARDS_COMPATIBILITY_VERSION = 2;
export declare const API_BACKWARDS_COMPATIBILITY_VERSION = 3;
export {};
//# sourceMappingURL=global-utils.d.ts.map

@@ -18,6 +18,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.API_BACKWARDS_COMPATIBILITY_VERSION = exports.makeGetter = exports._global = exports.GLOBAL_TRACE_API_KEY = exports.GLOBAL_PROPAGATION_API_KEY = exports.GLOBAL_METRICS_API_KEY = exports.GLOBAL_CONTEXT_MANAGER_API_KEY = void 0;
exports.API_BACKWARDS_COMPATIBILITY_VERSION = exports.makeGetter = exports._global = exports.GLOBAL_TRACE_API_KEY = exports.GLOBAL_PROPAGATION_API_KEY = exports.GLOBAL_CONTEXT_MANAGER_API_KEY = void 0;
var platform_1 = require("../platform");
exports.GLOBAL_CONTEXT_MANAGER_API_KEY = Symbol.for('io.opentelemetry.js.api.context');
exports.GLOBAL_METRICS_API_KEY = Symbol.for('io.opentelemetry.js.api.metrics');
exports.GLOBAL_PROPAGATION_API_KEY = Symbol.for('io.opentelemetry.js.api.propagation');

@@ -47,3 +46,3 @@ exports.GLOBAL_TRACE_API_KEY = Symbol.for('io.opentelemetry.js.api.trace');

*/
exports.API_BACKWARDS_COMPATIBILITY_VERSION = 2;
exports.API_BACKWARDS_COMPATIBILITY_VERSION = 3;
//# sourceMappingURL=global-utils.js.map

4

build/src/api/propagation.d.ts

@@ -32,2 +32,6 @@ import { Context } from '@opentelemetry/context-base';

extract<Carrier>(context: Context, carrier: Carrier, getter?: TextMapGetter<Carrier>): Context;
/**
* Return a list of all fields which may be used by the propagator.
*/
fields(): string[];
/** Remove the global propagator */

@@ -34,0 +38,0 @@ disable(): void;

@@ -69,2 +69,8 @@ "use strict";

};
/**
* Return a list of all fields which may be used by the propagator.
*/
PropagationAPI.prototype.fields = function () {
return this._getGlobalPropagator().fields();
};
/** Remove the global propagator */

@@ -71,0 +77,0 @@ PropagationAPI.prototype.disable = function () {

import { Context } from '@opentelemetry/context-base';
import { Baggage, Span, SpanContext } from '../';
/**
* Return the active span if one exists
* Return the span if one exists
*
* @param context context to get span from
*/
export declare function getActiveSpan(context: Context): Span | undefined;
export declare function getSpan(context: Context): Span | undefined;
/**
* Set the active span on a context
* Set the span on a context
*

@@ -15,5 +15,5 @@ * @param context context to use as parent

*/
export declare function setActiveSpan(context: Context, span: Span): Context;
export declare function setSpan(context: Context, span: Span): Context;
/**
* Wrap extracted span context in a NoopSpan and set as active span in a new
* Wrap span context in a NoopSpan and set as span in a new
* context

@@ -24,11 +24,9 @@ *

*/
export declare function setExtractedSpanContext(context: Context, spanContext: SpanContext): Context;
export declare function setSpanContext(context: Context, spanContext: SpanContext): Context;
/**
* Get the span context of the parent span if it exists,
* or the extracted span context if there is no active
* span.
* Get the span context of the span if it exists.
*
* @param context context to get values from
*/
export declare function getParentSpanContext(context: Context): SpanContext | undefined;
export declare function getSpanContext(context: Context): SpanContext | undefined;
/**

@@ -35,0 +33,0 @@ * Sets value on context to indicate that instrumentation should

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.setBaggage = exports.getBaggage = exports.isInstrumentationSuppressed = exports.unsuppressInstrumentation = exports.suppressInstrumentation = exports.getParentSpanContext = exports.setExtractedSpanContext = exports.setActiveSpan = exports.getActiveSpan = void 0;
exports.setBaggage = exports.getBaggage = exports.isInstrumentationSuppressed = exports.unsuppressInstrumentation = exports.suppressInstrumentation = exports.getSpanContext = exports.setSpanContext = exports.setSpan = exports.getSpan = void 0;
var context_base_1 = require("@opentelemetry/context-base");
var __1 = require("../");
/**
* Active span key
* span key
*/
var ACTIVE_SPAN_KEY = context_base_1.createContextKey('OpenTelemetry Context Key ACTIVE_SPAN');
var SPAN_KEY = context_base_1.createContextKey('OpenTelemetry Context Key SPAN');
/**

@@ -36,12 +36,12 @@ * Shared key for indicating if instrumentation should be suppressed beyond

/**
* Return the active span if one exists
* Return the span if one exists
*
* @param context context to get span from
*/
function getActiveSpan(context) {
return context.getValue(ACTIVE_SPAN_KEY) || undefined;
function getSpan(context) {
return context.getValue(SPAN_KEY) || undefined;
}
exports.getActiveSpan = getActiveSpan;
exports.getSpan = getSpan;
/**
* Set the active span on a context
* Set the span on a context
*

@@ -51,8 +51,8 @@ * @param context context to use as parent

*/
function setActiveSpan(context, span) {
return context.setValue(ACTIVE_SPAN_KEY, span);
function setSpan(context, span) {
return context.setValue(SPAN_KEY, span);
}
exports.setActiveSpan = setActiveSpan;
exports.setSpan = setSpan;
/**
* Wrap extracted span context in a NoopSpan and set as active span in a new
* Wrap span context in a NoopSpan and set as span in a new
* context

@@ -63,18 +63,16 @@ *

*/
function setExtractedSpanContext(context, spanContext) {
return setActiveSpan(context, new __1.NoopSpan(spanContext));
function setSpanContext(context, spanContext) {
return setSpan(context, new __1.NoopSpan(spanContext));
}
exports.setExtractedSpanContext = setExtractedSpanContext;
exports.setSpanContext = setSpanContext;
/**
* Get the span context of the parent span if it exists,
* or the extracted span context if there is no active
* span.
* Get the span context of the span if it exists.
*
* @param context context to get values from
*/
function getParentSpanContext(context) {
function getSpanContext(context) {
var _a;
return (_a = getActiveSpan(context)) === null || _a === void 0 ? void 0 : _a.context();
return (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.context();
}
exports.getParentSpanContext = getParentSpanContext;
exports.getSpanContext = getSpanContext;
/**

@@ -81,0 +79,0 @@ * Sets value on context to indicate that instrumentation should

@@ -43,5 +43,2 @@ import { Context } from '@opentelemetry/context-base';

* Return a list of all fields which may be used by the propagator.
*
* This list should be used to clear fields before calling inject if a carrier is
* used more than once.
*/

@@ -48,0 +45,0 @@ fields(): string[];

@@ -9,11 +9,2 @@ export * from './common/Exception';

export * from './baggage/EntryValue';
export * from './metrics/BatchObserverResult';
export * from './metrics/BoundInstrument';
export * from './metrics/Meter';
export * from './metrics/MeterProvider';
export * from './metrics/Metric';
export * from './metrics/NoopMeter';
export * from './metrics/NoopMeterProvider';
export * from './metrics/Observation';
export * from './metrics/ObserverResult';
export * from './trace/attributes';

@@ -49,5 +40,2 @@ export * from './trace/Event';

export declare const trace: TraceAPI;
import { MetricsAPI } from './api/metrics';
/** Entrypoint for metrics API */
export declare const metrics: MetricsAPI;
import { PropagationAPI } from './api/propagation';

@@ -58,3 +46,2 @@ /** Entrypoint for propagation API */

trace: TraceAPI;
metrics: MetricsAPI;
context: ContextAPI;

@@ -61,0 +48,0 @@ propagation: PropagationAPI;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.propagation = exports.metrics = exports.trace = exports.context = void 0;
exports.propagation = exports.trace = exports.context = void 0;
__exportStar(require("./common/Exception"), exports);

@@ -38,11 +38,2 @@ __exportStar(require("./common/Logger"), exports);

__exportStar(require("./baggage/EntryValue"), exports);
__exportStar(require("./metrics/BatchObserverResult"), exports);
__exportStar(require("./metrics/BoundInstrument"), exports);
__exportStar(require("./metrics/Meter"), exports);
__exportStar(require("./metrics/MeterProvider"), exports);
__exportStar(require("./metrics/Metric"), exports);
__exportStar(require("./metrics/NoopMeter"), exports);
__exportStar(require("./metrics/NoopMeterProvider"), exports);
__exportStar(require("./metrics/Observation"), exports);
__exportStar(require("./metrics/ObserverResult"), exports);
__exportStar(require("./trace/attributes"), exports);

@@ -86,5 +77,2 @@ __exportStar(require("./trace/Event"), exports);

exports.trace = trace_1.TraceAPI.getInstance();
var metrics_1 = require("./api/metrics");
/** Entrypoint for metrics API */
exports.metrics = metrics_1.MetricsAPI.getInstance();
var propagation_1 = require("./api/propagation");

@@ -95,3 +83,2 @@ /** Entrypoint for propagation API */

trace: exports.trace,
metrics: exports.metrics,
context: exports.context,

@@ -98,0 +85,0 @@ propagation: exports.propagation,

@@ -7,8 +7,5 @@ import { Span, SpanOptions, Tracer } from '..';

export declare class NoopTracer implements Tracer {
getCurrentSpan(): Span;
startSpan(name: string, options?: SpanOptions, context?: Context): Span;
withSpan<T extends (...args: unknown[]) => ReturnType<T>>(span: Span, fn: T): ReturnType<T>;
bind<T>(target: T, _span?: Span): T;
}
export declare const NOOP_TRACER: NoopTracer;
//# sourceMappingURL=NoopTracer.d.ts.map

@@ -28,5 +28,2 @@ "use strict";

}
NoopTracer.prototype.getCurrentSpan = function () {
return NoopSpan_1.NOOP_SPAN;
};
// startSpan starts a noop span.

@@ -38,3 +35,3 @@ NoopTracer.prototype.startSpan = function (name, options, context) {

}
var parentFromContext = context && context_1.getParentSpanContext(context);
var parentFromContext = context && context_1.getSpanContext(context);
if (isSpanContext(parentFromContext) &&

@@ -48,8 +45,2 @@ spancontext_utils_1.isSpanContextValid(parentFromContext)) {

};
NoopTracer.prototype.withSpan = function (span, fn) {
return fn();
};
NoopTracer.prototype.bind = function (target, _span) {
return target;
};
return NoopTracer;

@@ -56,0 +47,0 @@ }());

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

import { Context } from '@opentelemetry/context-base';
import { Span, SpanOptions, Tracer } from '..';

@@ -12,6 +13,3 @@ import { ProxyTracerProvider } from './ProxyTracerProvider';

constructor(_provider: ProxyTracerProvider, name: string, version?: string | undefined);
getCurrentSpan(): Span | undefined;
startSpan(name: string, options?: SpanOptions): Span;
withSpan<T extends (...args: unknown[]) => ReturnType<T>>(span: Span, fn: T): ReturnType<T>;
bind<T>(target: T, span?: Span): T;
startSpan(name: string, options?: SpanOptions, context?: Context): Span;
/**

@@ -18,0 +16,0 @@ * Try to get a tracer from the proxy tracer provider.

@@ -29,14 +29,5 @@ "use strict";

}
ProxyTracer.prototype.getCurrentSpan = function () {
return this._getTracer().getCurrentSpan();
ProxyTracer.prototype.startSpan = function (name, options, context) {
return this._getTracer().startSpan(name, options, context);
};
ProxyTracer.prototype.startSpan = function (name, options) {
return this._getTracer().startSpan(name, options);
};
ProxyTracer.prototype.withSpan = function (span, fn) {
return this._getTracer().withSpan(span, fn);
};
ProxyTracer.prototype.bind = function (target, span) {
return this._getTracer().bind(target, span);
};
/**

@@ -43,0 +34,0 @@ * Try to get a tracer from the proxy tracer provider.

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

import { TimeInput } from '../common/Time';
import { Attributes } from './attributes';

@@ -18,3 +19,3 @@ import { Link } from './link';

/** A manually specified start time for the created `Span` object. */
startTime?: number;
startTime?: TimeInput;
/** The new span should be a root span. (Ignore parent from context). */

@@ -21,0 +22,0 @@ root?: boolean;

@@ -13,20 +13,6 @@ import { Context } from '@opentelemetry/context-base';

/**
* Returns the current Span from the current context if available.
* Starts a new {@link Span}. Start the span without setting it on context.
*
* If there is no Span associated with the current context, `undefined` is
* returned.
* This method do NOT modify the current Context.
*
* To install a {@link Span} to the current Context use
* {@link Tracer.withSpan}.
*
* @returns Span The currently active Span
*/
getCurrentSpan(): Span | undefined;
/**
* Starts a new {@link Span}. Start the span without setting it as the current
* span in this tracer's context.
*
* This method do NOT modify the current Context. To install a {@link
* Span} to the current Context use {@link Tracer.withSpan}.
*
* @param name The name of the span

@@ -42,26 +28,3 @@ * @param [options] SpanOptions used for span creation

startSpan(name: string, options?: SpanOptions, context?: Context): Span;
/**
* Executes the function given by fn within the context provided by Span.
*
* This is a convenience method for creating spans attached to the tracer's
* context. Applications that need more control over the span lifetime should
* use {@link Tracer.startSpan} instead.
*
* @param span The span that provides the context
* @param fn The function to be executed inside the provided context
* @example
* tracer.withSpan(span, () => {
* tracer.getCurrentSpan().addEvent("parent's event");
* doSomeOtherWork(); // Here "span" is the current Span.
* });
*/
withSpan<T extends (...args: unknown[]) => ReturnType<T>>(span: Span, fn: T): ReturnType<T>;
/**
* Bind a span as the target's context or propagate the current one.
*
* @param target Any object to which a context need to be set
* @param [context] Optionally specify the context which you want to bind
*/
bind<T>(target: T, context?: Span): T;
}
//# sourceMappingURL=tracer.d.ts.map

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

export declare const VERSION = "0.14.0";
export declare const VERSION = "0.15.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.14.0';
exports.VERSION = '0.15.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/api",
"version": "0.14.0",
"version": "0.15.0",
"description": "Public API for OpenTelemetry",

@@ -13,2 +13,4 @@ "main": "build/src/index.js",

"scripts": {
"compile": "tsc --build",
"clean": "tsc --build --clean",
"test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",

@@ -21,9 +23,6 @@ "test:browser": "nyc karma start --single-run",

"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version",
"version:update": "node ../../scripts/version-update.js",
"compile": "npm run version:update && tsc -p .",
"version": "node ../../scripts/version-update.js",
"docs-test": "linkinator docs/out --silent --skip david-dm.org",
"docs": "typedoc --tsconfig tsconfig.json --exclude test/**/*.ts",
"prepare": "npm run compile",
"watch": "tsc -w"
"docs": "typedoc --tsconfig tsconfig.docs.json",
"watch": "tsc --build --watch"
},

@@ -36,3 +35,2 @@ "keywords": [

"profiling",
"metrics",
"stats",

@@ -58,8 +56,8 @@ "monitoring"

"dependencies": {
"@opentelemetry/context-base": "^0.14.0"
"@opentelemetry/context-base": "^0.15.0"
},
"devDependencies": {
"@types/mocha": "8.2.0",
"@types/node": "14.14.12",
"@types/sinon": "9.0.9",
"@types/node": "14.14.20",
"@types/sinon": "9.0.10",
"@types/webpack-env": "1.16.0",

@@ -75,13 +73,13 @@ "codecov": "3.8.1",

"karma-webpack": "4.0.2",
"linkinator": "2.8.0",
"linkinator": "2.13.1",
"mocha": "7.2.0",
"nyc": "15.1.0",
"sinon": "9.2.2",
"ts-loader": "8.0.12",
"sinon": "9.2.3",
"ts-loader": "8.0.14",
"ts-mocha": "8.0.0",
"typedoc": "0.19.2",
"typedoc": "0.20.14",
"typescript": "3.9.7",
"webpack": "4.44.2"
"webpack": "4.46.0"
},
"gitHead": "27a8d4530c56257c191468b073669909bf8892a1"
"gitHead": "960b868f5b7686eabbf49190071b8463551e5d8f"
}

@@ -13,3 +13,3 @@ # OpenTelemetry API for JavaScript

To get started you need to install the SDK and plugins, create a TracerProvider and/or MeterProvider, and register it with the API.
To get started you need to install the SDK and plugins, create a TracerProvider, and register it with the API.

@@ -27,7 +27,2 @@ ### Install Dependencies

@opentelemetry/plugin-http # add plugins as needed
$ # Install metrics dependencies
$ npm install \
@opentelemetry/metrics \
@opentelemetry/exporter-prometheus # add exporters as needed
```

@@ -79,23 +74,2 @@

#### Metrics
```javascript
const api = require("@opentelemetry/api");
const { MeterProvider } = require("@opentelemetry/metrics");
const { PrometheusExporter } = require("@opentelemetry/exporter-prometheus");
const meterProvider = new MeterProvider({
// The Prometheus exporter runs an HTTP server which
// the Prometheus backend scrapes to collect metrics.
exporter: new PrometheusExporter({ startServer: true }),
interval: 1000,
});
/**
* Registering the provider with the API allows it to be discovered
* and used by instrumentation libraries.
*/
api.metrics.setGlobalMeterProvider(meterProvider);
```
## Version Compatibility

@@ -128,3 +102,2 @@

- [Trace API Documentation][trace-api-docs]
- [Metrics API Documentation][metrics-api-docs]
- [Propagation API Documentation][propagation-api-docs]

@@ -143,9 +116,2 @@ - [Context API Documentation][context-api-docs]

/* Initialize MeterProvider */
api.metrics.setGlobalMeterProvider(meterProvider);
/* returns meterProvider (no-op if a working provider has not been initialized) */
api.metrics.getMeterProvider();
/* returns a meter from the registered global meter provider (no-op if a working provider has not been initialized) */
api.metrics.getMeter(name, version);
/* Initialize Propagator */

@@ -168,3 +134,3 @@ api.propagation.setGlobalPropagator(httpTraceContextPropagator);

async function doSomething() {
const span = tracer.startSpan("doSomething", { parent: tracer.getCurrentSpan() });
const span = tracer.startSpan("doSomething");
try {

@@ -171,0 +137,0 @@ const result = await doSomethingElse();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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