Skip to content

Commit

Permalink
upgrade to otel 1.24.0 / 0.51.0 (#902)
Browse files Browse the repository at this point in the history
* upgrade to otel 1.23.0 / 0.50.0

* add explicit types for attributes

* fix sequelize tests

* upgrade prebuildify

* fix nodejs versions for windows unit tests

* update mocha, reduce parallel jobs

* increase parallel unit tests

* upgrade to otel 1.24.0 / 0.51.0

* no node 14 on macos latest, prefer macos-13
  • Loading branch information
seemk authored Apr 26, 2024
1 parent aa8c645 commit 8cf3960
Show file tree
Hide file tree
Showing 8 changed files with 842 additions and 886 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,29 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-2019', 'macos-latest']
os: ['ubuntu-latest', 'macos-latest']
nodejs: ['14', '16', '17', '18', '20', '21']
exclude:
- os: 'macos-latest'
nodejs: '14'
include:
- os: 'macos-latest'
python_version: '3.11'
- os: 'macos-latest'
- os: 'macos-13'
nodejs: '14'
python_version: '3.10'
- os: 'windows-2019'
nodejs: '14'
- os: 'windows-2019'
nodejs: '16'
- os: 'windows-2019'
nodejs: '17'
- os: 'windows-2019'
nodejs: '18.20.1'
- os: 'windows-2019'
nodejs: '20.12.1'
- os: 'windows-2019'
nodejs: '21.7.2'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
1,455 changes: 708 additions & 747 deletions package-lock.json

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@commitlint/config-conventional": "^18.6.0",
"@elastic/elasticsearch": "^7.17.11",
"@types/bunyan": "1.8.8",
"@types/mocha": "10.0.1",
"@types/mocha": "10.0.6",
"@types/semver": "^7.5.0",
"@types/shimmer": "1.0.5",
"@types/sinon": "^10.0.2",
Expand All @@ -81,14 +81,14 @@
"eslint-plugin-prettier": "^4.2.1",
"gts": "^5.0.0",
"kafkajs": "^2.2.4",
"mocha": "^10.2.0",
"mocha": "^10.4.0",
"mysql2": "^2.2.5",
"nock": "^13.3.1",
"nyc": "15.1.0",
"octokit": "^3.1.2",
"pg": "^8.4.2",
"pino": "^8.7.0",
"prebuildify": "^5.0.1",
"prebuildify": "^6.0.1",
"prettier": "^2.8.4",
"redis": "^3.1.2",
"rewire": "^6.0.0",
Expand All @@ -103,55 +103,55 @@
"dependencies": {
"@grpc/grpc-js": "^1.9.14",
"@grpc/proto-loader": "^0.7.10",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/api-logs": "^0.48.0",
"@opentelemetry/context-async-hooks": "1.21.0",
"@opentelemetry/core": "1.21.0",
"@opentelemetry/exporter-logs-otlp-http": "^0.48.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.48.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.48.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.48.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.48.0",
"@opentelemetry/instrumentation": "0.48.0",
"@opentelemetry/instrumentation-amqplib": "0.34.0",
"@opentelemetry/instrumentation-aws-sdk": "0.38.0",
"@opentelemetry/instrumentation-bunyan": "0.35.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.35.0",
"@opentelemetry/instrumentation-connect": "0.33.0",
"@opentelemetry/instrumentation-dataloader": "0.6.0",
"@opentelemetry/instrumentation-dns": "0.33.0",
"@opentelemetry/instrumentation-express": "0.35.0",
"@opentelemetry/instrumentation-fastify": "0.33.0",
"@opentelemetry/instrumentation-generic-pool": "0.33.0",
"@opentelemetry/instrumentation-graphql": "0.37.0",
"@opentelemetry/instrumentation-grpc": "0.48.0",
"@opentelemetry/instrumentation-hapi": "0.34.0",
"@opentelemetry/instrumentation-http": "0.48.0",
"@opentelemetry/instrumentation-ioredis": "0.37.0",
"@opentelemetry/instrumentation-knex": "0.33.0",
"@opentelemetry/instrumentation-koa": "0.37.0",
"@opentelemetry/instrumentation-memcached": "0.33.0",
"@opentelemetry/instrumentation-mongodb": "0.39.0",
"@opentelemetry/instrumentation-mongoose": "0.35.0",
"@opentelemetry/instrumentation-mysql": "0.35.0",
"@opentelemetry/instrumentation-mysql2": "0.35.0",
"@opentelemetry/instrumentation-nestjs-core": "0.34.0",
"@opentelemetry/instrumentation-net": "0.33.0",
"@opentelemetry/instrumentation-pg": "0.38.0",
"@opentelemetry/instrumentation-pino": "0.35.0",
"@opentelemetry/instrumentation-redis": "0.36.0",
"@opentelemetry/instrumentation-redis-4": "0.36.0",
"@opentelemetry/instrumentation-restify": "0.35.0",
"@opentelemetry/instrumentation-router": "0.34.0",
"@opentelemetry/instrumentation-tedious": "0.7.0",
"@opentelemetry/instrumentation-winston": "0.34.0",
"@opentelemetry/propagator-b3": "1.21.0",
"@opentelemetry/resources": "1.21.0",
"@opentelemetry/sdk-logs": "^0.48.0",
"@opentelemetry/sdk-metrics": "1.21.0",
"@opentelemetry/sdk-trace-base": "1.21.0",
"@opentelemetry/sdk-trace-node": "1.21.0",
"@opentelemetry/semantic-conventions": "1.21.0",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/api-logs": "^0.51.0",
"@opentelemetry/context-async-hooks": "1.24.0",
"@opentelemetry/core": "1.24.0",
"@opentelemetry/exporter-logs-otlp-http": "^0.51.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.51.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.51.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.51.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.51.0",
"@opentelemetry/instrumentation": "0.51.0",
"@opentelemetry/instrumentation-amqplib": "0.37.0",
"@opentelemetry/instrumentation-aws-sdk": "0.41.0",
"@opentelemetry/instrumentation-bunyan": "0.38.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.38.0",
"@opentelemetry/instrumentation-connect": "0.36.0",
"@opentelemetry/instrumentation-dataloader": "0.9.0",
"@opentelemetry/instrumentation-dns": "0.36.0",
"@opentelemetry/instrumentation-express": "0.38.0",
"@opentelemetry/instrumentation-fastify": "0.36.0",
"@opentelemetry/instrumentation-generic-pool": "0.36.0",
"@opentelemetry/instrumentation-graphql": "0.40.0",
"@opentelemetry/instrumentation-grpc": "0.51.0",
"@opentelemetry/instrumentation-hapi": "0.37.0",
"@opentelemetry/instrumentation-http": "0.51.0",
"@opentelemetry/instrumentation-ioredis": "0.40.0",
"@opentelemetry/instrumentation-knex": "0.36.0",
"@opentelemetry/instrumentation-koa": "0.40.0",
"@opentelemetry/instrumentation-memcached": "0.36.0",
"@opentelemetry/instrumentation-mongodb": "0.43.0",
"@opentelemetry/instrumentation-mongoose": "0.38.0",
"@opentelemetry/instrumentation-mysql": "0.38.0",
"@opentelemetry/instrumentation-mysql2": "0.38.0",
"@opentelemetry/instrumentation-nestjs-core": "0.37.0",
"@opentelemetry/instrumentation-net": "0.36.0",
"@opentelemetry/instrumentation-pg": "0.41.0",
"@opentelemetry/instrumentation-pino": "0.38.0",
"@opentelemetry/instrumentation-redis": "0.39.0",
"@opentelemetry/instrumentation-redis-4": "0.39.0",
"@opentelemetry/instrumentation-restify": "0.38.0",
"@opentelemetry/instrumentation-router": "0.37.0",
"@opentelemetry/instrumentation-tedious": "0.10.0",
"@opentelemetry/instrumentation-winston": "0.37.0",
"@opentelemetry/propagator-b3": "1.24.0",
"@opentelemetry/resources": "1.24.0",
"@opentelemetry/sdk-logs": "^0.51.0",
"@opentelemetry/sdk-metrics": "1.24.0",
"@opentelemetry/sdk-trace-base": "1.24.0",
"@opentelemetry/sdk-trace-node": "1.24.0",
"@opentelemetry/semantic-conventions": "1.24.0",
"is-promise": "^4.0.0",
"nan": "^2.18.0",
"node-gyp-build": "^4.8.0",
Expand Down
13 changes: 4 additions & 9 deletions src/instrumentations/external/elasticsearch/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ enum AttributeNames {
ELASTICSEARCH_INDICES = 'elasticsearch.request.indices',
}

export class ElasticsearchInstrumentation extends InstrumentationBase<
typeof elasticsearch
> {
export class ElasticsearchInstrumentation extends InstrumentationBase {
static readonly component = '@elastic/elasticsearch';

protected override _config: ElasticsearchInstrumentationConfig = {};
Expand All @@ -60,11 +58,10 @@ export class ElasticsearchInstrumentation extends InstrumentationBase<
this._config = Object.assign({}, config);
}

protected init(): InstrumentationModuleDefinition<typeof elasticsearch> {
protected init(): InstrumentationModuleDefinition {
const apiModuleFiles = ELASTICSEARCH_API_FILES.map(
({ path, operationClassName }) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new InstrumentationNodeModuleFile<any>(
new InstrumentationNodeModuleFile(
`@elastic/elasticsearch/api/${path}`,
['>=5 <8'],
(moduleExports, moduleVersion) => {
Expand Down Expand Up @@ -110,9 +107,7 @@ export class ElasticsearchInstrumentation extends InstrumentationBase<
)
);

const module = new InstrumentationNodeModuleDefinition<
typeof elasticsearch
>(
const module = new InstrumentationNodeModuleDefinition(
ElasticsearchInstrumentation.component,
['*'],
undefined,
Expand Down
57 changes: 25 additions & 32 deletions src/instrumentations/external/kafkajs/kafkajs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ import { VERSION } from '../../../version';
import { bufferTextMapGetter } from './propagator';
import {
InstrumentationBase,
InstrumentationModuleDefinition,
InstrumentationNodeModuleDefinition,
safeExecuteInTheMiddle,
isWrapped,
} from '@opentelemetry/instrumentation';

export class KafkaJsInstrumentation extends InstrumentationBase<
typeof kafkaJs
> {
export class KafkaJsInstrumentation extends InstrumentationBase {
static readonly component = 'kafkajs';
protected override _config!: KafkaJsInstrumentationConfig;
private moduleVersion?: string;
Expand All @@ -71,10 +68,8 @@ export class KafkaJsInstrumentation extends InstrumentationBase<
this._config = Object.assign({}, config);
}

protected init(): InstrumentationModuleDefinition<typeof kafkaJs> {
const unpatch: InstrumentationModuleDefinition<
typeof kafkaJs
>['unpatch'] = (moduleExports) => {
protected init() {
const unpatch = (moduleExports: typeof kafkaJs) => {
diag.debug('kafkajs instrumentation: un-patching');
if (isWrapped(moduleExports?.Kafka?.prototype.producer)) {
this._unwrap(moduleExports.Kafka.prototype, 'producer');
Expand All @@ -83,31 +78,29 @@ export class KafkaJsInstrumentation extends InstrumentationBase<
this._unwrap(moduleExports.Kafka.prototype, 'consumer');
}
};
const module: InstrumentationModuleDefinition<typeof kafkaJs> =
new InstrumentationNodeModuleDefinition<typeof kafkaJs>(
KafkaJsInstrumentation.component,
['*'],
(moduleExports, moduleVersion) => {
diag.debug('kafkajs instrumentation: applying patch');
this.moduleVersion = moduleVersion;

unpatch(moduleExports);
this._wrap(
moduleExports?.Kafka?.prototype,
'producer',
this._getProducerPatch()
);
this._wrap(
moduleExports?.Kafka?.prototype,
'consumer',
this._getConsumerPatch()
);
const module = new InstrumentationNodeModuleDefinition(
KafkaJsInstrumentation.component,
['*'],
(moduleExports, moduleVersion) => {
diag.debug('kafkajs instrumentation: applying patch');
this.moduleVersion = moduleVersion;

unpatch(moduleExports);
this._wrap(
moduleExports?.Kafka?.prototype,
'producer',
this._getProducerPatch()
);
this._wrap(
moduleExports?.Kafka?.prototype,
'consumer',
this._getConsumerPatch()
);

return moduleExports;
},
unpatch
);
module.includePrerelease = true;
return moduleExports;
},
unpatch
);
return module;
}

Expand Down
51 changes: 23 additions & 28 deletions src/instrumentations/external/sequelize/sequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ import { VERSION } from '../../../version';
import { extractTableFromQuery } from './utils';
import {
InstrumentationBase,
InstrumentationModuleDefinition,
InstrumentationNodeModuleDefinition,
InstrumentationNodeModuleFile,
isWrapped,
safeExecuteInTheMiddle,
} from '@opentelemetry/instrumentation';

export class SequelizeInstrumentation extends InstrumentationBase<
typeof sequelize
> {
export class SequelizeInstrumentation extends InstrumentationBase {
static readonly component = 'sequelize';
protected override _config!: SequelizeInstrumentationConfig;
private moduleVersion?: string;
Expand All @@ -58,7 +55,7 @@ export class SequelizeInstrumentation extends InstrumentationBase<
this._config = Object.assign({}, config);
}

protected init(): InstrumentationModuleDefinition<typeof sequelize> {
protected init() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const unpatchConnectionManager = (moduleExports: any) => {
if (
Expand All @@ -71,35 +68,33 @@ export class SequelizeInstrumentation extends InstrumentationBase<
}
return moduleExports;
};
const connectionManagerInstrumentation =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new InstrumentationNodeModuleFile<any>(
'sequelize/lib/dialects/abstract/connection-manager.js',
['*'],
(moduleExports) => {
if (moduleExports === undefined || moduleExports === null) {
return moduleExports;
}
diag.debug(
`sequelize instrumentation: applying patch to sequelize ConnectionManager`
);
unpatchConnectionManager(moduleExports);
this._wrap(
moduleExports.ConnectionManager.prototype,
'getConnection',
this._getConnectionPatch()
);
const connectionManagerInstrumentation = new InstrumentationNodeModuleFile(
'sequelize/lib/dialects/abstract/connection-manager.js',
['*'],
(moduleExports) => {
if (moduleExports === undefined || moduleExports === null) {
return moduleExports;
},
unpatchConnectionManager
);
}
diag.debug(
`sequelize instrumentation: applying patch to sequelize ConnectionManager`
);
unpatchConnectionManager(moduleExports);
this._wrap(
moduleExports.ConnectionManager.prototype,
'getConnection',
this._getConnectionPatch()
);
return moduleExports;
},
unpatchConnectionManager
);

const unpatch = (moduleExports: typeof sequelize) => {
if (isWrapped(moduleExports.Sequelize.prototype.query)) {
this._unwrap(moduleExports.Sequelize.prototype, 'query');
}
};
const module = new InstrumentationNodeModuleDefinition<typeof sequelize>(
const module = new InstrumentationNodeModuleDefinition(
SequelizeInstrumentation.component,
['*'],
(moduleExports, moduleVersion) => {
Expand Down Expand Up @@ -172,7 +167,7 @@ export class SequelizeInstrumentation extends InstrumentationBase<
else tableName = extractTableFromQuery(statement);
}

const attributes = {
const attributes: Record<string, any> = {
[SemanticAttributes.DB_SYSTEM]: sequelizeInstance.getDialect(),
[SemanticAttributes.DB_USER]: config?.username,
[SemanticAttributes.NET_PEER_NAME]: config?.host,
Expand Down
Loading

0 comments on commit 8cf3960

Please sign in to comment.