Skip to content

Commit d31d0e9

Browse files
authored
Merge branch 'main' into esm-builds
2 parents 4709d50 + d3989d3 commit d31d0e9

File tree

83 files changed

+1194
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1194
-359
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ To request automatic tracing support for a module not on this list, please [file
245245

246246
## Upgrade guidelines
247247

248-
### 0.19.0 to 1.0.0-rc.0
248+
### 0.18.x to 0.19.0
249249

250250
- All plugins have been removed in favor of instrumentations.
251251

252-
### 0.18.0 to 0.19.0
253-
254252
- The `@opentelemetry/propagator-b3` package previously exported three propagators: `B3Propagator`,`B3SinglePropagator`, and `B3MultiPropagator`, but now only exports the `B3Propagator`. It extracts b3 context in single and multi-header encodings, and injects context using the single-header encoding by default, but can be configured to inject context using the multi-header endcoding during construction: `new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })`. If you were previously using the `B3SinglePropagator` or `B3MultiPropagator` directly, you should update your code to use the `B3Propagator` with the appropriate configuration. See the [readme](./packages/opentelemetry-propagator-b3/readme.md) for full details and usage.
255253

254+
- Sampling configuration via environment variable has changed. If you were using `OTEL_SAMPLING_PROBABILITY` then you should replace it with `OTEL_TRACES_SAMPLER=parentbased_traceidratio` and `OTEL_TRACES_SAMPLER_ARG=<number>` where `<number>` is a number in the [0..1] range, e.g. "0.25". Default is 1.0 if unset.
255+
256256
### 0.17.0 to 0.18.0
257257

258258
- `diag.setLogLevel` is removed and LogLevel can be set by an optional second parameter to `setLogger`

backwards-compatability/node10/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"test:backcompat": "tsc --noEmit index.ts"
99
},
1010
"dependencies": {
11-
"@opentelemetry/sdk-node": "^0.18.2",
12-
"@opentelemetry/tracing": "^0.18.2"
11+
"@opentelemetry/sdk-node": "0.18.2",
12+
"@opentelemetry/tracing": "0.18.2"
1313
},
1414
"devDependencies": {
1515
"@types/node": "10.17.56",
16-
"typescript": "4.2.3"
16+
"typescript": "4.2.4"
1717
},
1818
"author": "OpenTelemetry Authors",
1919
"license": "Apache-2.0"

backwards-compatability/node12/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"test:backcompat": "tsc --noEmit index.ts"
99
},
1010
"dependencies": {
11-
"@opentelemetry/sdk-node": "^0.18.2",
12-
"@opentelemetry/tracing": "^0.18.2"
11+
"@opentelemetry/sdk-node": "0.18.2",
12+
"@opentelemetry/tracing": "0.18.2"
1313
},
1414
"devDependencies": {
1515
"@types/node": "12.20.7",
16-
"typescript": "4.2.3"
16+
"typescript": "4.2.4"
1717
},
1818
"author": "OpenTelemetry Authors",
1919
"license": "Apache-2.0"

backwards-compatability/node8/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"test:backcompat": "tsc --noEmit index.ts"
99
},
1010
"dependencies": {
11-
"@opentelemetry/sdk-node": "^0.18.2",
12-
"@opentelemetry/tracing": "^0.18.2"
11+
"@opentelemetry/sdk-node": "0.18.2",
12+
"@opentelemetry/tracing": "0.18.2"
1313
},
1414
"devDependencies": {
1515
"@types/node": "8.10.66",
16-
"typescript": "4.2.3"
16+
"typescript": "4.2.4"
1717
},
1818
"author": "OpenTelemetry Authors",
1919
"license": "Apache-2.0"

