Skip to content

Commit

Permalink
chore: update to otel 1.27.0 / 0.54.0 (#969)
Browse files Browse the repository at this point in the history
* chore: update to otel 1.27.0 / 0.54.0

* update node version for lint job

* update grpc-js
  • Loading branch information
seemk authored Nov 12, 2024
1 parent da88406 commit 099ce4a
Show file tree
Hide file tree
Showing 13 changed files with 1,032 additions and 1,149 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module.exports = {
],
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "args": "after-used"}],
"@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }],
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/no-require-imports": "off",
"arrow-parens": ["error", "always"],
"prettier/prettier": ["error", {
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run: git fetch origin ${{ github.base_ref }}
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22
- name: Install npm dependencies
run: npm ci --ignore-scripts
- name: Check version
Expand Down
1,942 changes: 896 additions & 1,046 deletions package-lock.json

Large diffs are not rendered by default.

122 changes: 60 additions & 62 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@
"@elastic/elasticsearch": "^7.17.11",
"@types/bunyan": "1.8.11",
"@types/semver": "^7.5.0",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"bunyan": "1.8.15",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.1",
"gts": "^5.3.1",
"mysql2": "^3.10.2",
"nock": "^13.5.4",
Expand All @@ -82,73 +81,72 @@
"pg": "^8.4.2",
"pino": "^8.7.0",
"prebuildify": "^6.0.1",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"redis": "^3.1.2",
"sequelize": "^6.32.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",
"typeorm": "^0.3.17",
"typescript": "5.5.3",
"typescript": "5.6.3",
"winston": "3.10.0"
},
"dependencies": {
"@grpc/grpc-js": "^1.11.1",
"@grpc/grpc-js": "^1.12.2",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/api-logs": "^0.53.0",
"@opentelemetry/context-async-hooks": "1.26.0",
"@opentelemetry/core": "1.26.0",
"@opentelemetry/exporter-logs-otlp-http": "0.53.0",
"@opentelemetry/exporter-logs-otlp-proto": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.53.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.53.0",
"@opentelemetry/instrumentation": "0.53.0",
"@opentelemetry/instrumentation-amqplib": "0.42.0",
"@opentelemetry/instrumentation-aws-sdk": "0.44.0",
"@opentelemetry/instrumentation-bunyan": "0.41.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.41.0",
"@opentelemetry/instrumentation-connect": "0.39.0",
"@opentelemetry/instrumentation-dataloader": "0.12.0",
"@opentelemetry/instrumentation-dns": "0.39.0",
"@opentelemetry/instrumentation-express": "0.42.0",
"@opentelemetry/instrumentation-fastify": "0.39.0",
"@opentelemetry/instrumentation-generic-pool": "0.39.0",
"@opentelemetry/instrumentation-graphql": "0.43.0",
"@opentelemetry/instrumentation-grpc": "0.53.0",
"@opentelemetry/instrumentation-hapi": "0.41.0",
"@opentelemetry/instrumentation-http": "0.53.0",
"@opentelemetry/instrumentation-ioredis": "0.43.0",
"@opentelemetry/instrumentation-kafkajs": "0.3.0",
"@opentelemetry/instrumentation-knex": "0.40.0",
"@opentelemetry/instrumentation-koa": "0.43.0",
"@opentelemetry/instrumentation-lru-memoizer": "0.40.0",
"@opentelemetry/instrumentation-memcached": "0.39.0",
"@opentelemetry/instrumentation-mongodb": "0.47.0",
"@opentelemetry/instrumentation-mongoose": "0.42.0",
"@opentelemetry/instrumentation-mysql": "0.41.0",
"@opentelemetry/instrumentation-mysql2": "0.41.0",
"@opentelemetry/instrumentation-nestjs-core": "0.40.0",
"@opentelemetry/instrumentation-net": "0.39.0",
"@opentelemetry/instrumentation-pg": "0.44.0",
"@opentelemetry/instrumentation-pino": "0.42.0",
"@opentelemetry/instrumentation-redis": "0.42.0",
"@opentelemetry/instrumentation-redis-4": "0.42.0",
"@opentelemetry/instrumentation-restify": "0.41.0",
"@opentelemetry/instrumentation-router": "0.40.0",
"@opentelemetry/instrumentation-socket.io": "0.42.0",
"@opentelemetry/instrumentation-tedious": "0.14.0",
"@opentelemetry/instrumentation-undici": "0.6.0",
"@opentelemetry/instrumentation-winston": "0.40.0",
"@opentelemetry/propagator-b3": "1.26.0",
"@opentelemetry/resource-detector-container": "0.4.1",
"@opentelemetry/resources": "1.26.0",
"@opentelemetry/sdk-logs": "^0.53.0",
"@opentelemetry/sdk-metrics": "1.26.0",
"@opentelemetry/sdk-trace-base": "1.26.0",
"@opentelemetry/sdk-trace-node": "1.26.0",
"@opentelemetry/api-logs": "^0.54.2",
"@opentelemetry/context-async-hooks": "1.27.0",
"@opentelemetry/core": "1.27.0",
"@opentelemetry/exporter-logs-otlp-http": "0.54.2",
"@opentelemetry/exporter-logs-otlp-proto": "0.54.2",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.54.2",
"@opentelemetry/exporter-metrics-otlp-proto": "0.54.2",
"@opentelemetry/exporter-trace-otlp-grpc": "0.54.2",
"@opentelemetry/exporter-trace-otlp-proto": "0.54.2",
"@opentelemetry/instrumentation": "0.54.2",
"@opentelemetry/instrumentation-amqplib": "0.43.0",
"@opentelemetry/instrumentation-aws-sdk": "0.46.0",
"@opentelemetry/instrumentation-bunyan": "0.42.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.42.0",
"@opentelemetry/instrumentation-connect": "0.40.0",
"@opentelemetry/instrumentation-dataloader": "0.13.0",
"@opentelemetry/instrumentation-dns": "0.40.0",
"@opentelemetry/instrumentation-express": "0.44.0",
"@opentelemetry/instrumentation-fastify": "0.41.0",
"@opentelemetry/instrumentation-generic-pool": "0.40.0",
"@opentelemetry/instrumentation-graphql": "0.44.0",
"@opentelemetry/instrumentation-grpc": "0.54.2",
"@opentelemetry/instrumentation-hapi": "0.42.0",
"@opentelemetry/instrumentation-http": "0.54.2",
"@opentelemetry/instrumentation-ioredis": "0.44.0",
"@opentelemetry/instrumentation-kafkajs": "0.4.0",
"@opentelemetry/instrumentation-knex": "0.41.0",
"@opentelemetry/instrumentation-koa": "0.44.0",
"@opentelemetry/instrumentation-lru-memoizer": "0.41.0",
"@opentelemetry/instrumentation-memcached": "0.40.0",
"@opentelemetry/instrumentation-mongodb": "0.48.0",
"@opentelemetry/instrumentation-mongoose": "0.43.0",
"@opentelemetry/instrumentation-mysql": "0.42.0",
"@opentelemetry/instrumentation-mysql2": "0.42.1",
"@opentelemetry/instrumentation-nestjs-core": "0.41.0",
"@opentelemetry/instrumentation-net": "0.40.0",
"@opentelemetry/instrumentation-pg": "0.47.1",
"@opentelemetry/instrumentation-pino": "0.43.0",
"@opentelemetry/instrumentation-redis": "0.43.0",
"@opentelemetry/instrumentation-redis-4": "0.43.0",
"@opentelemetry/instrumentation-restify": "0.42.0",
"@opentelemetry/instrumentation-router": "0.41.0",
"@opentelemetry/instrumentation-socket.io": "0.43.0",
"@opentelemetry/instrumentation-tedious": "0.15.0",
"@opentelemetry/instrumentation-undici": "0.7.1",
"@opentelemetry/instrumentation-winston": "0.41.0",
"@opentelemetry/propagator-b3": "1.27.0",
"@opentelemetry/resource-detector-container": "0.5.0",
"@opentelemetry/resources": "1.27.0",
"@opentelemetry/sdk-logs": "0.54.2",
"@opentelemetry/sdk-metrics": "1.27.0",
"@opentelemetry/sdk-trace-base": "1.27.0",
"@opentelemetry/sdk-trace-node": "1.27.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@opentelemetry/winston-transport": "0.6.0",
"@opentelemetry/winston-transport": "0.7.0",
"is-promise": "^4.0.0",
"nan": "^2.22.0",
"node-gyp-build": "^4.8.2",
Expand Down
6 changes: 3 additions & 3 deletions src/instrumentations/external/typeorm/typeorm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class TypeormInstrumentation extends InstrumentationBase<TypeormInstrumen
try {
attributes[ExtendedDatabaseAttribute.DB_STATEMENT_PARAMETERS] =
JSON.stringify(parameters);
} catch (err) {
} catch {
/* */
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ export class TypeormInstrumentation extends InstrumentationBase<TypeormInstrumen
statement = statement.trim();
try {
operation = statement.split(' ')[0].toUpperCase();
} catch (e) {
} catch {
/* */
}
}
Expand Down Expand Up @@ -459,7 +459,7 @@ const buildStatement = (func: Function, args: any[]) => {
statement[pName] = args[i];
return;
}
} catch (_err) {
} catch {
/* */
}
if (value?.name) {
Expand Down
2 changes: 1 addition & 1 deletion src/instrumentations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function setupLoggingOptions(
return setDefaultLoggingOptions(opts);
}

function signalStartOpt<T extends {}>(options: T | boolean | undefined): T {
function signalStartOpt<T extends object>(options: T | boolean | undefined): T {
if (typeof options === 'object') {
return options;
}
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface NativeCounters {
};
}

const typedKeys = <T extends {}>(obj: T): (keyof T)[] =>
const typedKeys = <T extends object>(obj: T): (keyof T)[] =>
Object.keys(obj) as (keyof T)[];

interface CountersExtension {
Expand Down Expand Up @@ -167,7 +167,7 @@ export function createOtlpExporter(options: MetricsOptions) {
? {
'X-SF-TOKEN': options.accessToken,
}
: {};
: undefined;
const url = ensureResourcePath(endpoint, '/v1/metrics');
return new OTLPHttpProtoMetricExporter({
url,
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function otlpSpanExporterFactory(options: TracingOptions): SpanExporter {
? {
'X-SF-TOKEN': accessToken,
}
: {};
: undefined;
const url = ensureResourcePath(endpoint, '/v1/traces');
return new OTLPHttpTraceExporter({
url,
Expand Down
29 changes: 18 additions & 11 deletions test/common_options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { describe, it } from 'node:test';
import { strict as assert } from 'assert';
import { parseOptionsAndConfigureInstrumentations } from '../src/instrumentations';
import { Resource } from '@opentelemetry/resources';
import { exporterUrl } from './utils';

describe('common options', () => {
it('passes resource creation function to signals', () => {
Expand Down Expand Up @@ -118,19 +119,25 @@ describe('common options', () => {
endpoint: 'http://localhost:4318',
});

const traceUrl = tracingOptions.spanExporterFactory(tracingOptions)[0].url;
assert.strictEqual(traceUrl, 'http://localhost:4318/v1/traces');
const spanExporter = tracingOptions.spanExporterFactory(tracingOptions)[0];
assert.strictEqual(
exporterUrl(spanExporter),
'http://localhost:4318/v1/traces'
);

const metricsUrl =
metricsOptions.metricReaderFactory(metricsOptions)[0]['_exporter'][
'_otlpExporter'
].url;
assert.strictEqual(metricsUrl, 'http://localhost:4318/v1/metrics');
const metricsExporter =
metricsOptions.metricReaderFactory(metricsOptions)[0]['_exporter'];
assert.strictEqual(
exporterUrl(metricsExporter),
'http://localhost:4318/v1/metrics'
);

const logsUrl =
loggingOptions.logRecordProcessorFactory(loggingOptions)[0]['_exporter']
.url;
assert.strictEqual(logsUrl, 'http://localhost:4318/v1/logs');
const logsExporter =
loggingOptions.logRecordProcessorFactory(loggingOptions)[0]['_exporter'];
assert.strictEqual(
exporterUrl(logsExporter),
'http://localhost:4318/v1/logs'
);

const profilingUrl =
profilingOptions.exporterFactory(profilingOptions)[0]['_endpoint'];
Expand Down
12 changes: 5 additions & 7 deletions test/metrics.options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('metrics options', () => {
const exporter = reader['_exporter'];
assert(exporter instanceof OTLPHttpProtoMetricExporter);
assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'http://foobar:4200/v1/metrics'
);
});
Expand All @@ -126,7 +126,7 @@ describe('metrics options', () => {

assert(exporter instanceof OTLPHttpProtoMetricExporter);
assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'https://ingest.us0.signalfx.com/v2/datapoint/otlp'
);
const msg = `OTLP metric exporter: defaulting protocol to 'http/protobuf' instead of 'grpc' due to realm being defined.`;
Expand All @@ -151,14 +151,12 @@ describe('metrics options', () => {
assert(exporter instanceof OTLPHttpProtoMetricExporter);

assert.deepStrictEqual(
exporter._otlpExporter['_transport']['_transport']['_parameters'][
'headers'
]['X-SF-TOKEN'],
utils.exporterHeaders(exporter)['X-SF-TOKEN'],
'abc'
);

assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'https://ingest.eu0.signalfx.com/v2/datapoint/otlp'
);
});
Expand All @@ -178,7 +176,7 @@ describe('metrics options', () => {

assert(exporter instanceof OTLPHttpProtoMetricExporter);
assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'http://localhost:4320/v1/metrics'
);
});
Expand Down
13 changes: 8 additions & 5 deletions test/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ describe('options', () => {
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(
exporter.url,
utils.exporterUrl(exporter),
`https://ingest.us0.signalfx.com/v2/trace/otlp`
);
});
Expand Down Expand Up @@ -386,7 +386,7 @@ describe('options', () => {
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(
exporter.url,
utils.exporterUrl(exporter),
'https://ingest.us0.signalfx.com/v2/trace/otlp'
);
const oneLogMatches = logger.warn.mock.calls.some((call) =>
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('options', () => {
'Expected exporter to be instance of OTLPTraceExporter'
);
assert.deepStrictEqual(
exporter.url,
utils.exporterUrl(exporter),
'http://myendpoint:4333/v1/my-traces'
);
});
Expand Down Expand Up @@ -463,7 +463,10 @@ describe('options', () => {
assert(Array.isArray(exporters));
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(exporter.url, 'foobar:4200/v1/traces');
assert.deepStrictEqual(
utils.exporterUrl(exporter),
'foobar:4200/v1/traces'
);
});

it('prefers OTEL_EXPORTER_OTLP_TRACES_ENDPOINT over OTEL_EXPORTER_OTLP_ENDPOINT', () => {
Expand All @@ -474,7 +477,7 @@ describe('options', () => {
assert(Array.isArray(exporters));
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(exporter.url, 'barfoo:2400');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'barfoo:2400');
});
});
});
Expand Down
10 changes: 3 additions & 7 deletions test/tracing/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { ProxyTracerProvider } from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { exporterHeaders, exporterUrl } from '../utils';

export function setupMocks() {
const addSpanProcessorMock = mock.method(
Expand Down Expand Up @@ -55,14 +56,9 @@ export function assertTracingPipeline(
provider.resource.attributes[ATTR_SERVICE_NAME],
serviceName
);
assert.strictEqual(exporter.url, exportURL);
assert.strictEqual(exporterUrl(exporter), exportURL);

if (accessToken) {
assert.equal(
exporter['_transport']['_transport']['_parameters']['headers'][
'X-SF-TOKEN'
],
accessToken
);
assert.equal(exporterHeaders(exporter)['X-SF-TOKEN'], accessToken);
}
}
Loading

0 comments on commit 099ce4a

Please sign in to comment.