Skip to content

Commit

Permalink
Merge branch 'main' into sem-bunyan
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm authored May 14, 2024
2 parents 3595a08 + 416337e commit 6d8ae8a
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 140 deletions.
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions plugins/node/opentelemetry-instrumentation-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Downstream spans in the context of all resolvers will be child of the first span

Can be found [here](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/graphql)

## Semantic Conventions

This package does not currently generate any attributes from semantic conventions.

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@opentelemetry/semantic-conventions": "^1.3.1",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@types/mocha": "8.2.3",
"@types/node": "18.6.5",
"graphql": "^16.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import { Span, SpanStatusCode } from '@opentelemetry/api';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_EXCEPTION_MESSAGE } from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import type * as graphqlTypes from 'graphql';
import { GraphQLInstrumentation } from '../src';
Expand Down Expand Up @@ -1399,7 +1399,7 @@ describe('graphql', () => {
const resolveEvent = resolveSpan.events[0];
assert.deepStrictEqual(resolveEvent.name, 'exception');
assert.deepStrictEqual(
resolveEvent.attributes?.[SemanticAttributes.EXCEPTION_MESSAGE],
resolveEvent.attributes?.[SEMATTRS_EXCEPTION_MESSAGE],
'sync resolver error from tests'
);

Expand Down
14 changes: 14 additions & 0 deletions plugins/node/opentelemetry-instrumentation-ioredis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ requestHook: function (

```

## Semantic Conventions

This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md)

Attributes collected:

| Attribute | Short Description |
|------------------------|-----------------------------------------------------------------------------|
| `db.connection_string` | The connection string used to connect to the database. |
| `db.statement` | The database statement being executed. |
| `db.system` | An identifier for the database management system (DBMS) product being used. |
| `net.peer.name` | Remote hostname or similar. |
| `net.peer.port` | Remote port number. |

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"dependencies": {
"@opentelemetry/instrumentation": "^0.51.0",
"@opentelemetry/redis-common": "^0.36.2",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.23.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ import {
import { IORedisInstrumentationConfig } from './types';
import { IORedisCommand, RedisInterface } from './internal-types';
import {
DbSystemValues,
SemanticAttributes,
DBSYSTEMVALUES_REDIS,
SEMATTRS_DB_CONNECTION_STRING,
SEMATTRS_DB_STATEMENT,
SEMATTRS_DB_SYSTEM,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
} from '@opentelemetry/semantic-conventions';
import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
import { endSpan } from './utils';
Expand Down Expand Up @@ -121,11 +125,8 @@ export class IORedisInstrumentation extends InstrumentationBase {
const span = instrumentation.tracer.startSpan(cmd.name, {
kind: SpanKind.CLIENT,
attributes: {
[SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,
[SemanticAttributes.DB_STATEMENT]: dbStatementSerializer(
cmd.name,
cmd.args
),
[SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS,
[SEMATTRS_DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args),
},
});

Expand All @@ -149,9 +150,9 @@ export class IORedisInstrumentation extends InstrumentationBase {
const { host, port } = this.options;

span.setAttributes({
[SemanticAttributes.NET_PEER_NAME]: host,
[SemanticAttributes.NET_PEER_PORT]: port,
[SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
[SEMATTRS_NET_PEER_NAME]: host,
[SEMATTRS_NET_PEER_PORT]: port,
[SEMATTRS_DB_CONNECTION_STRING]: `redis://${host}:${port}`,
});

try {
Expand Down Expand Up @@ -201,16 +202,16 @@ export class IORedisInstrumentation extends InstrumentationBase {
const span = instrumentation.tracer.startSpan('connect', {
kind: SpanKind.CLIENT,
attributes: {
[SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,
[SemanticAttributes.DB_STATEMENT]: 'connect',
[SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS,
[SEMATTRS_DB_STATEMENT]: 'connect',
},
});
const { host, port } = this.options;

span.setAttributes({
[SemanticAttributes.NET_PEER_NAME]: host,
[SemanticAttributes.NET_PEER_PORT]: port,
[SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
[SEMATTRS_NET_PEER_NAME]: host,
[SEMATTRS_NET_PEER_PORT]: port,
[SEMATTRS_DB_CONNECTION_STRING]: `redis://${host}:${port}`,
});
try {
const client = original.apply(this, arguments);
Expand Down
Loading

0 comments on commit 6d8ae8a

Please sign in to comment.