Skip to content

Commit 9b43ccb

Browse files
authored
chore: add 'lint:deps' script to check for unused and unlisted deps (open-telemetry#2477)
This uses knip (https://knip.dev) to check dependencies, in hopes of avoiding issues like open-telemetry#2473. This adds 'npm run lint:deps' and adds that to the existing 'npm run lint'. This change includes fixes for a handful of unused and unlisted deps. For now knip is configured to only check 'production' deps. Checking non-prod deps results in way too many false positives. Note that knip is being run via `npx` rather than installing as a devDep because there is a conflict: knip deps on typescript@5 and all packaegs in this repo currently use [email protected]. Installing knip at the top-level results in a ballooning of the node_modules install size as [email protected] is installed 40+ types in all separate workspaces.
1 parent 2822511 commit 9b43ccb

File tree

58 files changed

+86
-47
lines changed

Some content is hidden

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

58 files changed

+86
-47
lines changed

knip.jsonc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://knip.dev/reference/configuration
2+
{
3+
"$schema": "https://unpkg.com/knip@5/schema-jsonc.json",
4+
"workspaces": {
5+
"metapackages/auto-instrumentations-node": {
6+
// Ensure register.ts is considered an entry-point (the `!` is to be
7+
// included with the `--production` flag).
8+
"entry": "src/register.ts!"
9+
}
10+
}
11+
}

package-lock.json

+16-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
"test-all-versions": "npm run --if-present --workspaces test-all-versions",
2424
"bump": "lerna publish",
2525
"changelog": "lerna-changelog",
26-
"lint": "lerna run lint && npm run lint:readme && npm run lint:markdown",
26+
"lint": "lerna run lint && npm run lint:deps && npm run lint:readme && npm run lint:markdown",
2727
"lint:fix": "lerna run lint:fix && npm run lint:markdown:fix",
28+
"lint:deps": "npx --yes [email protected] --dependencies --production --tags=-knipignore",
2829
"lint:examples": "eslint ./examples/**/*.js",
2930
"lint:examples:fix": "eslint ./examples/**/*.js --fix",
3031
"lint:markdown": "markdownlint-cli2 $(git ls-files '*.md')",

packages/opentelemetry-host-metrics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"@opentelemetry/api": "^1.3.0",
47+
"@opentelemetry/sdk-metrics": "^1.8.0",
4748
"@types/mocha": "8.2.3",
4849
"@types/node": "18.18.14",
4950
"@types/sinon": "10.0.20",
@@ -53,7 +54,6 @@
5354
"typescript": "4.4.4"
5455
},
5556
"dependencies": {
56-
"@opentelemetry/sdk-metrics": "^1.8.0",
5757
"systeminformation": "5.22.9"
5858
},
5959
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-host-metrics#readme"

packages/opentelemetry-host-metrics/src/BaseMetrics.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Meter, MeterProvider, diag, metrics } from '@opentelemetry/api';
1818

19+
/** @knipignore */
1920
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2021

2122
/**

packages/opentelemetry-test-utils/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
"@opentelemetry/core": "^1.0.0",
4848
"@opentelemetry/exporter-jaeger": "^1.3.1",
4949
"@opentelemetry/instrumentation": "^0.54.0",
50+
"@opentelemetry/otlp-transformer": "^0.54.0",
5051
"@opentelemetry/resources": "^1.8.0",
52+
"@opentelemetry/sdk-metrics": "^1.27.0",
5153
"@opentelemetry/sdk-node": "^0.54.0",
5254
"@opentelemetry/sdk-trace-base": "^1.8.0",
5355
"@opentelemetry/sdk-trace-node": "^1.8.0",

packages/winston-transport/src/OpenTelemetryTransportV3.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Logger, logs } from '@opentelemetry/api-logs';
1818
import TransportStream = require('winston-transport');
19+
/** @knipignore */
1920
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2021
import { emitLogRecord } from './utils';
2122

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

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
normalizeExchange,
7575
unmarkConfirmChannelTracing,
7676
} from './utils';
77+
/** @knipignore */
7778
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
7879

7980
const supportedVersions = ['>=0.5.5 <1'];

