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

@opentelemetry/web

Package Overview
Dependencies
Maintainers
5
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/web - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

build/src/StackContextManager.d.ts

2

build/src/index.d.ts

@@ -17,5 +17,5 @@ /*!

export * from './WebTracerProvider';
export * from './StackScopeManager';
export * from './StackContextManager';
export * from './enums/PerformanceTimingNames';
export * from './types';
export * from './utils';

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

__export(require("./WebTracerProvider"));
__export(require("./StackScopeManager"));
__export(require("./StackContextManager"));
__export(require("./enums/PerformanceTimingNames"));
__export(require("./utils"));
//# sourceMappingURL=index.js.map

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

*/
import { Context } from '@opentelemetry/api';
import { ScopeManager } from '@opentelemetry/scope-base';

@@ -30,3 +31,3 @@ /**

*/
_currentScope: unknown;
_currentScope: Context;
/**

@@ -41,3 +42,3 @@ *

*/
active(): unknown;
active(): Context;
/**

@@ -48,3 +49,3 @@ * Binds a the certain scope or the active one to the target function and then returns the target

*/
bind<T>(target: T, scope?: unknown): T;
bind<T>(target: T, scope?: Context): T;
/**

@@ -64,3 +65,3 @@ * Disable the scope manager (clears the current scope)

*/
with<T extends (...args: unknown[]) => ReturnType<T>>(scope: unknown, fn: () => ReturnType<T>): ReturnType<T>;
with<T extends (...args: unknown[]) => ReturnType<T>>(scope: Context | null, fn: () => ReturnType<T>): ReturnType<T>;
}

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

Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("@opentelemetry/api");
/**

@@ -29,2 +30,6 @@ * Stack Scope Manager for managing the state in web

this._enabled = false;
/**
* Keeps the reference to current scope
*/
this._currentScope = api_1.Context.ROOT_CONTEXT;
}