eslint.config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ module.exports = {
44
"header"
55
],
66
extends: [
7-
"./node_modules/gts",
7+
"./node_modules/gts",
88
],
99
parser: "@typescript-eslint/parser",
1010
parserOptions: {
11-
"project": "./tsconfig.json"
11+
"project": "./tsconfig.json"
1212
},
1313
rules: {
14+
"@typescript-eslint/no-floating-promises": 2,
1415
"@typescript-eslint/no-this-alias": "off",
1516
"eqeqeq": [
1617
"error",
1718
"smart"
1819
],
1920
"prefer-rest-params": "off",
2021
"@typescript-eslint/naming-convention": [
21-
"error",
22-
{
23-
"selector": "memberLike",
24-
"modifiers": ["private", "protected"],
25-
"format": ["camelCase"],
26-
"leadingUnderscore": "require"
27-
}
22+
"error",
23+
{
24+
"selector": "memberLike",
25+
"modifiers": ["private", "protected"],
26+
"format": ["camelCase"],
27+
"leadingUnderscore": "require"
28+
}
2829
],
2930
"no-console": "error",
3031
"no-shadow": "off",
@@ -35,8 +36,8 @@ module.exports = {
3536
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
3637
"node/no-deprecated-api": ["warn"],
3738
"header/header": [2, "block", [{
38-
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
39-
template:
39+
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
40+
template:
4041
`\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n `
4142
}]]
4243
},
@@ -48,6 +49,7 @@ module.exports = {
4849
"@typescript-eslint/ban-ts-ignore": "off",
4950
"@typescript-eslint/no-empty-function": "off",
5051
"@typescript-eslint/no-explicit-any": "off",
52+
"@typescript-eslint/no-floating-promises": 1,
5153
"@typescript-eslint/no-unused-vars": "off",
5254
"@typescript-eslint/no-var-requires": "off",
5355
"@typescript-eslint/no-shadow": ["off"],

examples/grpc-js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
2929
},
3030
"dependencies": {
31-
"@grpc/grpc-js": "^1.0.5",
31+
"@grpc/grpc-js": "^1.2.12",
3232
"@opentelemetry/api": "^1.0.0-rc.0",
3333
"@opentelemetry/exporter-jaeger": "^0.18.2",
3434
"@opentelemetry/exporter-zipkin": "^0.18.2",

examples/tracer-web/examples/zipkin/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
44

55
const provider = new WebTracerProvider();
66
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
7-
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter()));
7+
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
8+
// testing interceptor
9+
// getExportRequestHeaders: ()=> {
10+
// return {
11+
// foo: 'bar',
12+
// }
13+
// }
14+
})));
815

916
provider.register();
1017