plugins/node/instrumentation-cucumber/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
},
4646
"devDependencies": {
4747
"@cucumber/cucumber": "^9.0.0",
48+
"@cucumber/messages": "^22.0.0",
4849
"@opentelemetry/api": "^1.0.0",
4950
"@opentelemetry/core": "^1.3.1",
5051
"@opentelemetry/sdk-trace-base": "^1.3.1",

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

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {
3838
} from '@cucumber/cucumber/lib/support_code_library_builder/types';
3939

4040
import { AttributeNames, CucumberInstrumentationConfig } from './types';
41+
/** @knipignore */
4142
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
4243

4344
const hooks = ['Before', 'BeforeStep', 'AfterStep', 'After'] as const;

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

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
SpanKind,
2828
} from '@opentelemetry/api';
2929
import { DataloaderInstrumentationConfig } from './types';
30+
/** @knipignore */
3031
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
3132
import type * as Dataloader from 'dataloader';
3233

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

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
InstrumentationNodeModuleDefinition,
2222
isWrapped,
2323
} from '@opentelemetry/instrumentation';
24+
/** @knipignore */
2425
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2526
import {
2627
CALLBACK_FUNCTIONS,

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

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import type {
4444
Consumer,
4545
} from 'kafkajs';
4646
import { KafkaJsInstrumentationConfig } from './types';
47+
/** @knipignore */
4748
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
4849
import { bufferTextMapGetter } from './propagator';
4950
import {

plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
InstrumentationConfig,
2121
InstrumentationNodeModuleDefinition,
2222
} from '@opentelemetry/instrumentation';
23+
/** @knipignore */
2324
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2425

2526
export class LruMemoizerInstrumentation extends InstrumentationBase {

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

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
InstrumentationModuleDefinition,
2828
InstrumentationNodeModuleDefinition,
2929
} from '@opentelemetry/instrumentation';
30+
/** @knipignore */
3031
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
3132
import {
3233
SEMATTRS_DB_OPERATION,

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

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const { eventLoopUtilization } = performance;
1818

1919
import { InstrumentationBase } from '@opentelemetry/instrumentation';
2020

21+
/** @knipignore */
2122
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2223
import { RuntimeNodeInstrumentationConfig } from './types';
2324

plugins/node/instrumentation-socket.io/src/socket.io.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
} from '@opentelemetry/semantic-conventions';
3838
import { SocketIoInstrumentationConfig } from './types';
3939
import { SocketIoInstrumentationAttributes } from './AttributeNames';
40+
/** @knipignore */
4041
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
4142
import {
4243
extractRoomsAttributeValue,

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

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import type * as tedious from 'tedious';
3535
import { TediousInstrumentationConfig } from './types';
3636
import { getSpanName, once } from './utils';
37+
/** @knipignore */
3738
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
3839

3940
const CURRENT_DATABASE = Symbol(

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

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
ValueType,
3535
} from '@opentelemetry/api';
3636

37+
/** @knipignore */
3738
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
3839

3940
import {

plugins/node/opentelemetry-instrumentation-aws-lambda/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"dependencies": {
5858
"@opentelemetry/instrumentation": "^0.54.0",
5959
"@opentelemetry/propagator-aws-xray": "^1.3.1",
60-
"@opentelemetry/resources": "^1.8.0",
6160
"@opentelemetry/semantic-conventions": "^1.27.0",
6261
"@types/aws-lambda": "8.10.143"
6362
},

plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
} from 'aws-lambda';
5959

6060
import { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types';
61+
/** @knipignore */
6162
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
6263
import { env } from 'process';
6364
import { LambdaModule } from './internal-types';

plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
NormalizedRequest,
3434
NormalizedResponse,
3535
} from './types';
36+
/** @knipignore */
3637
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
3738
import {
3839
InstrumentationBase,

plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { logs, SeverityNumber, Logger } from '@opentelemetry/api-logs';
1818
import type { LogLevelString } from 'bunyan';
19+
/** @knipignore */
1920
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2021

2122
const DEFAULT_INSTRUMENTATION_SCOPE_NAME = PACKAGE_NAME;

0 commit comments

Comments
 (0)