@opentelemetry/instrumentation-long-task
Advanced tools
Comparing version 0.27.0 to 0.28.0
@@ -1,2 +0,3 @@ | ||
import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation'; | ||
import { InstrumentationBase } from '@opentelemetry/instrumentation'; | ||
import type { LongtaskInstrumentationConfig } from './types'; | ||
export declare class LongTaskInstrumentation extends InstrumentationBase { | ||
@@ -7,2 +8,3 @@ readonly component: string; | ||
private _observer?; | ||
_config: LongtaskInstrumentationConfig; | ||
/** | ||
@@ -12,3 +14,3 @@ * | ||
*/ | ||
constructor(config?: InstrumentationConfig); | ||
constructor(config?: LongtaskInstrumentationConfig); | ||
init(): void; | ||
@@ -15,0 +17,0 @@ private isSupported; |
@@ -0,1 +1,16 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/* | ||
@@ -16,19 +31,5 @@ * Copyright The OpenTelemetry Authors | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { hrTime } from '@opentelemetry/core'; | ||
import { InstrumentationBase, } from '@opentelemetry/instrumentation'; | ||
import { diag } from '@opentelemetry/api'; | ||
import { InstrumentationBase } from '@opentelemetry/instrumentation'; | ||
import { VERSION } from './version'; | ||
@@ -62,2 +63,10 @@ var LONGTASK_PERFORMANCE_TYPE = 'longtask'; | ||
}); | ||
if (this._config.observerCallback) { | ||
try { | ||
this._config.observerCallback(span, { longtaskEntry: entry }); | ||
} | ||
catch (err) { | ||
diag.error('longtask instrumentation: observer callback failed', err); | ||
} | ||
} | ||
span.setAttribute('component', this.component); | ||
@@ -64,0 +73,0 @@ span.setAttribute('longtask.name', entry.name); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.27.0"; | ||
export declare const VERSION = "0.28.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export var VERSION = '0.27.0'; | ||
export var VERSION = '0.28.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,3 @@ | ||
import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation'; | ||
import { InstrumentationBase } from '@opentelemetry/instrumentation'; | ||
import type { LongtaskInstrumentationConfig } from './types'; | ||
export declare class LongTaskInstrumentation extends InstrumentationBase { | ||
@@ -7,2 +8,3 @@ readonly component: string; | ||
private _observer?; | ||
_config: LongtaskInstrumentationConfig; | ||
/** | ||
@@ -12,3 +14,3 @@ * | ||
*/ | ||
constructor(config?: InstrumentationConfig); | ||
constructor(config?: LongtaskInstrumentationConfig); | ||
init(): void; | ||
@@ -15,0 +17,0 @@ private isSupported; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LongTaskInstrumentation = void 0; | ||
/* | ||
@@ -17,5 +19,4 @@ * Copyright The OpenTelemetry Authors | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LongTaskInstrumentation = void 0; | ||
const core_1 = require("@opentelemetry/core"); | ||
const api_1 = require("@opentelemetry/api"); | ||
const instrumentation_1 = require("@opentelemetry/instrumentation"); | ||
@@ -47,2 +48,10 @@ const version_1 = require("./version"); | ||
}); | ||
if (this._config.observerCallback) { | ||
try { | ||
this._config.observerCallback(span, { longtaskEntry: entry }); | ||
} | ||
catch (err) { | ||
api_1.diag.error('longtask instrumentation: observer callback failed', err); | ||
} | ||
} | ||
span.setAttribute('component', this.component); | ||
@@ -49,0 +58,0 @@ span.setAttribute('longtask.name', entry.name); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.27.0"; | ||
export declare const VERSION = "0.28.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.27.0'; | ||
exports.VERSION = '0.28.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/instrumentation-long-task", | ||
"version": "0.27.0", | ||
"version": "0.28.0", | ||
"description": "OpenTelemetry long task API automatic instrumentation package.", | ||
@@ -13,4 +13,3 @@ "main": "build/src/index.js", | ||
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", | ||
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", | ||
"precompile": "tsc --version && lerna run version --scope @opentelemetry/instrumentation-user-interaction --include-filtered-dependencies", | ||
"precompile": "tsc --version && lerna run version --scope @opentelemetry/instrumentation-user-interaction --include-dependencies", | ||
"prewatch": "npm run precompile", | ||
@@ -57,10 +56,10 @@ "version:update": "node ../../../scripts/version-update.js", | ||
"@types/mocha": "7.0.2", | ||
"@types/node": "14.17.9", | ||
"@types/node": "16.11.21", | ||
"@types/sinon": "10.0.2", | ||
"@types/webpack-env": "1.16.2", | ||
"babel-loader": "8.2.2", | ||
"codecov": "3.8.3", | ||
"colors": "1.4.0", | ||
"gts": "3.1.0", | ||
"istanbul-instrumenter-loader": "3.0.1", | ||
"karma": "5.2.3", | ||
"karma": "6.3.16", | ||
"karma-chrome-launcher": "3.1.0", | ||
@@ -75,3 +74,3 @@ "karma-coverage-istanbul-reporter": "3.0.3", | ||
"rimraf": "3.0.2", | ||
"sinon": "12.0.1", | ||
"sinon": "13.0.1", | ||
"ts-loader": "8.3.0", | ||
@@ -94,3 +93,3 @@ "ts-mocha": "8.0.0", | ||
"sideEffects": false, | ||
"gitHead": "b303880b3aea11da779286f92f1e4b8f6393b66f" | ||
"gitHead": "78717b6dda677bf737811c34df21ef0ec88c31a3" | ||
} |
@@ -34,3 +34,5 @@ # OpenTelemetry Long Task Instrumentation for web | ||
instrumentations: [ | ||
new LongTaskInstrumentation(), | ||
new LongTaskInstrumentation({ | ||
// see under for available configuration | ||
}), | ||
], | ||
@@ -40,2 +42,23 @@ }); | ||
### longtask Instrumentation Options | ||
| Options | Type | Description | | ||
| --- | --- | --- | | ||
| `observerCallback` | `ObserverCallback` | Callback executed on observed `longtask`, allowing additional attributes to be attached to the span. | | ||
The `observerCallback` function is passed the created span and the `longtask` `PerformanceEntry`, | ||
allowing the user to add custom attributes to the span with any logic. | ||
For example, a webapp with client-side routing can add contextual information on the current page, | ||
even if the tracer was instantiated before navigation. | ||
Usage Example: | ||
```js | ||
longtaskInstrumentationConfig = { | ||
observerCallback: (span, longtaskEvent) => { | ||
span.setAttribute('location.pathname', window.location.pathname) | ||
} | ||
} | ||
``` | ||
## Useful links | ||
@@ -42,0 +65,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44946
36
389
83