integration-tests/propagation-validation-server/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
"compile": "tsc --build"
1212
},
1313
"dependencies": {
14-
"@opentelemetry/context-async-hooks": "^0.18.2",
15-
"@opentelemetry/core": "^0.18.2",
16-
"@opentelemetry/tracing": "^0.18.2",
14+
"@opentelemetry/context-async-hooks": "0.18.2",
15+
"@opentelemetry/core": "0.18.2",
16+
"@opentelemetry/tracing": "0.18.2",
1717
"axios": "0.21.1",
1818
"body-parser": "1.19.0",
1919
"express": "4.17.1"
2020
},
2121
"devDependencies": {
2222
"@opentelemetry/api": "^1.0.0-rc.0",
23-
"typescript": "4.2.3"
23+
"typescript": "4.2.4"
2424
},
2525
"peerDependencies": {
2626
"@opentelemetry/api": "^1.0.0-rc.0"

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
"author": "OpenTelemetry Authors",
4646
"license": "Apache-2.0",
4747
"devDependencies": {
48-
"@commitlint/cli": "12.0.1",
49-
"@commitlint/config-conventional": "12.0.1",
50-
"@typescript-eslint/eslint-plugin": "4.20.0",
51-
"@typescript-eslint/parser": "4.20.0",
48+
"@commitlint/cli": "12.1.1",
49+
"@commitlint/config-conventional": "12.1.1",
50+
"@typescript-eslint/eslint-plugin": "4.22.0",
51+
"@typescript-eslint/parser": "4.22.0",
5252
"beautify-benchmark": "0.2.4",
5353
"benchmark": "2.1.4",
54-
"eslint": "7.23.0",
54+
"eslint": "7.24.0",
5555
"eslint-config-airbnb-base": "14.2.1",
5656
"eslint-plugin-header": "3.1.1",
5757
"eslint-plugin-import": "2.22.1",
@@ -61,8 +61,8 @@
6161
"lerna": "3.22.1",
6262
"lerna-changelog": "1.0.1",
6363
"markdownlint-cli": "0.27.1",
64-
"typescript": "4.2.3",
65-
"update-ts-references": "2.0.0"
64+
"typescript": "4.2.4",
65+
"update-ts-references": "2.3.0"
6666
},
6767
"husky": {
6868
"hooks": {

packages/opentelemetry-api-metrics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"nyc": "15.1.0",
7474
"ts-loader": "8.1.0",
7575
"ts-mocha": "8.0.0",
76-
"typescript": "4.2.3",
76+
"typescript": "4.2.4",
7777
"webpack": "4.46.0"
7878
}
7979
}

packages/opentelemetry-context-async-hooks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"rimraf": "3.0.2",
5252
"ts-mocha": "8.0.0",
5353
"ts-node": "9.1.1",
54-
"typescript": "4.2.3"
54+
"typescript": "4.2.4"
5555
},
5656
"peerDependencies": {
5757
"@opentelemetry/api": "^1.0.0-rc.0"

packages/opentelemetry-context-zone-peer-dep/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"access": "public"
4646
},
4747
"devDependencies": {
48-
"@babel/core": "7.13.14",
48+
"@babel/core": "7.13.15",
4949
"@opentelemetry/api": "^1.0.0-rc.0",
5050
"@types/mocha": "8.2.2",
5151
"@types/node": "14.14.37",
@@ -69,7 +69,7 @@
6969
"ts-loader": "8.1.0",
7070
"ts-mocha": "8.0.0",
7171
"ts-node": "9.1.1",
72-
"typescript": "4.2.3",
72+
"typescript": "4.2.4",
7373
"webpack": "4.46.0",
7474
"webpack-cli": "4.6.0",
7575
"zone.js": "0.11.4"

packages/opentelemetry-context-zone/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"access": "public"
4343
},
4444
"devDependencies": {
45-
"@babel/core": "7.13.14",
45+
"@babel/core": "7.13.15",
4646
"@types/mocha": "8.2.2",
4747
"@types/node": "14.14.37",
4848
"@types/sinon": "9.0.11",
@@ -62,13 +62,13 @@
6262
"ts-loader": "8.1.0",
6363
"ts-mocha": "8.0.0",
6464
"ts-node": "9.1.1",
65-
"typescript": "4.2.3",
65+
"typescript": "4.2.4",
6666
"webpack": "4.46.0",
6767
"webpack-cli": "4.6.0",
6868
"webpack-merge": "5.7.3"
6969
},
7070
"dependencies": {
71-
"@opentelemetry/context-zone-peer-dep": "^0.18.2",
71+
"@opentelemetry/context-zone-peer-dep": "0.18.2",
7272
"zone.js": "^0.11.0"
7373
},
7474
"sideEffects": true

