Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
upgrade otel versions (#272)
Browse files Browse the repository at this point in the history
* try to upgrade otel versions

* run prettier

* fix all ts errors

* prettier

* fix build and test

* update aspecto-opentelemetry-instrumentation-mocha

* update node version

* update ts and skipLibCheck

* update ts-node

* fix tests

* change neo4j docker version

---------

Co-authored-by: Motti Bechhofer <motti.bechhofer@smartbear.com>
  • Loading branch information
mottibec and Motti Bechhofer authored May 16, 2024
1 parent 3be217b commit acdc802
Show file tree
Hide file tree
Showing 45 changed files with 592 additions and 461 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/daily-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
- 27017:27017

neo4j:
image: neo4j:4.2.3
image: neo4j:4.4.34
ports:
- 7474:7474
- 11011:7687
env:
NEO4J_AUTH: neo4j/test
NEO4J_AUTH: neo4j/your_password


steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
- 27017:27017

neo4j:
image: neo4j:4.2.3
image: neo4j:4.4.34
ports:
- 7474:7474
- 11011:7687
env:
NEO4J_AUTH: neo4j/test
NEO4J_AUTH: neo4j/your_password

steps:

Expand All @@ -39,10 +39,10 @@ jobs:
- name: Fetch all history for all tags and branches
run: git fetch

- name: Use Node.js 14
- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18

- name: Install Dependencies
run: yarn install
Expand Down
16 changes: 8 additions & 8 deletions detectors/node/resource-detector-deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
},
"peerDependencies": {
"@opentelemetry/api": "^1.6.0"
"@opentelemetry/api": "^1.8.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"@opentelemetry/resources": "~1.24.1",
"@opentelemetry/semantic-conventions": "^1.24.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/api": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
"opentelemetry-instrumentation-mocha": "0.0.7-alpha.1",
"ts-node": "^9.1.1",
"typescript": "4.3.4"
"aspecto-opentelemetry-instrumentation-mocha": "0.0.9-alpha.0",
"ts-node": "^10.9.2",
"typescript": "5.4.5"
},
"mocha": {
"extension": [
Expand All @@ -56,7 +56,7 @@
"spec": "test/**/*.spec.ts",
"require": [
"ts-node/register",
"opentelemetry-instrumentation-mocha"
"aspecto-opentelemetry-instrumentation-mocha"
]
}
}
16 changes: 8 additions & 8 deletions detectors/node/resource-detector-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
},
"peerDependencies": {
"@opentelemetry/api": "^1.6.0"
"@opentelemetry/api": "^1.8.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"@opentelemetry/resources": "~1.24.1",
"@opentelemetry/semantic-conventions": "^1.24.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/api": "^1.8.0",
"@types/mocha": "^8.2.2",
"@types/node": "^14.0.0",
"expect": "^26.6.2",
"mocha": "^8.4.0",
"opentelemetry-instrumentation-mocha": "0.0.7-alpha.1",
"aspecto-opentelemetry-instrumentation-mocha": "0.0.9-alpha.0",
"sinon": "^11.1.1",
"ts-node": "^9.1.1",
"typescript": "4.3.4"
"ts-node": "^10.9.2",
"typescript": "5.4.5"
},
"mocha": {
"extension": [
Expand All @@ -60,7 +60,7 @@
"spec": "test/**/*.spec.ts",
"require": [
"ts-node/register",
"opentelemetry-instrumentation-mocha"
"aspecto-opentelemetry-instrumentation-mocha"
]
}
}
16 changes: 8 additions & 8 deletions detectors/node/resource-detector-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
},
"peerDependencies": {
"@opentelemetry/api": "^1.6.0"
"@opentelemetry/api": "^1.8.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"@opentelemetry/resources": "~1.24.1",
"@opentelemetry/semantic-conventions": "^1.24.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/api": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
"opentelemetry-instrumentation-mocha": "0.0.7-alpha.1",
"ts-node": "^9.1.1",
"typescript": "4.3.4"
"aspecto-opentelemetry-instrumentation-mocha": "0.0.9-alpha.0",
"ts-node": "^10.9.2",
"typescript": "5.4.5"
},
"mocha": {
"extension": [
Expand All @@ -57,7 +57,7 @@
"spec": "test/**/*.spec.ts",
"require": [
"ts-node/register",
"opentelemetry-instrumentation-mocha"
"aspecto-opentelemetry-instrumentation-mocha"
]
}
}
10 changes: 5 additions & 5 deletions detectors/resource-detector-sync-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
},
"peerDependencies": {
"@opentelemetry/api": "^1.6.0"
"@opentelemetry/api": "^1.8.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1"
"@opentelemetry/resources": "~1.24.1"
},
"devDependencies": {
"@opentelemetry/api": "^1.6.0",
"ts-node": "^9.1.1",
"typescript": "4.3.4"
"@opentelemetry/api": "^1.8.0",
"ts-node": "^10.9.2",
"typescript": "5.4.5"
}
}
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"packages": ["packages/*", "detectors/*", "detectors/node/*", "propagators/*", "examples/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
"npmClient": "yarn"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"test:ci:all": "lerna run test:ci --parallel",
"build": "lerna run build",
"build:ci": "lerna run build",
"postinstall": "lerna bootstrap",
"prettier": "prettier --config .prettierrc.yml --write --ignore-unknown \"**/*\"",
"prettier:check": "npx prettier@2.3.2 --config .prettierrc.yml --check --ignore-unknown \"**/*\"",
"prettier:check": "npx prettier@3.2.5 --config .prettierrc.yml --check --ignore-unknown \"**/*\"",
"version:update": "lerna run version:update",
"version": "git add packages/**/version.ts",
"publish:ci": "lerna publish --yes --allow-branch master --create-release github --conventionalCommits",
"publish:ci:prerelease": "lerna publish --yes --no-git-tag-version --no-push --no-changelog --dist-tag alpha"
},
"devDependencies": {
"lerna": "^3.22.1",
"prettier": "2.3.2"
"@types/node": "^20.12.12",
"lerna": "^8.1.3",
"prettier": "3.2.5"
},
"workspaces": [
"packages/*",
Expand Down
20 changes: 10 additions & 10 deletions packages/instrumentation-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@
"url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues"
},
"peerDependencies": {
"@opentelemetry/api": "^1.6.0"
"@opentelemetry/api": "^1.8.0"
},
"dependencies": {
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/semantic-conventions": "^1.17.1"
"@opentelemetry/core": "^1.24.1",
"@opentelemetry/instrumentation": "^0.51.1",
"@opentelemetry/semantic-conventions": "^1.24.1"
},
"devDependencies": {
"@elastic/elasticsearch": "^7.8.0",
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/contrib-test-utils": "^0.34.2",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/contrib-test-utils": "^0.39.0",
"@types/chai": "^4.2.15",
"@types/mocha": "^8.2.2",
"chai": "^4.3.0",
"expect": "^26.6.2",
"mocha": "^8.4.0",
"nock": "^13.0.9",
"opentelemetry-instrumentation-mocha": "0.0.7-alpha.1",
"aspecto-opentelemetry-instrumentation-mocha": "0.0.9-alpha.0",
"sinon": "^9.2.4",
"test-all-versions": "^5.0.1",
"ts-node": "^9.1.1",
"typescript": "4.3.4"
"ts-node": "^10.9.2",
"typescript": "5.4.5"
},
"mocha": {
"extension": [
Expand All @@ -72,7 +72,7 @@
"spec": "test/**/*.spec.ts",
"require": [
"ts-node/register",
"opentelemetry-instrumentation-mocha"
"aspecto-opentelemetry-instrumentation-mocha"
]
}
}
20 changes: 11 additions & 9 deletions packages/instrumentation-elasticsearch/src/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@opentelemetry/instrumentation';
import { VERSION } from './version';
import { AttributeNames } from './enums';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_DB_OPERATION, SEMATTRS_DB_STATEMENT, SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
startSpan,
onError,
Expand All @@ -21,7 +21,7 @@ import {
} from './utils';
import { ELASTICSEARCH_API_FILES } from './helpers';

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

