Skip to content

Commit 310a2b2

Browse files
committed
Merge remote-tracking branch 'origin/feat/node/prom-client-implementation' into feat/node/prom-client-implementation
2 parents 460003f + 2189d51 commit 310a2b2

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-17
lines changed

.github/component-label-map.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ pkg-status:unmaintained:
278278
- changed-files:
279279
- any-glob-to-any-file:
280280
- detectors/node/opentelemetry-resource-detector-github/**
281+
- packages/opentelemetry-redis-common/**
281282
- plugins/node/instrumentation-fs/**
282283
- plugins/node/instrumentation-tedious/**
283284
- plugins/node/opentelemetry-instrumentation-connect/**
@@ -288,6 +289,9 @@ pkg-status:unmaintained:
288289
- plugins/node/opentelemetry-instrumentation-knex/**
289290
- plugins/node/opentelemetry-instrumentation-koa/**
290291
- plugins/node/opentelemetry-instrumentation-memcached/**
292+
- plugins/node/opentelemetry-instrumentation-mongodb/**
293+
- plugins/node/opentelemetry-instrumentation-mysql/**
294+
- plugins/node/opentelemetry-instrumentation-mysql2/**
291295
- plugins/node/opentelemetry-instrumentation-nestjs-core/**
292296
- plugins/node/opentelemetry-instrumentation-restify/**
293297
- plugins/node/opentelemetry-instrumentation-router/**

.github/component_owners.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ components:
4242
- pichlermarc
4343
- legendecas
4444
- blumamir
45-
packages/opentelemetry-redis-common:
46-
- haddasbronfman
45+
packages/opentelemetry-redis-common: []
46+
# Unmaintained
4747
packages/opentelemetry-test-utils:
4848
- dyladan
4949
- pichlermarc
@@ -102,12 +102,12 @@ components:
102102
# Unmaintained
103103
plugins/node/opentelemetry-instrumentation-memcached: []
104104
# Unmaintained
105-
plugins/node/opentelemetry-instrumentation-mongodb:
106-
- osherv
107-
plugins/node/opentelemetry-instrumentation-mysql:
108-
- haddasbronfman
109-
plugins/node/opentelemetry-instrumentation-mysql2:
110-
- haddasbronfman
105+
plugins/node/opentelemetry-instrumentation-mongodb: []
106+
# Unmaintained
107+
plugins/node/opentelemetry-instrumentation-mysql: []
108+
# Unmaintained
109+
plugins/node/opentelemetry-instrumentation-mysql2: []
110+
# Unmaintained
111111
plugins/node/opentelemetry-instrumentation-nestjs-core: []
112112
# Unmaintained
113113
plugins/node/opentelemetry-instrumentation-net:

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ jobs:
139139
- name: Report Coverage
140140
if: ${{ matrix.code-coverage && !cancelled()}}
141141
uses: codecov/codecov-action@v4
142+
env:
143+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
142144
with:
143145
verbose: true
144146

@@ -170,5 +172,7 @@ jobs:
170172
run: npm run test:browser
171173
- name: Report Coverage
172174
uses: codecov/codecov-action@v4
175+
env:
176+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
173177
with:
174178
verbose: true

plugins/node/instrumentation-undici/src/internal-types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import type { Channel } from 'diagnostics_channel';
1716

1817
import { UndiciRequest, UndiciResponse } from './types';
1918

2019
export interface ListenerRecord {
2120
name: string;
22-
channel: Channel;
23-
onMessage: (message: any, name: string | symbol) => void;
21+
unsubscribe: () => void;
2422
}
2523

2624
export interface RequestMessage {

plugins/node/instrumentation-undici/src/undici.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class UndiciInstrumentation extends InstrumentationBase<UndiciInstrumenta
7777

7878
override disable(): void {
7979
super.disable();
80-
this._channelSubs.forEach(sub => sub.channel.unsubscribe(sub.onMessage));
80+
this._channelSubs.forEach(sub => sub.unsubscribe());
8181
this._channelSubs.length = 0;
8282
}
8383

@@ -137,14 +137,29 @@ export class UndiciInstrumentation extends InstrumentationBase<UndiciInstrumenta
137137

138138
private subscribeToChannel(
139139
diagnosticChannel: string,
140-
onMessage: ListenerRecord['onMessage']
140+
onMessage: (message: any, name: string | symbol) => void
141141
) {
142-
const channel = diagch.channel(diagnosticChannel);
143-
channel.subscribe(onMessage);
142+
// `diagnostics_channel` had a ref counting bug until v18.19.0.
143+
// https://github.com/nodejs/node/pull/47520
144+
const [major, minor] = process.version
145+
.replace('v', '')
146+
.split('.')
147+
.map(n => Number(n));
148+
const useNewSubscribe = major > 18 || (major === 18 && minor >= 19);
149+
150+
let unsubscribe: () => void;
151+
if (useNewSubscribe) {
152+
diagch.subscribe?.(diagnosticChannel, onMessage);
153+
unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);
154+
} else {
155+
const channel = diagch.channel(diagnosticChannel);
156+
channel.subscribe(onMessage);
157+
unsubscribe = () => channel.unsubscribe(onMessage);
158+
}
159+
144160
this._channelSubs.push({
145161
name: diagnosticChannel,
146-
channel,
147-
onMessage,
162+
unsubscribe,
148163
});
149164
}
150165

0 commit comments

Comments
 (0)