Skip to content

Commit

Permalink
Merge branch 'main' into hectorhdzg/winstonLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorhdzg authored Apr 18, 2024
2 parents 3a2256d + df2fa5a commit e69b6b3
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 1,133 deletions.
5 changes: 0 additions & 5 deletions .github/component-label-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pkg:instrumentation-aws-lambda:
- changed-files:
- any-glob-to-any-file:
- plugins/node/opentelemetry-instrumentation-aws-lambda/**
- propagators/opentelemetry-propagator-aws-xray/**
pkg:instrumentation-aws-sdk:
- changed-files:
- any-glob-to-any-file:
Expand Down Expand Up @@ -246,10 +245,6 @@ pkg:propagation-utils:
- any-glob-to-any-file:
- packages/opentelemetry-propagation-utils/**
- packages/opentelemetry-test-utils/**
pkg:propagator-aws-xray:
- changed-files:
- any-glob-to-any-file:
- propagators/opentelemetry-propagator-aws-xray/**
pkg:propagator-grpc-census-binary:
- changed-files:
- any-glob-to-any-file:
Expand Down
2 changes: 0 additions & 2 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ components:
- obecny
plugins/web/opentelemetry-plugin-react-load:
- martinkuba
propagators/opentelemetry-propagator-aws-xray:
- carolabadeer
propagators/opentelemetry-propagator-grpc-census-binary: []
# Unmaintained?
propagators/opentelemetry-propagator-instana:
Expand Down
1 change: 0 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"plugins/web/opentelemetry-instrumentation-long-task": "0.37.0",
"plugins/web/opentelemetry-instrumentation-user-interaction": "0.37.0",
"plugins/web/opentelemetry-plugin-react-load": "0.30.0",
"propagators/opentelemetry-propagator-aws-xray": "1.3.1",
"propagators/opentelemetry-propagator-grpc-census-binary": "0.27.1",
"propagators/opentelemetry-propagator-instana": "0.3.1",
"propagators/opentelemetry-propagator-ot-trace": "0.27.1"
Expand Down
90 changes: 18 additions & 72 deletions package-lock.json

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

30 changes: 25 additions & 5 deletions plugins/node/instrumentation-undici/test/undici.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ describe('UndiciInstrumentation `undici` tests', function () {
propagation.disable();
mockServer.mockListener(undefined);
mockServer.stop(done);

// Close kept-alive sockets. This can save a 4s keep-alive delay before the
// process exits.
(undici as any).getGlobalDispatcher().close();
});

beforeEach(function () {
Expand Down Expand Up @@ -216,11 +220,27 @@ describe('UndiciInstrumentation `undici` tests', function () {
};

const queryRequestUrl = `${protocol}://${hostname}:${mockServer.port}/?query=test`;
const firstQueryResponse = await undici.request(queryRequestUrl, {
headers,
// @ts-expect-error - method type expects in uppercase
method: 'get',
});
let firstQueryResponse;
try {
firstQueryResponse = await undici.request(queryRequestUrl, {
headers,
// @ts-expect-error - method type expects in uppercase
method: 'get',
});
} catch (err: any) {
// This request is using a bogus HTTP method `get`. If (a) using Node.js
// v14, v16, or early v18.x versions and (b) this request is re-using
// a socket (from an earlier keep-alive request in this test file),
// then Node.js will emit 'end' on the socket. Undici then throws
// `SocketError: other side closed`. Given this is only for old Node.js
// versions and for this rare case of using a bogus HTTP method, we will
// skip out of this test instead of attempting to fully understand it.
assert.strictEqual(err.message, 'other side closed');
this.skip();
}
if (!firstQueryResponse) {
return;
}
await consumeResponseBody(firstQueryResponse.body);

const secondQueryResponse = await undici.request(queryRequestUrl, {
Expand Down
18 changes: 18 additions & 0 deletions plugins/node/opentelemetry-instrumentation-knex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ registerInstrumentations({
| ------- | ---- | ------- | ----------- |
| `maxQueryLength` | `number` | `100` | Truncate `db.statement` attribute to a maximum length. If the statement is truncated `'..'` is added to it's end. Default `1022`. `-1` leaves `db.statement` untouched. |

## 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.name` | This attribute is used to report the name of the database being accessed. |
| `db.operation` | The name of the operation being executed. |
| `db.sql.table` | The name of the primary table that the operation is acting upon. |
| `db.statement` | The database statement being executed. |
| `db.system` | An identifier for the database management system (DBMS) product being used. |
| `db.user` | Username for accessing the database. |
| `net.peer.name` | Remote hostname or similar. |
| `net.peer.port` | Remote port number. |
| `net.transport` | Transport protocol used. |

## 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 @@ -58,7 +58,7 @@
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.50.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.22.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-knex#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ import {
InstrumentationNodeModuleFile,
isWrapped,
} from '@opentelemetry/instrumentation';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_DB_NAME,
SEMATTRS_DB_OPERATION,
SEMATTRS_DB_SQL_TABLE,
SEMATTRS_DB_STATEMENT,
SEMATTRS_DB_SYSTEM,
SEMATTRS_DB_USER,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
SEMATTRS_NET_TRANSPORT,
} from '@opentelemetry/semantic-conventions';
import * as utils from './utils';
import * as types from './types';

Expand Down Expand Up @@ -144,18 +154,18 @@ export class KnexInstrumentation extends InstrumentationBase<any> {

const attributes: api.SpanAttributes = {
'knex.version': moduleVersion,
[SemanticAttributes.DB_SYSTEM]: utils.mapSystem(config.client),
[SemanticAttributes.DB_SQL_TABLE]: table,
[SemanticAttributes.DB_OPERATION]: operation,
[SemanticAttributes.DB_USER]: config?.connection?.user,
[SemanticAttributes.DB_NAME]: name,
[SemanticAttributes.NET_PEER_NAME]: config?.connection?.host,
[SemanticAttributes.NET_PEER_PORT]: config?.connection?.port,
[SemanticAttributes.NET_TRANSPORT]:
[SEMATTRS_DB_SYSTEM]: utils.mapSystem(config.client),
[SEMATTRS_DB_SQL_TABLE]: table,
[SEMATTRS_DB_OPERATION]: operation,
[SEMATTRS_DB_USER]: config?.connection?.user,
[SEMATTRS_DB_NAME]: name,
[SEMATTRS_NET_PEER_NAME]: config?.connection?.host,
[SEMATTRS_NET_PEER_PORT]: config?.connection?.port,
[SEMATTRS_NET_TRANSPORT]:
config?.connection?.filename === ':memory:' ? 'inproc' : undefined,
};
if (maxLen !== 0) {
attributes[SemanticAttributes.DB_STATEMENT] = utils.limitLength(
attributes[SEMATTRS_DB_STATEMENT] = utils.limitLength(
query?.sql,
maxLen
);
Expand Down
9 changes: 6 additions & 3 deletions plugins/node/opentelemetry-instrumentation-knex/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
* limitations under the License.
*/

import { DbSystemValues } from '@opentelemetry/semantic-conventions';
import {
DBSYSTEMVALUES_SQLITE,
DBSYSTEMVALUES_POSTGRESQL,
} from '@opentelemetry/semantic-conventions';

type Exception = {
new (message: string): Exception;
Expand Down Expand Up @@ -52,8 +55,8 @@ export const cloneErrorWithNewMessage = (err: Exception, message: string) => {
};

const systemMap = new Map([
['sqlite3', DbSystemValues.SQLITE],
['pg', DbSystemValues.POSTGRESQL],
['sqlite3', DBSYSTEMVALUES_SQLITE],
['pg', DBSYSTEMVALUES_POSTGRESQL],
]);
export const mapSystem = (knexSystem: string) => {
return systemMap.get(knexSystem) || knexSystem;
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions propagators/opentelemetry-propagator-aws-xray/.eslintrc.js

This file was deleted.

62 changes: 0 additions & 62 deletions propagators/opentelemetry-propagator-aws-xray/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit e69b6b3

Please sign in to comment.