packages/opentelemetry-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
"devDependencies": {
5858
"@opentelemetry/api": "^1.0.0-rc.0",
59-
"@opentelemetry/propagator-b3": "^0.18.2",
59+
"@opentelemetry/propagator-b3": "0.18.2",
6060
"@types/mocha": "8.2.2",
6161
"@types/node": "14.14.37",
6262
"@types/semver": "7.3.4",
@@ -78,7 +78,7 @@
7878
"ts-loader": "8.1.0",
7979
"ts-mocha": "8.0.0",
8080
"ts-node": "9.1.1",
81-
"typescript": "4.2.3",
81+
"typescript": "4.2.4",
8282
"webpack": "4.46.0"
8383
},
8484
"peerDependencies": {

packages/opentelemetry-core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ export * from './trace/TraceState';
3434
export * from './trace/IdGenerator';
3535
export * from './utils/url';
3636
export * from './utils/wrap';
37+
export * from './utils/sampling';

packages/opentelemetry-core/src/utils/environment.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { DiagLogLevel } from '@opentelemetry/api';
18+
import { TracesSamplerValues } from './sampling';
1819

1920
const DEFAULT_LIST_SEPARATOR = ',';
2021

@@ -27,7 +28,6 @@ const ENVIRONMENT_NUMBERS_KEYS = [
2728
'OTEL_BSP_MAX_EXPORT_BATCH_SIZE',
2829
'OTEL_BSP_MAX_QUEUE_SIZE',
2930
'OTEL_BSP_SCHEDULE_DELAY',
30-
'OTEL_SAMPLING_PROBABILITY',
3131
'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT',
3232
'OTEL_SPAN_EVENT_COUNT_LIMIT',
3333
'OTEL_SPAN_LINK_COUNT_LIMIT',
@@ -67,8 +67,11 @@ export type ENVIRONMENT = {
6767
OTEL_EXPORTER_JAEGER_ENDPOINT?: string;
6868
OTEL_EXPORTER_JAEGER_PASSWORD?: string;
6969
OTEL_EXPORTER_JAEGER_USER?: string;
70+
OTEL_EXPORTER_ZIPKIN_ENDPOINT?: string;
7071
OTEL_LOG_LEVEL?: DiagLogLevel;
7172
OTEL_RESOURCE_ATTRIBUTES?: string;
73+
OTEL_TRACES_SAMPLER_ARG?: string;
74+
OTEL_TRACES_SAMPLER?: string;
7275
} & ENVIRONMENT_NUMBERS &
7376
ENVIRONMENT_LISTS;
7477

@@ -94,14 +97,16 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
9497
OTEL_EXPORTER_JAEGER_ENDPOINT: '',
9598
OTEL_EXPORTER_JAEGER_PASSWORD: '',
9699
OTEL_EXPORTER_JAEGER_USER: '',
100+
OTEL_EXPORTER_ZIPKIN_ENDPOINT: 'http://localhost:9411/api/v2/spans',
97101
OTEL_LOG_LEVEL: DiagLogLevel.INFO,
98102
OTEL_NO_PATCH_MODULES: [],
99103
OTEL_PROPAGATORS: ['tracecontext', 'baggage'],
100104
OTEL_RESOURCE_ATTRIBUTES: '',
101-
OTEL_SAMPLING_PROBABILITY: 1,
102-
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: 1000,
103-
OTEL_SPAN_EVENT_COUNT_LIMIT: 1000,
104-
OTEL_SPAN_LINK_COUNT_LIMIT: 1000,
105+
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: 128,
106+
OTEL_SPAN_EVENT_COUNT_LIMIT: 128,
107+
OTEL_SPAN_LINK_COUNT_LIMIT: 128,
108+
OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,
109+
OTEL_TRACES_SAMPLER_ARG: '',
105110
};
106111

107112
/**
@@ -194,10 +199,6 @@ export function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT {
194199
const key = env as keyof ENVIRONMENT;
195200

196201
switch (key) {
197-
case 'OTEL_SAMPLING_PROBABILITY':
198-
parseNumber(key, environment, values, 0, 1);
199-
break;
200-
201202
case 'OTEL_LOG_LEVEL':
202203
setLogLevelFromEnv(key, environment, values);
203204
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export enum TracesSamplerValues {
18+
AlwaysOff = 'always_off',
19+
AlwaysOn = 'always_on',
20+
ParentBasedAlwaysOff = 'parentbased_always_off',
21+
ParentBasedAlwaysOn = 'parentbased_always_on',
22+
ParentBasedTraceIdRatio = 'parentbased_traceidratio',
23+
TraceIdRatio = 'traceidratio',
24+
}

0 commit comments

Comments
 (0)