Skip to content

Commit e99a273

Browse files
authored
Merge branch 'main' into main
2 parents 7c0fd76 + f86251d commit e99a273

29 files changed

+742
-292
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,21 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
1111

1212
### :rocket: (Enhancement)
1313

14+
* feat(sdk-metrics): allow single bucket histograms [#4456](https://github.com/open-telemetry/opentelemetry-js/pull/4456) @pichlermarc
1415
* feat(instrumentation): Make `init()` method public [#4418](https://github.com/open-telemetry/opentelemetry-js/pull/4418)
1516

1617
### :bug: (Bug Fix)
1718

19+
* fix(sdk-metrics): handle zero bucket counts in exponential histogram merge [#4459](https://github.com/open-telemetry/opentelemetry-js/pull/4459) @mwear
20+
* fix(sdk-metrics): ignore `NaN` value recordings in Histograms [#4455](https://github.com/open-telemetry/opentelemetry-js/pull/4455) @pichlermarc
21+
* fixes a bug where recording `NaN` on a histogram would result in the sum of bucket count values not matching the overall count
22+
* fix(sdk-metrics): allow single bucket histograms [#4456](https://github.com/open-telemetry/opentelemetry-js/pull/4456) @pichlermarc
23+
* fixes a bug where `Meter.createHistogram()` with the advice `explicitBucketBoundaries: []` would throw
24+
1825
### :books: (Refine Doc)
1926

27+
* docs: shorten readme sections [#4460](https://github.com/open-telemetry/opentelemetry-js/pull/4460) @legendecas
28+
2029
### :house: (Internal)
2130

2231
## 1.21.0

README.md

+28-276
Large diffs are not rendered by default.
File renamed without changes.

doc/GUIDELINES.md renamed to doc/contributing/dependencies.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# OpenTelemetry JS Code Contribution Guide
2-
3-
This document outlines the essential guidelines for contributing code to the OpenTelemetry JS repository. These guidelines are designed to ensure consistency, stability, and the highest quality of code across the project.
4-
5-
## Dependencies
1+
# OpenTelemetry Dependencies
62

73
This section refers to `"dependencies"` and `"devDependencies"` entries in `package.json` file.
84
> [!IMPORTANT]
95
> Not all libraries follow [Semantic Versioning](https://semver.org/). Even those who do might occasionally introduce breaking changes due to human errors. Exceptions to the guidelines in this document MAY be granted by Approvers or Maintainers to work around this.
106
11-
### Development Dependencies
7+
## Development Dependencies
128

139
`"devDependencies"` SHOULD be pinned to reduce the risk of autobreaking the build. Since we cannot use the `package-lock.json` file (because the libraries are distributed without it), control over the version our contributors will get is limited. By using pinned versions, we prevent potential disruptions caused by unpinned versions.
1410

@@ -17,15 +13,15 @@ This section refers to `"dependencies"` and `"devDependencies"` entries in `pack
1713
> [!NOTE]
1814
> As this approach might leave our project with outdated tooling, we adopt `renovate-bot`. This automated dependency update tool proactively opens pull requests upon the release of new patch/minor/major versions. The complete configuration for renovate-bot can be found in [renovate.json](../renovate.json) file.
1915
20-
### @opentelemetry/* dependencies
16+
## @opentelemetry/* dependencies
2117

2218
All packages from the `@opentelemetry/` namespace MUST have the same pinned version, as these dependencies are automatically updated on each release by lerna.
2319

2420
**Example:** all packages under `packages/` should consistently maintain the same version, as should those under `experimental/packages/`.
2521

2622
An exception is granted for dependencies on `@opentelemetry/api`, which, if used by the package SHOULD NOT be included as a `dependency`. `@opentelemetry/api` SHOULD be included as a `peerDependency` instead. The version range of the `peerDependency` SHOULD reflect the minimum supported, and SHOULD NOT allow versions greater than the latest released minor version.
2723

28-
### Third-Party Library Dependencies
24+
## Third-Party Library Dependencies
2925

3026
Packages categorized as third-party and listed under the `"dependencies"` section (e.g., @grpc/grpc-js, @grpc/proto-loader, shimmer, etc.) should remain unpinned and utilize the caret (`^`) symbol. This approach offers several advantages:
3127

File renamed without changes.
File renamed without changes.

doc/upgrade-guide.md

+257
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
# Upgrade guidelines
2+
3+
## 0.37.x to 0.38.0
4+
5+
- `@opentelemetry/sdk-node` `NodeSDKConfiguration.defaultAttributes` has been unused and was removed as the concept does not exist in OpenTelemetry anymore
6+
- Please use `NodeSDKConfiguration.resource` instead.
7+
8+
## 0.35.x to 0.36.0
9+
10+
- `@opentelemetry/sdk-node` changed `await start()` to now be synchronous
11+
- `@opentelemetry/sdk-node` changed `await detectResources()` to now be synchronous
12+
13+
## 0.28.x to 0.29.x
14+
15+
- `@opentelemetry/exporter-trace-otlp-http` is now exporting `scopeSpans` instead of `instrumentationLibrarySpans`
16+
- this exporter now requires collector version `0.48` and up.
17+
- `@opentelemetry/exporter-metrics-otlp-http` is now exporting `scopeMetrics` instead of `instrumentationLibraryMetrics`
18+
- this exporter now requires collector version `0.48` and up.
19+
20+
## 0.27.x to 0.28.x
21+
22+
- In `@opentelemetry/exporter-trace-otlp-http`, `OTLPExporterBase._isShutdown` is replaced with `_shutdownOnce`.
23+
24+
## 0.26.x to 0.27.x
25+
26+
Metric and trace exporters are split into separate packages:
27+
28+
- `@opentelemetry/exporter-otlp-http` => `@opentelemetry/exporter-trace-otlp-http` and `@opentelemetry/exporter-metrics-otlp-http`
29+
- `@opentelemetry/exporter-otlp-grpc` => `@opentelemetry/exporter-trace-otlp-grpc` and `@opentelemetry/exporter-metrics-otlp-grpc`
30+
- `@opentelemetry/exporter-otlp-proto` => `@opentelemetry/exporter-trace-otlp-proto` and `@opentelemetry/exporter-metrics-otlp-proto`
31+
32+
Metric types are renamed:
33+
34+
- `@openetelemetry/api-metrics`
35+
- `Meter`
36+
- `createValueRecorder` => `createHistogram`
37+
- `createValueObserver` => `createObservableGauge`
38+
- `createSumObserver` => `createObservableCounter`
39+
- `createUpDownSumObserver` => `createObservableUpDownCounter`
40+
- `ValueRecorder` => `Histogram`
41+
- `ValueObserver` => `ObservableGauge`
42+
- `SumObserver` => `ObservableCounter`
43+
- `UpDownSumObserver` => `ObservableUpDownCounter`
44+
- `ObserverResult` => `ObservableResult`
45+
- `Observation.observer` => `Observation.observable`
46+
- `@opentelemetry/sdk-metrics-base`
47+
- `MetricKind`
48+
- `VALUE_RECORDER` => `HISTOGRAM`
49+
- `SUM_OBSERVER` => `OBSERVABLE_COUNTER`
50+
- `UP_DOWN_SUM_OBSERVER` => `OBSERVABLE_UP_DOWN_COUNTER`
51+
- `VALUE_OBSERVER` => `OBSERVABLE_GAUGE`
52+
53+
## 0.25.x to 1.x.y
54+
55+
Collector exporter packages and types are renamed:
56+
57+
- `@opentelemetry/exporter-collector` => `@opentelemetry/exporter-otlp-http`
58+
- `CollectorExporterBase` => `OTLPExporterBase`
59+
- `CollectorTraceExporter` => `OTLPTraceExporter`
60+
- `CollectorMetricExporter` => `OTLPMetricExporter`
61+
- `CollectorExporterBrowserBase` => `OTLPExporterBrowserBase`
62+
- `CollectorExporterNodeBase` => `OTLPExporterNodeBase`
63+
- `CollectorExporterConfigBase` => `OTLPExporterConfigBase`
64+
- `CollectorExporterError` => `OTLPExporterError`
65+
- `COLLECTOR_SPAN_KIND_MAPPING` => `OTLP_SPAN_KIND_MAPPING`
66+
- `collectorTypes` => `otlpTypes`
67+
- `@opentelemetry/exporter-collector-grpc` => `@opentelemetry/exporter-otlp-grpc`
68+
- `CollectorTraceExporter` => `OTLPTraceExporter`
69+
- `CollectorMetricExporter` => `OTLPMetricExporter`
70+
- `CollectorExporterConfigNode` => `OTLPExporterConfigNode`
71+
- `@opentelemetry/exporter-collector-proto` => `@opentelemetry/exporter-otlp-proto`
72+
- `CollectorExporterNodeBase` => `OTLPExporterNodeBase`
73+
- `CollectorMetricExporter` => `OTLPMetricExporter`
74+
- `CollectorTraceExporter` => `OTLPTraceExporter`
75+
- W3C propagators in @opentelemetry/core were renamed
76+
- `HttpTraceContextPropagator` -> `W3CTraceContextPropagator`
77+
- `HttpBaggagePropagator` -> `W3CBaggagePropagator`
78+
79+
## 0.24.x to 0.25.x
80+
81+
- SDKs packages for trace and metrics has been renamed to have a consistent naming schema:
82+
- @opentelemetry/tracing -> @opentelemetry/sdk-trace-base
83+
- @opentelemetry/node -> @opentelemetry/sdk-trace-node
84+
- @opentelemetry/web -> @opentelemetry/sdk-trace-web
85+
- @opentelemetry/metrics -> @opentelemetry/sdk-metrics-base
86+
- @opentelemetry/node-sdk -> @opentelemetry/sdk-node
87+
88+
## 0.23.x to 0.24.x
89+
90+
- `ResourceAttributes` renamed to `SemanticResourceAttributes` in the `@opentelemetry/semantic-conventions` package
91+
92+
## 0.19.x to 0.20.0
93+
94+
- `HttpBaggage` renamed to `HttpBaggagePropagator`
95+
96+
- `HttpTraceContext` renamed to `HttpTraceContextPropagator`
97+
98+
- `JaegerHttpTracePropagator` renamed to `JaegerPropagator`
99+
100+
- `serviceName` configuration removed from Collector exporters. Use `service.name` Resource attribute instead.
101+
102+
- Prometheus exporter added suffix `_total` to counter metrics.
103+
104+
## 0.18.x to 0.19.0
105+
106+
- API is now a peer dependency. This means that users will need to include `@opentelemetry/api` as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically.
107+
108+
- All plugins have been removed in favor of instrumentations.
109+
110+
- 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][otel-propagator-b3] for full details and usage.
111+
112+
- 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.
113+
114+
## 0.17.0 to 0.18.0
115+
116+
- `diag.setLogLevel` is removed and LogLevel can be set by an optional second parameter to `setLogger`
117+
118+
[PR-1975](https://github.com/open-telemetry/opentelemetry-js/pull/1975)
119+
120+
- Breaking change - The resulting resource MUST have all attributes that are on any of the two input resources. If a key exists on both the old and updating resource, the value of the updating resource MUST be picked - previously it was opposite.
121+
122+
## 0.16.0 to 0.17.0
123+
124+
[PR-1880](https://github.com/open-telemetry/opentelemetry-js/pull/1880) feat(diag-logger): introduce a new global level api.diag for internal diagnostic logging
125+
126+
[PR-1925](https://github.com/open-telemetry/opentelemetry-js/pull/1925) feat(diag-logger): part 2 - breaking changes - remove api.Logger, api.NoopLogger, core.LogLevel, core.ConsoleLogger
127+
128+
- These PR's remove the previous `Logger` and `LogLevel` implementations and change the way you should use the replacement `DiagLogger` and `DiagLogLevel`, below are simple examples of how to change your existing usages.
129+
130+
### Setting the global diagnostic logger
131+
132+
The new global [`api.diag`](https://github.com/open-telemetry/opentelemetry-js/blob/main/api/src/api/diag.ts) provides the ability to set the global diagnostic logger `setLogger()` and logging level `setLogLevel()`, it is also a `DiagLogger` implementation and should be directly to log diagnostic messages.
133+
134+
All included logger references have been removed in preference to using the global `api.diag` directly, so you no longer need to pass around the logger instance via function parameters or included as part of the configuration for a component.
135+
136+
```javascript
137+
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
138+
// Setting the default Global logger to use the Console
139+
// And optionally change the logging level (Defaults to INFO)
140+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR)
141+
```
142+
143+
### Using the logger anywhere in the code
144+
145+
```typescript
146+
import { diag } from "@opentelemetry/api";
147+
148+
// Remove or make optional the parameter and don't use it.
149+
export function MyFunction() {
150+
diag.debug("...");
151+
diag.info("...");
152+
diag.warn("...");
153+
diag.error("...");
154+
diag.verbose("..");
155+
}
156+
157+
```
158+
159+
### Setting the logger back to a noop
160+
161+
```typescript
162+
import { diag } from "@opentelemetry/api";
163+
diag.setLogger();
164+
165+
```
166+
167+
[PR-1855](https://github.com/open-telemetry/opentelemetry-js/pull/1855) Use instrumentation loader to load plugins and instrumentations
168+
169+
- Providers do no load the plugins anymore. Also PluginLoader has been removed from providers, use `registerInstrumentations` instead
170+
171+
```javascript
172+
//Previously in node
173+
const provider = new NodeTracerProvider({
174+
plugins: {
175+
'@grpc/grpc-js': {
176+
enabled: true,
177+
path: '@opentelemetry/plugin-grpc-js',
178+
},
179+
}
180+
});
181+
182+
// Now
183+
const provider = new NodeTracerProvider();
184+
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
185+
registerInstrumentations({
186+
instrumentations: [
187+
{
188+
plugins: {
189+
'@grpc/grpc-js': {
190+
enabled: true,
191+
path: '@opentelemetry/plugin-grpc-js',
192+
},
193+
}
194+
}
195+
],
196+
tracerProvider: provider,
197+
});
198+
199+
// or if you want to load only default instrumentations / plugins
200+
registerInstrumentations({
201+
tracerProvider: provider,
202+
});
203+
204+
//Previously in browser
205+
const provider = new WebTracerProvider({
206+
plugins: [
207+
new DocumentLoad()
208+
]
209+
});
210+
// Now
211+
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
212+
const provider = new WebTracerProvider();
213+
registerInstrumentations({
214+
instrumentations: [
215+
new DocumentLoad(),
216+
],
217+
});
218+
```
219+
220+
- `registerInstrumentations` supports loading old plugins and instrumentations together. It also supports setting tracer provider and meter provider on instrumentations
221+
222+
[PR-1874](https://github.com/open-telemetry/opentelemetry-js/pull/1874) More specific API type names
223+
224+
Some types exported from `"@opentelemetry/api"` have been changed to be more specific.
225+
226+
- `AttributeValue` renamed to `SpanAttributeValue`
227+
- `Attributes` renamed to `SpanAttributes`
228+
- `EntryTtl` renamed to `BaggageEntryTtl`
229+
- `EntryValue` renamed to `BaggageEntryValue`
230+
- `Status` renamed to `SpanStatus`
231+
- `StatusCode` renamed to `SpanStatusCode`
232+
233+
## 0.15.0 to 0.16.0
234+
235+
[PR-1863](https://github.com/open-telemetry/opentelemetry-js/pull/1863) removed public attributes `keepAlive` and `httpAgentOptions` from nodejs `CollectorTraceExporter` and `CollectorMetricExporter`
236+
237+
## 0.14.0 to 0.15.0
238+
239+
[PR-1764](https://github.com/open-telemetry/opentelemetry-js/pull/1764) removed some APIs from `Tracer`:
240+
241+
- `Tracer.getCurrentSpan()`: use `api.getSpan(api.context.active())`
242+
- `Tracer.withSpan(span)`: use `api.context.with(api.setSpan(api.context.active(), span))`
243+
- `Tracer.bind(target)`: use `api.context.bind(target)`
244+
245+
[PR-1797](https://github.com/open-telemetry/opentelemetry-js/pull/1797) chore!: split metrics into its own api package:
246+
247+
- Any references to `require("@opentelemetry/api").metrics` will need to be changed to `require("@opentelemetry/api-metrics").metrics`
248+
249+
[PR-1725](https://github.com/open-telemetry/opentelemetry-js/pull/1725) Use new gRPC default port
250+
251+
- The default port used by `@opentelemetry/exporter-collector-grpc` is changed from `55680` to `4317`
252+
253+
[PR-1749](https://github.com/open-telemetry/opentelemetry-js/pull/1749) chore: improve naming of span related context APIs
254+
255+
- Rename `[gs]etActiveSpan()` to `[gs]etSpan()`
256+
- Rename `setExtractedSpanContext()` to `setSpanContext()`
257+
- Rename `getParentSpanContext()` to `getSpanContext()`

experimental/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to experimental packages in this project will be documented
88

99
### :rocket: (Enhancement)
1010

11+
* feat(instrumentation): allow LoggerProvider to be specified in Instrumentations [#4314](https://github.com/open-telemetry/opentelemetry-js/pull/4314) @hectorhdzg
1112
* feat(instrumentation): Make `init()` method public [#4418](https://github.com/open-telemetry/opentelemetry-js/pull/4418)
1213
* feat(exporter-metrics-otlp-http): add option to set the exporter aggregation preference [#4409](https://github.com/open-telemetry/opentelemetry-js/pull/4409) @AkselAllas
1314
* feat(node-sdk): add spanProcessors option [#4454](https://github.com/open-telemetry/opentelemetry-js/pull/4454) @naseemkullah

experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ describe('PrometheusSerializer', () => {
622622
it('should serialize non-finite values', async () => {
623623
const serializer = new PrometheusSerializer();
624624
const cases = [
625-
[NaN, 'NaN'],
626625
[-Infinity, '-Inf'],
627626
[+Infinity, '+Inf'],
628627
] as [number, string][];

experimental/packages/opentelemetry-instrumentation/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@
7878
"shimmer": "^1.2.1"
7979
},
8080
"peerDependencies": {
81-
"@opentelemetry/api": "^1.3.0"
81+
"@opentelemetry/api": "^1.3.0",
82+
"@opentelemetry/api-logs": "^0.46.0"
8283
},
8384
"devDependencies": {
8485
"@babel/core": "7.23.6",
8586
"@babel/preset-env": "7.22.20",
8687
"@opentelemetry/api": "1.7.0",
88+
"@opentelemetry/api-logs": "0.47.0",
8789
"@opentelemetry/sdk-metrics": "1.21.0",
8890
"@types/mocha": "10.0.6",
8991
"@types/node": "18.6.5",

experimental/packages/opentelemetry-instrumentation/src/autoLoader.ts

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

1717
import { trace, metrics } from '@opentelemetry/api';
18+
import { logs } from '@opentelemetry/api-logs';
1819
import {
1920
disableInstrumentations,
2021
enableInstrumentations,
@@ -36,8 +37,14 @@ export function registerInstrumentations(
3637
);
3738
const tracerProvider = options.tracerProvider || trace.getTracerProvider();
3839
const meterProvider = options.meterProvider || metrics.getMeterProvider();
40+
const loggerProvider = options.loggerProvider || logs.getLoggerProvider();
3941

40-
enableInstrumentations(instrumentations, tracerProvider, meterProvider);
42+
enableInstrumentations(
43+
instrumentations,
44+
tracerProvider,
45+
meterProvider,
46+
loggerProvider
47+
);
4148

4249
return () => {
4350
disableInstrumentations(instrumentations);

experimental/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { TracerProvider, MeterProvider } from '@opentelemetry/api';
1818
import { Instrumentation } from './types';
1919
import { AutoLoaderResult, InstrumentationOption } from './types_internal';
20+
import { LoggerProvider } from '@opentelemetry/api-logs';
2021

2122
/**
2223
* Parses the options and returns instrumentations, node plugins and
@@ -52,7 +53,8 @@ export function parseInstrumentationOptions(
5253
export function enableInstrumentations(
5354
instrumentations: Instrumentation[],
5455
tracerProvider?: TracerProvider,
55-
meterProvider?: MeterProvider
56+
meterProvider?: MeterProvider,
57+
loggerProvider?: LoggerProvider
5658
): void {
5759
for (let i = 0, j = instrumentations.length; i < j; i++) {
5860
const instrumentation = instrumentations[i];
@@ -62,6 +64,9 @@ export function enableInstrumentations(
6264
if (meterProvider) {
6365
instrumentation.setMeterProvider(meterProvider);
6466
}
67+
if (loggerProvider && instrumentation.setLoggerProvider) {
68+
instrumentation.setLoggerProvider(loggerProvider);
69+
}
6570
// instrumentations have been already enabled during creation
6671
// so enable only if user prevented that by setting enabled to false
6772
// this is to prevent double enabling but when calling register all

0 commit comments

Comments
 (0)