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

@opentelemetry/core

Package Overview
Dependencies
Maintainers
2
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/core - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

3

build/esm/platform/browser/RandomIdGenerator.d.ts
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

var SPAN_ID_BYTES = 8;
var TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
var RandomIdGenerator = /** @class */ (function () {

@@ -4,0 +7,0 @@ function RandomIdGenerator() {

@@ -16,12 +16,35 @@ /*

*/
function intValue(charCode) {
// 0-9
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
// a-f
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
// A-F
return charCode - 55;
}
var buf8 = Buffer.alloc(8);
var buf16 = Buffer.alloc(16);
export function hexToBase64(hexStr) {
var hexStrLen = hexStr.length;
var hexAsciiCharsStr = '';
for (var i = 0; i < hexStrLen; i += 2) {
var hexPair = hexStr.substring(i, i + 2);
var hexVal = parseInt(hexPair, 16);
hexAsciiCharsStr += String.fromCharCode(hexVal);
var buf;
if (hexStr.length === 16) {
buf = buf8;
}
return Buffer.from(hexAsciiCharsStr, 'ascii').toString('base64');
else if (hexStr.length === 32) {
buf = buf16;
}
else {
buf = Buffer.alloc(hexStr.length / 2);
}
var offset = 0;
for (var i = 0; i < hexStr.length; i += 2) {
var hi = intValue(hexStr.charCodeAt(i));
var lo = intValue(hexStr.charCodeAt(i + 1));
buf.writeUInt8((hi << 4) | lo, offset++);
}
return buf.toString('base64');
}
//# sourceMappingURL=hex-to-base64.js.map
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

@@ -18,2 +18,5 @@ /*

var TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
var RandomIdGenerator = /** @class */ (function () {

@@ -20,0 +23,0 @@ function RandomIdGenerator() {

5

build/esm/trace/IdGenerator.d.ts

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

/** IdGenerator provides an interface for generating Trace Id and Span Id */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* IdGenerator provides an interface for generating Trace Id and Span Id.
*/
export interface IdGenerator {

@@ -3,0 +6,0 @@ /** Returns a trace ID composed of 32 lowercase hex characters. */

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
export declare class AlwaysOffSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

import { SamplingDecision } from '@opentelemetry/api';
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
var AlwaysOffSampler = /** @class */ (function () {

@@ -20,0 +23,0 @@ function AlwaysOffSampler() {

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
export declare class AlwaysOnSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

import { SamplingDecision } from '@opentelemetry/api';
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
var AlwaysOnSampler = /** @class */ (function () {

@@ -20,0 +23,0 @@ function AlwaysOnSampler() {

import { Context, Link, Sampler, SamplingResult, SpanAttributes, SpanKind } from '@opentelemetry/api';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -4,0 +5,0 @@ * or delegates to `delegateSampler` for root spans.

@@ -21,2 +21,3 @@ /*

/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -23,0 +24,0 @@ * or delegates to `delegateSampler` for root spans.

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
export declare class TraceIdRatioBasedSampler implements Sampler {

@@ -4,0 +7,0 @@ private readonly _ratio;

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

import { SamplingDecision, isValidTraceId, } from '@opentelemetry/api';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
var TraceIdRatioBasedSampler = /** @class */ (function () {

@@ -20,0 +23,0 @@ function TraceIdRatioBasedSampler(_ratio) {

@@ -67,3 +67,8 @@ import { DiagLogLevel } from '@opentelemetry/api';

export declare function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT;
/**
* Get environment in node or browser without
* populating default values.
*/
export declare function getEnvWithoutDefaults(): ENVIRONMENT;
export {};
//# sourceMappingURL=environment.d.ts.map

@@ -18,2 +18,3 @@ /*

import { TracesSamplerValues } from './sampling';
import { _globalThis } from '../platform/browser/globalThis';
var DEFAULT_LIST_SEPARATOR = ',';

@@ -204,2 +205,11 @@ /**

}
/**
* Get environment in node or browser without
* populating default values.
*/
export function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(_globalThis);
}
//# sourceMappingURL=environment.js.map

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '1.5.0';
export var VERSION = '1.6.0';
//# sourceMappingURL=version.js.map
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

const SPAN_ID_BYTES = 8;
const TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export class RandomIdGenerator {

@@ -4,0 +7,0 @@ constructor() {

@@ -16,12 +16,35 @@ /*

*/
function intValue(charCode) {
// 0-9
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
// a-f
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
// A-F
return charCode - 55;
}
const buf8 = Buffer.alloc(8);
const buf16 = Buffer.alloc(16);
export function hexToBase64(hexStr) {
const hexStrLen = hexStr.length;
let hexAsciiCharsStr = '';
for (let i = 0; i < hexStrLen; i += 2) {
const hexPair = hexStr.substring(i, i + 2);
const hexVal = parseInt(hexPair, 16);
hexAsciiCharsStr += String.fromCharCode(hexVal);
let buf;
if (hexStr.length === 16) {
buf = buf8;
}
return Buffer.from(hexAsciiCharsStr, 'ascii').toString('base64');
else if (hexStr.length === 32) {
buf = buf16;
}
else {
buf = Buffer.alloc(hexStr.length / 2);
}
let offset = 0;
for (let i = 0; i < hexStr.length; i += 2) {
const hi = intValue(hexStr.charCodeAt(i));
const lo = intValue(hexStr.charCodeAt(i + 1));
buf.writeUInt8((hi << 4) | lo, offset++);
}
return buf.toString('base64');
}
//# sourceMappingURL=hex-to-base64.js.map
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

@@ -18,2 +18,5 @@ /*

const TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export class RandomIdGenerator {

@@ -20,0 +23,0 @@ constructor() {

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

/** IdGenerator provides an interface for generating Trace Id and Span Id */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* IdGenerator provides an interface for generating Trace Id and Span Id.
*/
export interface IdGenerator {

@@ -3,0 +6,0 @@ /** Returns a trace ID composed of 32 lowercase hex characters. */

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
export declare class AlwaysOffSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

import { SamplingDecision } from '@opentelemetry/api';
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
export class AlwaysOffSampler {

@@ -20,0 +23,0 @@ shouldSample() {

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
export declare class AlwaysOnSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

import { SamplingDecision } from '@opentelemetry/api';
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
export class AlwaysOnSampler {

@@ -20,0 +23,0 @@ shouldSample() {

import { Context, Link, Sampler, SamplingResult, SpanAttributes, SpanKind } from '@opentelemetry/api';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -4,0 +5,0 @@ * or delegates to `delegateSampler` for root spans.

@@ -21,2 +21,3 @@ /*

/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -23,0 +24,0 @@ * or delegates to `delegateSampler` for root spans.

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
export declare class TraceIdRatioBasedSampler implements Sampler {

@@ -4,0 +7,0 @@ private readonly _ratio;

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

import { SamplingDecision, isValidTraceId, } from '@opentelemetry/api';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
export class TraceIdRatioBasedSampler {

@@ -20,0 +23,0 @@ constructor(_ratio = 0) {

@@ -67,3 +67,8 @@ import { DiagLogLevel } from '@opentelemetry/api';

export declare function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT;
/**
* Get environment in node or browser without
* populating default values.
*/
export declare function getEnvWithoutDefaults(): ENVIRONMENT;
export {};
//# sourceMappingURL=environment.d.ts.map

@@ -18,2 +18,3 @@ /*

import { TracesSamplerValues } from './sampling';
import { _globalThis } from '../platform/browser/globalThis';
const DEFAULT_LIST_SEPARATOR = ',';

@@ -201,2 +202,11 @@ /**

}
/**
* Get environment in node or browser without
* populating default values.
*/
export function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(_globalThis);
}
//# sourceMappingURL=environment.js.map

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '1.5.0';
export const VERSION = '1.6.0';
//# sourceMappingURL=version.js.map
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

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

const TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
class RandomIdGenerator {

@@ -8,0 +11,0 @@ constructor() {

@@ -19,13 +19,36 @@ "use strict";

*/
function intValue(charCode) {
// 0-9
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
// a-f
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
// A-F
return charCode - 55;
}
const buf8 = Buffer.alloc(8);
const buf16 = Buffer.alloc(16);
function hexToBase64(hexStr) {
const hexStrLen = hexStr.length;
let hexAsciiCharsStr = '';
for (let i = 0; i < hexStrLen; i += 2) {
const hexPair = hexStr.substring(i, i + 2);
const hexVal = parseInt(hexPair, 16);
hexAsciiCharsStr += String.fromCharCode(hexVal);
let buf;
if (hexStr.length === 16) {
buf = buf8;
}
return Buffer.from(hexAsciiCharsStr, 'ascii').toString('base64');
else if (hexStr.length === 32) {
buf = buf16;
}
else {
buf = Buffer.alloc(hexStr.length / 2);
}
let offset = 0;
for (let i = 0; i < hexStr.length; i += 2) {
const hi = intValue(hexStr.charCodeAt(i));
const lo = intValue(hexStr.charCodeAt(i + 1));
buf.writeUInt8((hi << 4) | lo, offset++);
}
return buf.toString('base64');
}
exports.hexToBase64 = hexToBase64;
//# sourceMappingURL=hex-to-base64.js.map
import { IdGenerator } from '../../trace/IdGenerator';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
export declare class RandomIdGenerator implements IdGenerator {

@@ -3,0 +6,0 @@ /**

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

const TRACE_ID_BYTES = 16;
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
*/
class RandomIdGenerator {

@@ -23,0 +26,0 @@ constructor() {

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

/** IdGenerator provides an interface for generating Trace Id and Span Id */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* IdGenerator provides an interface for generating Trace Id and Span Id.
*/
export interface IdGenerator {

@@ -3,0 +6,0 @@ /** Returns a trace ID composed of 32 lowercase hex characters. */

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
export declare class AlwaysOffSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

const api_1 = require("@opentelemetry/api");
/** Sampler that samples no traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples no traces.
*/
class AlwaysOffSampler {

@@ -23,0 +26,0 @@ shouldSample() {

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
export declare class AlwaysOnSampler implements Sampler {

@@ -4,0 +7,0 @@ shouldSample(): SamplingResult;

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

const api_1 = require("@opentelemetry/api");
/** Sampler that samples all traces. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples all traces.
*/
class AlwaysOnSampler {

@@ -23,0 +26,0 @@ shouldSample() {

import { Context, Link, Sampler, SamplingResult, SpanAttributes, SpanKind } from '@opentelemetry/api';
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -4,0 +5,0 @@ * or delegates to `delegateSampler` for root spans.

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

/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* A composite sampler that either respects the parent span's sampling decision

@@ -26,0 +27,0 @@ * or delegates to `delegateSampler` for root spans.

import { Sampler, SamplingResult } from '@opentelemetry/api';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
export declare class TraceIdRatioBasedSampler implements Sampler {

@@ -4,0 +7,0 @@ private readonly _ratio;

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

const api_1 = require("@opentelemetry/api");
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
/**
* @deprecated Use the one defined in @opentelemetry/sdk-trace-base instead.
* Sampler that samples a given fraction of traces based of trace id deterministically.
*/
class TraceIdRatioBasedSampler {

@@ -23,0 +26,0 @@ constructor(_ratio = 0) {

@@ -67,3 +67,8 @@ import { DiagLogLevel } from '@opentelemetry/api';

export declare function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT;
/**
* Get environment in node or browser without
* populating default values.
*/
export declare function getEnvWithoutDefaults(): ENVIRONMENT;
export {};
//# sourceMappingURL=environment.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseEnvironment = exports.DEFAULT_ENVIRONMENT = exports.DEFAULT_ATTRIBUTE_COUNT_LIMIT = exports.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = void 0;
exports.getEnvWithoutDefaults = exports.parseEnvironment = exports.DEFAULT_ENVIRONMENT = exports.DEFAULT_ATTRIBUTE_COUNT_LIMIT = exports.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = void 0;
const api_1 = require("@opentelemetry/api");
const sampling_1 = require("./sampling");
const globalThis_1 = require("../platform/browser/globalThis");
const DEFAULT_LIST_SEPARATOR = ',';

@@ -205,2 +206,12 @@ /**

exports.parseEnvironment = parseEnvironment;
/**
* Get environment in node or browser without
* populating default values.
*/
function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(globalThis_1._globalThis);
}
exports.getEnvWithoutDefaults = getEnvWithoutDefaults;
//# sourceMappingURL=environment.js.map

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '1.5.0';
exports.VERSION = '1.6.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/core",
"version": "1.5.0",
"version": "1.6.0",
"description": "OpenTelemetry Core provides constants and utilities shared by all OpenTelemetry SDK packages.",

@@ -67,6 +67,6 @@ "main": "build/src/index.js",

"devDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.2.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
"@opentelemetry/api": ">=1.0.0 <1.3.0",
"@types/mocha": "9.1.1",
"@types/node": "18.6.5",
"@types/sinon": "10.0.13",
"@types/webpack-env": "1.16.3",

@@ -81,9 +81,9 @@ "codecov": "3.8.3",

"karma-webpack": "4.0.2",
"lerna": "3.22.1",
"mocha": "7.2.0",
"lerna": "5.4.3",
"mocha": "10.0.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "9.0.2",
"sinon": "14.0.0",
"ts-loader": "8.4.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4",

@@ -93,9 +93,9 @@ "webpack": "4.46.0"

"peerDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.2.0"
"@opentelemetry/api": ">=1.0.0 <1.3.0"
},
"dependencies": {
"@opentelemetry/semantic-conventions": "1.5.0"
"@opentelemetry/semantic-conventions": "1.6.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core",
"gitHead": "776656b6e0cd0fc49a52b734702bc77110e483f1"
"gitHead": "a5abee69119cc41d9d34f6beb5c1826eef1ac0dd"
}

@@ -16,7 +16,2 @@ # OpenTelemetry Core

- [Baggage Propagator](#baggage-propagator)
- [Built-in Sampler](#built-in-sampler)
- [AlwaysOn Sampler](#alwayson-sampler)
- [AlwaysOff Sampler](#alwaysoff-sampler)
- [TraceIdRatioBased Sampler](#traceidratiobased-sampler)
- [ParentBased Sampler](#parentbased-sampler)
- [Useful links](#useful-links)

@@ -65,103 +60,2 @@ - [License](#license)

### Built-in Sampler
Sampler is used to make decisions on `Span` sampling.
#### AlwaysOn Sampler
Samples every trace regardless of upstream sampling decisions.
> This is used as a default Sampler
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { AlwaysOnSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new AlwaysOnSampler()
});
```
#### AlwaysOff Sampler
Doesn't sample any trace, regardless of upstream sampling decisions.
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { AlwaysOffSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new AlwaysOffSampler()
});
```
#### TraceIdRatioBased Sampler
Samples some percentage of traces, calculated deterministically using the trace ID.
Any trace that would be sampled at a given percentage will also be sampled at any higher percentage.
The `TraceIDRatioSampler` may be used with the `ParentBasedSampler` to respect the sampled flag of an incoming trace.
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { TraceIdRatioBasedSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
// See details of ParentBasedSampler below
sampler: new ParentBasedSampler({
// Trace ID Ratio Sampler accepts a positional argument
// which represents the percentage of traces which should
// be sampled.
root: new TraceIdRatioBasedSampler(0.5)
});
});
```
#### ParentBased Sampler
- This is a composite sampler. `ParentBased` helps distinguished between the
following cases:
- No parent (root span).
- Remote parent with `sampled` flag `true`
- Remote parent with `sampled` flag `false`
- Local parent with `sampled` flag `true`
- Local parent with `sampled` flag `false`
Required parameters:
- `root(Sampler)` - Sampler called for spans with no parent (root spans)
Optional parameters:
- `remoteParentSampled(Sampler)` (default: `AlwaysOn`)
- `remoteParentNotSampled(Sampler)` (default: `AlwaysOff`)
- `localParentSampled(Sampler)` (default: `AlwaysOn`)
- `localParentNotSampled(Sampler)` (default: `AlwaysOff`)
|Parent| parent.isRemote() | parent.isSampled()| Invoke sampler|
|--|--|--|--|
|absent| n/a | n/a |`root()`|
|present|true|true|`remoteParentSampled()`|
|present|true|false|`remoteParentNotSampled()`|
|present|false|true|`localParentSampled()`|
|present|false|false|`localParentNotSampled()`|
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { ParentBasedSampler, AlwaysOffSampler, TraceIdRatioBasedSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new ParentBasedSampler({
// By default, the ParentBasedSampler will respect the parent span's sampling
// decision. This is configurable by providing a different sampler to use
// based on the situation. See configuration details above.
//
// This will delegate the sampling decision of all root traces (no parent)
// to the TraceIdRatioBasedSampler.
// See details of TraceIdRatioBasedSampler above.
root: new TraceIdRatioBasedSampler(0.5)
})
});
```
## Useful links

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

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

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

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

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