@@ -36,3 +41,3 @@ /**

*/
_bindFunction(target, scope) {
_bindFunction(target, scope = api_1.Context.ROOT_CONTEXT) {
const manager = this;

@@ -61,3 +66,3 @@ const contextWrapper = function (...args) {

*/
bind(target, scope) {
bind(target, scope = api_1.Context.ROOT_CONTEXT) {
// if no specific scope to propagate is given, we use the current one

@@ -76,3 +81,3 @@ if (scope === undefined) {

disable() {
this._currentScope = undefined;
this._currentScope = api_1.Context.ROOT_CONTEXT;
this._enabled = false;

@@ -89,3 +94,3 @@ return this;

this._enabled = true;
this._currentScope = window;
this._currentScope = api_1.Context.ROOT_CONTEXT;
return this;

@@ -100,7 +105,4 @@ }

with(scope, fn) {
if (typeof scope === 'undefined' || scope === null) {
scope = window;
}
const previousScope = this._currentScope;
this._currentScope = scope;
this._currentScope = scope || api_1.Context.ROOT_CONTEXT;
try {

@@ -107,0 +109,0 @@ return fn.apply(scope);

@@ -16,2 +16,2 @@ /*!

*/
export declare const VERSION = "0.4.0";
export declare const VERSION = "0.5.0";

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.4.0';
exports.VERSION = '0.5.0';
//# sourceMappingURL=version.js.map

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

import { BasePlugin } from '@opentelemetry/core';
import { BasicTracerProvider, TracerConfig } from '@opentelemetry/tracing';
import { BasicTracerProvider, SDKRegistrationConfig, TracerConfig } from '@opentelemetry/tracing';
/**

@@ -29,3 +29,3 @@ * WebTracerConfig provides an interface for configuring a Web Tracer.

/**
* This class represents a web tracer with {@link StackScopeManager}
* This class represents a web tracer with {@link StackContextManager}
*/

@@ -38,2 +38,10 @@ export declare class WebTracerProvider extends BasicTracerProvider {

constructor(config?: WebTracerConfig);
/**
* Register this TracerProvider for use with the OpenTelemetry API.
* Undefined values may be replaced with defaults, and
* null values will be skipped.
*
* @param config Configuration object for SDK registration
*/
register(config?: SDKRegistrationConfig): void;
}

@@ -19,5 +19,5 @@ "use strict";

const tracing_1 = require("@opentelemetry/tracing");
const StackScopeManager_1 = require("./StackScopeManager");
const StackContextManager_1 = require("./StackContextManager");
/**
* This class represents a web tracer with {@link StackScopeManager}
* This class represents a web tracer with {@link StackContextManager}
*/

@@ -30,10 +30,6 @@ class WebTracerProvider extends tracing_1.BasicTracerProvider {

constructor(config = {}) {
if (typeof config.scopeManager === 'undefined') {
config.scopeManager = new StackScopeManager_1.StackScopeManager();
}
if (typeof config.plugins === 'undefined') {
config.plugins = [];
}
super(Object.assign({}, { scopeManager: config.scopeManager }, config));
config.scopeManager.enable();
super(config);
for (const plugin of config.plugins) {

@@ -43,4 +39,18 @@ plugin.enable([], this, this.logger);

}
/**
* Register this TracerProvider for use with the OpenTelemetry API.
* Undefined values may be replaced with defaults, and
* null values will be skipped.
*
* @param config Configuration object for SDK registration
*/
register(config = {}) {
if (config.contextManager === undefined) {
config.contextManager = new StackContextManager_1.StackContextManager();
config.contextManager.enable();
}
super.register(config);
}
}
exports.WebTracerProvider = WebTracerProvider;
//# sourceMappingURL=WebTracerProvider.js.map
{
"name": "@opentelemetry/web",
"version": "0.4.0",
"version": "0.5.0",
"description": "OpenTelemetry Web Tracer",

@@ -9,3 +9,4 @@ "main": "build/src/index.js",

"scripts": {
"check": "gts check",
"lint": "gts check",
"lint:fix": "gts fix",
"clean": "rimraf build/*",

@@ -16,3 +17,2 @@ "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",

"compile": "npm run version:update && tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile",

@@ -48,3 +48,4 @@ "tdd": "karma start",

"@babel/core": "^7.6.0",
"@opentelemetry/scope-zone": "^0.4.0",
"@opentelemetry/context-zone": "^0.5.0",
"@opentelemetry/resources": "^0.5.0",
"@types/jquery": "^3.3.31",

@@ -81,7 +82,7 @@ "@types/mocha": "^5.2.5",

"dependencies": {
"@opentelemetry/api": "^0.4.0",
"@opentelemetry/core": "^0.4.0",
"@opentelemetry/scope-base": "^0.4.0",
"@opentelemetry/tracing": "^0.4.0"
"@opentelemetry/api": "^0.5.0",
"@opentelemetry/context-base": "^0.5.0",
"@opentelemetry/core": "^0.5.0",
"@opentelemetry/tracing": "^0.5.0"
}
}

@@ -14,3 +14,3 @@ # OpenTelemetry Web

## How does automatic tracing work?
This package exposes a class `WebTracer` that will be able to automatically trace things in Browser only.
This package exposes a class `WebTracerProvider` that will be able to automatically trace things in Browser only.

@@ -22,6 +22,6 @@ See the example how to use it.

Web Tracer currently supports one plugin for document load.
Unlike Node Tracer, the plugins needs to be initialised and passed in configuration.
The reason is to give user full control over which plugin will be bundled into web page.
Unlike Node Tracer (`NodeTracerProvider`), the plugins needs to be initialised and passed in configuration.
The reason is to give user full control over which plugin will be bundled into web page.
You can choose to use the ZoneScopeManager if you want to trace asynchronous operations.
You can choose to use the `ZoneContextManager` if you want to trace asynchronous operations.

@@ -38,8 +38,8 @@ ## Installation

import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracer } from '@opentelemetry/web';
import { WebTracerProvider } from '@opentelemetry/web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
import { ZoneScopeManager } from '@opentelemetry/scope-zone';
import { ZoneContextManager } from '@opentelemetry/context-zone';
// Minimum required setup - supports only synchronous operations
const webTracer = new WebTracer({
const provider = new WebTracerProvider({
plugins: [

@@ -50,7 +50,7 @@ new DocumentLoad()

webTracer.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
// Changing default scopeManager to use ZoneScopeManager - supports asynchronous operations
const webTracerWithZone = new WebTracer({
scopeManager: new ZoneScopeManager(),
// Changing default contextManager to use ZoneContextManager - supports asynchronous operations
const providerWithZone = new WebTracerProvider({
contextManager: new ZoneContextManager(),
plugins: [

@@ -60,3 +60,3 @@ new DocumentLoad()

});
webTracerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

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