Skip to content

Commit 91f3693

Browse files
authored
Merge branch 'main' into feat/drop-jaeger-exporter
2 parents 9b84134 + fb3aeef commit 91f3693

File tree

118 files changed

+2859
-723
lines changed

Some content is hidden

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

118 files changed

+2859
-723
lines changed

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
persist-credentials: false
2525

26-
- uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
26+
- uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
2727
with:
2828
results_file: results.sarif
2929
results_format: sarif

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1414

1515
### :rocket: Features
1616

17+
* feat(web): add session handling implementation [5173](https://github.com/open-telemetry/opentelemetry-js/pull/5173) @martinkuba
18+
1719
### :bug: Bug Fixes
1820

19-
* test(shim-opentracing): add comparison thresholds in flaky assertions [#5974](https://github.com/open-telemetry/opentelemetry-js/pull/5974) @cjihrig
21+
* fix(core): avoid leaking Node.js types via `unrefTimer()` util [#5986](https://github.com/open-telemetry/opentelemetry-js/pull/5986)
22+
* fix(core): avoid leaking Node.js types via otperformance [#5987](https://github.com/open-telemetry/opentelemetry-js/pull/5987) @pichlermarc
23+
* **important:** this bug fix may be breaking for certain uses of `otperformnace`
24+
* `otperformance.now()` and `otperformance.timeOrigin` are not affected.
25+
* the previously used type was incorrect and overly broad, leading to unexpected run-time behavior runtimes that are not Node.js.
26+
* these problems are now caught on compile-time: if you have been using this API and this change is breaking to you, please consider using your target platform's `performance` implementation instead.
2027

2128
### :books: Documentation
2229

2330
### :house: Internal
2431

32+
* test(shim-opentracing): add comparison thresholds in flaky assertions [#5974](https://github.com/open-telemetry/opentelemetry-js/pull/5974) @cjihrig
33+
* test(exporter-jaeger): clean up OTEL_EXPORTER_JAEGER_AGENT_PORT between tests [#6003](https://github.com/open-telemetry/opentelemetry-js/pull/6003) @cjihrig
34+
2535
## 2.1.0
2636

2737
### :rocket: Features

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@ node -r ./tracing.js app.js
106106

107107
The above example will emit auto-instrumented telemetry about your Node.js application to the console. For a more in-depth example, see the [Getting Started Guide](https://opentelemetry.io/docs/languages/js/getting-started/). For more information about automatic instrumentation see [@opentelemetry/sdk-trace-node][otel-node], which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see [@opentelemetry/sdk-trace-base][otel-tracing]
108108

109+
#### Debugging The Setup
110+
111+
It's possible that an application instrumented as outlined above may not be behaving in an expected manner.
112+
For example, if the application is meant to be sending data to an Open Telemetry collector, that collector
113+
may not be receiving any data. Insight into such issues can be gained by enabling a diagnostics logger:
114+
115+
```js
116+
// Added as additional configuration to tracing.js
117+
118+
const {
119+
diag,
120+
DiagConsoleLogger,
121+
DiagLogLevel
122+
} = require('@opentelemetry/api');
123+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
124+
```
125+
109126
## Library Author
110127

111128
If you are a library author looking to build OpenTelemetry into your library, please see [the documentation][docs]. As a library author, it is important that you only depend on properties and methods published on the public API. If you use any properties or methods from the SDK that are not officially a part of the public API, your library may break if an application owner uses a different SDK implementation.
@@ -218,7 +235,7 @@ For a more detailed breakdown of feature support see the [specification complian
218235

219236
## Contributing
220237

221-
We'd love your help!. Use tags [up-for-grabs][up-for-grabs-issues] and
238+
We'd love your help! Use tags [up-for-grabs][up-for-grabs-issues] and
222239
[good first issue][good-first-issues] to get started with the project. For
223240
instructions to build and make changes to this project, see the
224241
[CONTRIBUTING][CONTRIBUTING] guide.

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"karma-spec-reporter": "0.0.36",
8888
"karma-webpack": "5.0.1",
8989
"memfs": "3.5.3",
90-
"mocha": "11.7.2",
90+
"mocha": "11.7.4",
9191
"nyc": "17.1.0",
9292
"sinon": "18.0.1",
9393
"ts-loader": "9.5.4",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!-- markdownlint-disable MD029 -->
2+
3+
# Migrating to stable HTTP and database semantic conventions
4+
5+
This document describes how users of **OTel JS** instrumentations can migrate to stable **HTTP** and **database**-related semantic conventions (semconv).
6+
7+
For example, consider an HTTP client making a `GET /users/42` request that receives an HTTP 200 response status. HTTP instrumentation will generate a [Span](https://opentelemetry.io/docs/concepts/signals/traces/#spans) representing that request/response. Should the HTTP request method be captured with an attribute named `http.method` or `http.request.method`? The response status with `http.status_code` or `http.response.status_code`? This is what semantic conventions define. Which attribute names are used might matter when they are ingested into your Observability system: queries, dashboards, alerts, etc. might be relying on specific attribute names.
8+
9+
To allow users to **migrate** from old names to the stabilized names over a period of time, OpenTelemetry defined a recommended migration process based on setting the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable to indicate whether old, stable, or both sets of field names should be used. See [the HTTP migration guide](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/) and the [database migration guide](https://opentelemetry.io/docs/specs/semconv/non-normative/db-migration/).
10+
11+
For **OTel JS users**, as of 2025-10, **not all instrumentations support stable semconv and `OTEL_SEMCONV_STABILITY_OPT_IN` yet**. Support for `http.*` attributes is complete, but not yet for `net.*` and `db.*` attributes.
12+
13+
## What's the easiest thing I can do?
14+
15+
1. Set the `OTEL_SEMCONV_STABILITY_OPT_IN=http/dup,database/dup` environment variable when you configure an OTel JS SDK. This tells instrumentations (that support it) to *emit* both old and stable semconv attributes.
16+
2. Migrate queries/dashboards/alerts in your Observability system to **use the stable `http.*` semconv** as described in [the HTTP migration guide](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
17+
3. For now, continue to **use the old `net.*` and `db.*` attributes** in your Observability system.
18+
19+
Future:
20+
21+
4. When [OTel JS instrumentations support it](https://github.com/open-telemetry/opentelemetry-js/issues/5663): migrate queries/dashboards/alerts in your Observability system to use the stable `net.*` semconv as described in [the HTTP migration guide](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
22+
5. When [OTel JS instrumentations support it](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2953): migrate queries/dashboards/alerts in your Observability system to use the stable `db.*` semconv as described in [the database migration guide](https://opentelemetry.io/docs/specs/semconv/non-normative/db-migration/).
23+
6. Sometime after a OTel JS SDK 3.0 release (anticipated to be in or after June 2026), you can drop usage of the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable. In JS SDK 3.0, instrumentations will only support the stable HTTP and database semantic conventions.
24+
25+
## Browser instrumentations
26+
27+
Some HTTP-related instrumentations are for use in the browser:
28+
[`@opentelemetry/instrumentation-fetch`](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch/#semantic-conventions),
29+
[`@opentelemetry/instrumentation-xml-http-request`](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request/#semantic-conventions), and
30+
[`@opentelemetry/instrumentation-document-load`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-document-load/#semantic-conventions). Environment variables don't exist in the browser so, instead of `OTEL_SEMCONV_STABILITY_OPT_IN`, use the `semconvStabilityOptIn` config option to these instrumentations.
31+
32+
## Timeline
33+
34+
- 2023-11:03: In [semconv v1.23.0](https://github.com/open-telemetry/semantic-conventions/blob/main/CHANGELOG.md#v1230-2023-11-03), HTTP semantic conventions were stabilized.
35+
- 2025-05-02: In [semconv v1.33.0](https://github.com/open-telemetry/semantic-conventions/blob/main/CHANGELOG.md#v1330), database semantic conventions were stabilized.
36+
- 2024-09-10 to 2025-09-19: All OTel JS instrumentations producing `http.*` were updated to support stable semconv and `OTEL_SEMCONV_STABILITY_OPT_IN`.
37+
- Ongoing: [OTel JS instrumentations producing **`net.*` semconv** are being updated](https://github.com/open-telemetry/opentelemetry-js/issues/5663) to support stable semconv and `OTEL_SEMCONV_STABILITY_OPT_IN`
38+
- Ongoing: [OTel JS instrumentations producing **`db.*` semconv** are being updated](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2953) to support stable semconv and `OTEL_SEMCONV_STABILITY_OPT_IN`
39+
- Projected 2026-06: As part of OTel JS SDK 3.0, instrumentations will emit *stable* HTTP and database semantic conventions by default, and drop support for old names.
40+
41+
## Q&A
42+
43+
### Why are `net.*` attributes controlled by `OTEL_SEMCONV_STABILITY_OPT_IN=http/dup`?
44+
45+
The semantic conventions for a number of networking-related attributes were stabilized as part of the same effort of stabilizing HTTP. Therefore when the [HTTP migration process](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/) was defined, it included migration of `net.*` attributes -- e.g. `net.peer.name → server.address` and `net.protocol.version → network.protocol.version`.
46+
47+
Even though `net.*` attributes are used in non-HTTP instrumentations (e.g. `@opentelemetry/instrumentation-amqplib`, `@opentelemetry/instrumentation-mysql2`) they will still use the `http` (or `http/dup`) value in `OTEL_SEMCONV_STABILITY_OPT_IN`.
48+
49+
(Note: One exception to this is `@opentelemetry/instrumentation-pg`, which added support for stable semconv migration using `OTEL_SEMCONV_STABILITY_OPT_IN=db/dup` for both `net.*` and `db.*` attributes **before** the plan in this document was discussed.)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Session Example</title>
7+
<base href="/">
8+
9+
<meta name="viewport" content="width=device-width, initial-scale=1">
10+
</head>
11+
12+
<body>
13+
Example of using attaching session attributes to spans and logs.
14+
<script type="text/javascript" src="session.js"></script>
15+
<button id="button1">generate span</button>
16+
<button id="button2">generate log</button>
17+
</body>
18+
19+
</html>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { ConsoleSpanExporter, SimpleSpanProcessor } = require( '@opentelemetry/sdk-trace-base');
2+
const { WebTracerProvider } = require( '@opentelemetry/sdk-trace-web');
3+
const {
4+
LoggerProvider,
5+
SimpleLogRecordProcessor,
6+
ConsoleLogRecordExporter,
7+
} = require('@opentelemetry/sdk-logs');
8+
const {
9+
createSessionSpanProcessor,
10+
createSessionLogRecordProcessor,
11+
createSessionManager,
12+
createDefaultSessionIdGenerator,
13+
LocalStorageSessionStore
14+
} = require('@opentelemetry/web-common');
15+
16+
// session manager
17+
const sessionManager = createSessionManager({
18+
sessionIdGenerator: createDefaultSessionIdGenerator(),
19+
sessionStore: new LocalStorageSessionStore(),
20+
maxDuration: 20,
21+
inactivityTimeout: 10
22+
});
23+
24+
sessionManager.addObserver({
25+
onSessionStarted: (newSession, previousSession) => {
26+
console.log('Session started', newSession, previousSession);
27+
},
28+
onSessionEnded: (session) => {
29+
console.log('Session ended', session);
30+
}
31+
});
32+
33+
// restore or start session
34+
sessionManager.start();
35+
36+
// configure tracer
37+
const tracerProvider = new WebTracerProvider({
38+
spanProcessors: [
39+
createSessionSpanProcessor(sessionManager),
40+
new SimpleSpanProcessor(new ConsoleSpanExporter())
41+
]
42+
});
43+
44+
tracerProvider.register();
45+
const tracer = tracerProvider.getTracer('example');
46+
47+
// configure logger
48+
const loggerProvider = new LoggerProvider({
49+
processors: [
50+
createSessionLogRecordProcessor(sessionManager),
51+
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
52+
]
53+
});
54+
55+
const logger = loggerProvider.getLogger('example');
56+
57+
window.addEventListener('load', () => {
58+
document.getElementById('button1').addEventListener('click', generateSpan);
59+
document.getElementById('button2').addEventListener('click', generateLog);
60+
});
61+
62+
function generateSpan() {
63+
const span = tracer.startSpan('foo');
64+
span.setAttribute('key', 'value');
65+
span.end();
66+
}
67+
68+
function generateLog() {
69+
logger.emit({
70+
attributes: {
71+
name: 'my-event',
72+
},
73+
body: {
74+
key1: 'val1'
75+
}
76+
});
77+
}

examples/opentelemetry-web/webpack.dev.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const common = {
1414
fetchXhrB3: 'examples/fetchXhrB3/index.js',
1515
'fetch-proto': 'examples/fetch-proto/index.js',
1616
zipkin: 'examples/zipkin/index.js',
17+
session: 'examples/session/index.js'
1718
},
1819
output: {
1920
path: path.resolve(__dirname, 'dist'),

examples/opentelemetry-web/webpack.prod.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const common = {
1414
fetchXhrB3: 'examples/fetchXhrB3/index.js',
1515
"fetch-proto": "examples/fetch-proto/index.js",
1616
zipkin: 'examples/zipkin/index.js',
17+
session: 'examples/session/index.js'
1718
},
1819
output: {
1920
path: path.resolve(__dirname, 'dist'),

experimental/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1414

1515
### :rocket: Features
1616

17+
* feat(sdk-node): always set up propagtion and context manager [#5930](https://github.com/open-telemetry/opentelemetry-js/pull/5930)
18+
* using `(new NodeSDK).start()` will now automatically set up a context management and propagation, even if no Trace SDK
19+
is initialized.
20+
* feat(otlp-exporter-base, otlp-grpc-exporter-base): add an option to let an SDK distribution prepend their own user-agent string in HTTP & GRPC exporters [#5928](https://github.com/open-telemetry/opentelemetry-js/pull/5928) @david-luna
21+
1722
### :bug: Bug Fixes
1823

24+
* fix(sdk-logs): Fix the `batchLogProcessor` exporting only upon `_scheduledDelayMillis` and ignoring `maxExportBatchSize` [#5961](https://github.com/open-telemetry/opentelemetry-js/pull/5961) @jacksonweber
25+
* fix(otlp-grpc-exporter-base): fix GRPC exporter not sending the user-agent header [#5687](https://github.com/open-telemetry/opentelemetry-js/issues/5867) @david-luna
26+
1927
### :books: Documentation
2028

2129
### :house: Internal
2230

31+
* test(opentelemetry-configuration): simplify management of environment variables [#6004](https://github.com/open-telemetry/opentelemetry-js/pull/6004) @cjihrig
32+
2333
## 0.206.0
2434

2535
### :rocket: Features
@@ -30,11 +40,14 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
3040
* feat(opentelemetry-configuration): Parse of Configuration File [#5875](https://github.com/open-telemetry/opentelemetry-js/pull/5875) @maryliag
3141
* feat(opentelemetry-configuration): parse of array objects on configuration file [#5947](https://github.com/open-telemetry/opentelemetry-js/pull/5947) @maryliag
3242
* feat(opentelemetry-configuration): parse of environment variables on configuration file [#5947](https://github.com/open-telemetry/opentelemetry-js/pull/5947) @maryliag
43+
* feat(opentelemetry-configuration): parse more parameters from config file [#5955](https://github.com/open-telemetry/opentelemetry-js/pull/5955) @maryliag
44+
* feat(exporter-prometheus): support withoutTargetInfo option [#5962](https://github.com/open-telemetry/opentelemetry-js/pull/5962) @cjihrig
3345

3446
### :bug: Bug Fixes
3547

3648
* fix(instrumentation-http): respect requireParent flag when INVALID_SPAN_CONTEXT is used [#4788](https://github.com/open-telemetry/opentelemetry-js/pull/4788) @reberhardt7
3749
* fix(otlp-transformer): trunc hrTime to int for nanos converting [#5924](https://github.com/open-telemetry/opentelemetry-js/pull/5924) @blumamir
50+
* fix(instrumentation-http): remove port from ATTR_CLIENT_ADDRESS [#5957](https://github.com/open-telemetry/opentelemetry-js/pull/5957) @cjihrig
3851

3952
### :house: Internal
4053

0 commit comments

Comments
 (0)