Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/node/prom-client-implementa…
Browse files Browse the repository at this point in the history
…tion' into feat/node/prom-client-implementation
  • Loading branch information
pikalovArtemN committed Oct 10, 2024
2 parents 460003f + 2189d51 commit 310a2b2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/component-label-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ pkg-status:unmaintained:
- changed-files:
- any-glob-to-any-file:
- detectors/node/opentelemetry-resource-detector-github/**
- packages/opentelemetry-redis-common/**
- plugins/node/instrumentation-fs/**
- plugins/node/instrumentation-tedious/**
- plugins/node/opentelemetry-instrumentation-connect/**
Expand All @@ -288,6 +289,9 @@ pkg-status:unmaintained:
- plugins/node/opentelemetry-instrumentation-knex/**
- plugins/node/opentelemetry-instrumentation-koa/**
- plugins/node/opentelemetry-instrumentation-memcached/**
- plugins/node/opentelemetry-instrumentation-mongodb/**
- plugins/node/opentelemetry-instrumentation-mysql/**
- plugins/node/opentelemetry-instrumentation-mysql2/**
- plugins/node/opentelemetry-instrumentation-nestjs-core/**
- plugins/node/opentelemetry-instrumentation-restify/**
- plugins/node/opentelemetry-instrumentation-router/**
Expand Down
16 changes: 8 additions & 8 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ components:
- pichlermarc
- legendecas
- blumamir
packages/opentelemetry-redis-common:
- haddasbronfman
packages/opentelemetry-redis-common: []
# Unmaintained
packages/opentelemetry-test-utils:
- dyladan
- pichlermarc
Expand Down Expand Up @@ -102,12 +102,12 @@ components:
# Unmaintained
plugins/node/opentelemetry-instrumentation-memcached: []
# Unmaintained
plugins/node/opentelemetry-instrumentation-mongodb:
- osherv
plugins/node/opentelemetry-instrumentation-mysql:
- haddasbronfman
plugins/node/opentelemetry-instrumentation-mysql2:
- haddasbronfman
plugins/node/opentelemetry-instrumentation-mongodb: []
# Unmaintained
plugins/node/opentelemetry-instrumentation-mysql: []
# Unmaintained
plugins/node/opentelemetry-instrumentation-mysql2: []
# Unmaintained
plugins/node/opentelemetry-instrumentation-nestjs-core: []
# Unmaintained
plugins/node/opentelemetry-instrumentation-net:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ jobs:
- name: Report Coverage
if: ${{ matrix.code-coverage && !cancelled()}}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true

Expand Down Expand Up @@ -170,5 +172,7 @@ jobs:
run: npm run test:browser
- name: Report Coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true
4 changes: 1 addition & 3 deletions plugins/node/instrumentation-undici/src/internal-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { Channel } from 'diagnostics_channel';

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

export interface ListenerRecord {
name: string;
channel: Channel;
onMessage: (message: any, name: string | symbol) => void;
unsubscribe: () => void;
}

export interface RequestMessage {
Expand Down
27 changes: 21 additions & 6 deletions plugins/node/instrumentation-undici/src/undici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class UndiciInstrumentation extends InstrumentationBase<UndiciInstrumenta

override disable(): void {
super.disable();
this._channelSubs.forEach(sub => sub.channel.unsubscribe(sub.onMessage));
this._channelSubs.forEach(sub => sub.unsubscribe());
this._channelSubs.length = 0;
}

Expand Down Expand Up @@ -137,14 +137,29 @@ export class UndiciInstrumentation extends InstrumentationBase<UndiciInstrumenta

private subscribeToChannel(
diagnosticChannel: string,
onMessage: ListenerRecord['onMessage']
onMessage: (message: any, name: string | symbol) => void
) {
const channel = diagch.channel(diagnosticChannel);
channel.subscribe(onMessage);
// `diagnostics_channel` had a ref counting bug until v18.19.0.
// https://github.com/nodejs/node/pull/47520
const [major, minor] = process.version
.replace('v', '')
.split('.')
.map(n => Number(n));
const useNewSubscribe = major > 18 || (major === 18 && minor >= 19);

let unsubscribe: () => void;
if (useNewSubscribe) {
diagch.subscribe?.(diagnosticChannel, onMessage);
unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);
} else {
const channel = diagch.channel(diagnosticChannel);
channel.subscribe(onMessage);
unsubscribe = () => channel.unsubscribe(onMessage);
}

this._channelSubs.push({
name: diagnosticChannel,
channel,
onMessage,
unsubscribe,
});
}

Expand Down

0 comments on commit 310a2b2

Please sign in to comment.