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

Commit

Permalink
chore: upgrade instrumentations to otel 1.13.0/0.39.1 (#262)
Browse files Browse the repository at this point in the history
* feat: upgrade instrumentations to otel 1.13.0/0.39.1

* fix: ReadableSpan conversion

* chore: prettier

* fix dep

* chore: prettier

---------

Co-authored-by: Motti Bechhofer <mybechhofer@gmail.com>
  • Loading branch information
seemk and mottibec authored Jul 26, 2023
1 parent c539814 commit 67eb37b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The instrumentations in this repo are:
- strictly complies with [open telemetry semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/trace/semantic_conventions)
- up to date with latest SDK version

**Compatible with [SDK stable ^1.8.0](https://github.com/open-telemetry/opentelemetry-js/tree/stable/v1.8.0) and [SDK experimental ^0.35.0](https://github.com/open-telemetry/opentelemetry-js/tree/experimental/v0.35.0)**
**Compatible with [SDK stable ^1.13.0](https://github.com/open-telemetry/opentelemetry-js/tree/v1.13.0) and [SDK experimental ^0.39.1](https://github.com/open-telemetry/opentelemetry-js/tree/experimental/v0.39.1)**
## Instrumentations
| Instrumentation Package | Instrumented Lib | NPM |
|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------| --- |
Expand Down
8 changes: 4 additions & 4 deletions packages/instrumentation-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0"
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0"
},
"devDependencies": {
"@elastic/elasticsearch": "^7.8.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@types/chai": "^4.2.15",
"@types/mocha": "^8.2.2",
"chai": "^4.3.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/instrumentation-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0",
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/instrumentation-http": "^0.35.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/instrumentation-http": "^0.39.1",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/express": "4.17.8",
"@types/mocha": "^8.2.2",
"axios": "0.21.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/instrumentation-kafkajs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0"
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"kafkajs": "^1.12.0",
"kafkajs": "^1.16.0",
"mocha": "^8.4.0",
"opentelemetry-instrumentation-mocha": "0.0.1-rc.7",
"ts-node": "^9.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/instrumentation-neo4j/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0"
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
Expand Down
11 changes: 6 additions & 5 deletions packages/instrumentation-node-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0"
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/instrumentation-sequelize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0"
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.14.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/instrumentation-typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.8.0",
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/instrumentation": "^0.41.0",
"@opentelemetry/semantic-conventions": "^1.13.0",
"is-promise": "^4.0.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/contrib-test-utils": "^0.33.1",
"@opentelemetry/sdk-trace-base": "1.8.0",
"@opentelemetry/contrib-test-utils": "^0.34.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@types/mocha": "^8.2.2",
"expect": "^26.6.2",
"mocha": "^8.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/span-transformations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"dependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/sdk-trace-base": "^1.0.0"
"@opentelemetry/core": "^1.13.0",
"@opentelemetry/sdk-trace-base": "^1.8.0"
},
"devDependencies": {
"@types/mocha": "^8.2.2",
Expand Down
22 changes: 18 additions & 4 deletions packages/span-transformations/src/jaeger.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { SpanAttributes, SpanKind, SpanStatusCode } from '@opentelemetry/api';
import { Attributes, SpanKind, SpanStatusCode } from '@opentelemetry/api';
import { timeInputToHrTime } from '@opentelemetry/core';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { Resource } from '@opentelemetry/resources';
import { JaegerSpan, JaegerTag } from './interfaces/jaeger';

const getJaegerValueForTag = (jaegerTagKey: string, tags: JaegerTag[]) =>
tags.find(({ key }) => jaegerTagKey === key)?.value;
const convertJaegerTagsToAttributes = (tags): SpanAttributes => {
const spanAttributes: SpanAttributes = {};
const convertJaegerTagsToAttributes = (tags): Attributes => {
const spanAttributes: Attributes = {};
tags.forEach(({ key, value }) => {
spanAttributes[key] = value;
});
return spanAttributes;
};

const getNumberValue = (attributes: Attributes, key: string): number | undefined => {
const value = attributes[key];

if (typeof value === 'number') {
return value;
}

return undefined;
};

const getOtelKindFromJaegerKind = (jaegerKind: string) => {
switch (jaegerKind) {
case 'client':
Expand Down Expand Up @@ -47,11 +57,12 @@ export const convertJaegerSpanToOtelReadableSpan = (jaegerSpan: JaegerSpan): Rea
const durationMillis = jaegerSpan.duration / 1000;
const startDateMillis = jaegerSpan.startTime / 1000;
const endDateMillis = timeInputToHrTime(new Date(startDateMillis + durationMillis));
const attributes = convertJaegerTagsToAttributes(jaegerSpan.tags);

return {
name: jaegerSpan.operationName,
kind: getOtelKindFromJaegerKind(getJaegerValueForTag('span.kind', jaegerSpan.tags)),
attributes: convertJaegerTagsToAttributes(jaegerSpan.tags),
attributes,
parentSpanId: getParentSpanID(jaegerSpan),
duration: timeInputToHrTime(durationMillis),
startTime: timeInputToHrTime(startDateMillis),
Expand All @@ -74,5 +85,8 @@ export const convertJaegerSpanToOtelReadableSpan = (jaegerSpan: JaegerSpan): Rea
resource: new Resource({
'service.name': getJaegerValueForTag('service.name', jaegerSpan.tags),
}),
droppedAttributesCount: getNumberValue(attributes, 'otel.dropped_attributes_count') || 0,
droppedEventsCount: getNumberValue(attributes, 'otel.dropped_events_count') || 0,
droppedLinksCount: getNumberValue(attributes, 'otel.dropped_links_count') || 0,
};
};

0 comments on commit 67eb37b

Please sign in to comment.