protected override _config: ElasticsearchInstrumentationConfig;
Expand All @@ -36,18 +36,18 @@ export class ElasticsearchInstrumentation extends InstrumentationBase<typeof ela
this._config = Object.assign({}, config);
}

protected init(): InstrumentationModuleDefinition<typeof elasticsearch> {
protected init(): InstrumentationModuleDefinition {
const apiModuleFiles = ELASTICSEARCH_API_FILES.map(
({ path, operationClassName }) =>
new InstrumentationNodeModuleFile<any>(
new InstrumentationNodeModuleFile(
`@elastic/elasticsearch/api/${path}`,
['>=5 <8'],
this.patch.bind(this, operationClassName),
this.unpatch.bind(this)
)
);

const module = new InstrumentationNodeModuleDefinition<typeof elasticsearch>(
const module = new InstrumentationNodeModuleDefinition(
ElasticsearchInstrumentation.component,
['*'],
undefined,
Expand Down Expand Up @@ -120,11 +120,13 @@ export class ElasticsearchInstrumentation extends InstrumentationBase<typeof ela
const span = startSpan({
tracer: self.tracer,
attributes: {
[SemanticAttributes.DB_OPERATION]: operation,
[SEMATTRS_DB_OPERATION]: operation,
[AttributeNames.ELASTICSEARCH_INDICES]: getIndexName(params),
[SemanticAttributes.DB_STATEMENT]: (
self._config.dbStatementSerializer || defaultDbStatementSerializer
)(operation, params, options),
[SEMATTRS_DB_STATEMENT]: (self._config.dbStatementSerializer || defaultDbStatementSerializer)(
operation,
params,
options
),
},
});
self._addModuleVersionIfNeeded(span);
Expand Down
15 changes: 10 additions & 5 deletions packages/instrumentation-elasticsearch/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Tracer, SpanAttributes, SpanStatusCode, diag, Span, SpanKind } from '@opentelemetry/api';
import { DbStatementSerializer, ResponseHook } from './types';
import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_DB_SYSTEM,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
SEMATTRS_NET_TRANSPORT,
} from '@opentelemetry/semantic-conventions';
import { ApiResponse } from '@elastic/elasticsearch/lib/Transport';

interface StartSpanPayload {
Expand All @@ -27,7 +32,7 @@ export function startSpan({ tracer, attributes }: StartSpanPayload): Span {
return tracer.startSpan('elasticsearch.request', {
kind: SpanKind.CLIENT,
attributes: {
[SemanticAttributes.DB_SYSTEM]: 'elasticsearch',
[SEMATTRS_DB_SYSTEM]: 'elasticsearch',
...attributes,
},
});
Expand Down Expand Up @@ -60,9 +65,9 @@ export function getNetAttributes(url: string): SpanAttributes {
const { port, protocol, hostname } = new URL(url);

return {
[SemanticAttributes.NET_TRANSPORT]: 'IP.TCP',
[SemanticAttributes.NET_PEER_NAME]: hostname,
[SemanticAttributes.NET_PEER_PORT]: getPort(port, protocol),
[SEMATTRS_NET_TRANSPORT]: 'IP.TCP',
[SEMATTRS_NET_PEER_NAME]: hostname,
[SEMATTRS_NET_PEER_PORT]: getPort(port, protocol),
};
}

Expand Down
15 changes: 10 additions & 5 deletions packages/instrumentation-elasticsearch/test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { stub, assert, spy } from 'sinon';
import { expect } from 'chai';
import * as Utils from '../src/utils';
import { SpanKind, SpanStatusCode } from '@opentelemetry/api';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_DB_SYSTEM,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
SEMATTRS_NET_TRANSPORT,
} from '@opentelemetry/semantic-conventions';

describe('elasticsearch utils', () => {
const spanMock = {
Expand Down Expand Up @@ -92,15 +97,15 @@ describe('elasticsearch utils', () => {
const attributes = Utils.getNetAttributes(url);

it('should get hostname from url', () => {
expect(attributes[SemanticAttributes.NET_PEER_NAME]).to.equal('localhost');
expect(attributes[SEMATTRS_NET_PEER_NAME]).to.equal('localhost');
});

it('should get hostname from url', () => {
expect(attributes[SemanticAttributes.NET_PEER_PORT]).to.equal('9200');
expect(attributes[SEMATTRS_NET_PEER_PORT]).to.equal('9200');
});

it('should set net.transport', () => {
expect(attributes[SemanticAttributes.NET_TRANSPORT]).to.equal('IP.TCP');
expect(attributes[SEMATTRS_NET_TRANSPORT]).to.equal('IP.TCP');
});
});

Expand Down Expand Up @@ -190,7 +195,7 @@ describe('elasticsearch utils', () => {

expect(operation).to.equal('elasticsearch.request');
expect(options.kind).to.equal(SpanKind.CLIENT);
expect(options.attributes[SemanticAttributes.DB_SYSTEM]).to.equal('elasticsearch');
expect(options.attributes[SEMATTRS_DB_SYSTEM]).to.equal('elasticsearch');
expect(options.attributes.testAttribute).to.equal('testValue');
});
});
Expand Down
Loading

0 comments on commit acdc802

Please sign in to comment.