Skip to content

Commit

Permalink
Merge branch 'main' into mongo-net-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored Oct 30, 2022
2 parents 41d9f12 + e72ea58 commit 5787c3e
Show file tree
Hide file tree
Showing 145 changed files with 919 additions and 554 deletions.
41 changes: 41 additions & 0 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Instrumentations Implementation Guide

This document captures general guidelines for implementing instrumentations in NodeJS and browser.

## Types

### Public Types

Public types are meant to be consumed by instrumentation users (OpenTelemetry distribution packages or end users implementing OpenTelemetry in their services). These are mostly instrumentation specific config interface (extending `InstrumentationConfig`) and the transitive types used in the config.

#### File Name

These typescript `interface`s, `type`s, `enum`s and js `const`ants statements SHOULD be placed in a file named `types.ts`. This file SHOULD contain only public types that are needed for instrumentation users.

#### Exporting

All types from `types.ts` file MUST be exported from instrumentation `index.ts` using export statement `export * from './types'`, which guarentee that they publicly available.

#### Breaking Changes

Since these types are publicly exported, a breaking change in this file can cause transpilation issues or require code changes for existing users. Special care and attention should be put when modifiying this file to guarantee backword compatibility or proper documentation of breaking changes.

### Internal Types

All types and constants that instrumentation needs internally to implement the instrumentation logic. This can include extensions to instrumented package interfaces (for example - when adding data to existing objects), symbols for patches, enums etc.

#### File Name

It is sometimes convenient to place these declarations in a dedicated file which can then be imported from various instrumentation files such as `instrumentation.ts`, `utils.ts` or test files.

The file SHOULD be named `internal-types.ts`.

Using this file is optional - when a type is used only in a single file, it is ok to declare it and use it in this file **without exporting it**. When a type is expected to be shared between multiple files, it is encourged to be declared in `internal-types.ts` to prevent circular dependencies.

#### Exporting

This file MUST NOT be exported publicly from instrumentation package, not directly (via `index.ts`) and not transitivly via export of other files.

#### Changes

Since the declarations in this file are not exported in the public instrumentation api, it is allowed to apply any refactors to this file, and they will not be breaking changes to users.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@types/mocha": "8.2.3",
"@types/node": "^17.0.14",
"@types/node": "^18.0.0",
"@types/sinon": "10.0.2",
"eslint-plugin-header": "^3.1.1",
"gts": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/semver": "7.3.8",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand All @@ -61,7 +61,7 @@
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"gcp-metadata": "^4.1.4",
"gcp-metadata": "^5.0.0",
"semver": "7.3.5"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@opentelemetry/sdk-node": "^0.32.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/semver": "7.3.8",
"mocha": "7.2.0",
"nock": "12.0.3",
Expand Down
2 changes: 1 addition & 1 deletion metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"babel-loader": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-host-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-id-generator-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"gts": "3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-propagation-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.31.0",
"@types/mocha": "^9.1.1",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "^10.0.11",
"expect": "27.4.2",
"gts": "3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"gts": "3.1.0",
"typescript": "4.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-amqplib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@types/lodash": "4.14.178",
"@types/mocha": "8.2.3",
"@types/sinon": "10.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"amqplib": "0.8.0",
"expect": "27.4.2",
"lodash": "4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-dataloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@opentelemetry/sdk-trace-base": "^1.6.0",
"@opentelemetry/sdk-trace-node": "^1.6.0",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"dataloader": "2.0.0",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-dataloader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
* limitations under the License.
*/

export { DataloaderInstrumentationConfig } from './types';
export * from './types';
export { DataloaderInstrumentation } from './instrumentation';
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@opentelemetry/sdk-trace-node": "^1.3.1",
"@types/mocha": "7.0.2",
"@types/node": "14.17.9",
"@types/node": "18.11.7",
"@types/sinon": "^10.0.11",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
8 changes: 1 addition & 7 deletions plugins/node/instrumentation-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ import FsInstrumentation from './instrumentation';
export { FsInstrumentation };

export * from './instrumentation';
export {
FMember,
FPMember,
CreateHook,
EndHook,
FsInstrumentationConfig,
} from './types';
export * from './types';

export default FsInstrumentation;
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-lru-memoizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@types/lru-cache": "7.10.9",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"expect": "25.5.0",
"gts": "3.1.0",
"lru-memoizer": "2.1.4",
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"expect": "27.4.2",
"gts": "3.1.0",
"mocha": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-tedious/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"gts": "3.1.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-tedious/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ import { TediousInstrumentation } from './instrumentation';
export * from './instrumentation';
export default TediousInstrumentation;

export { TediousInstrumentationConfig } from './types';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@opentelemetry/sdk-trace-node": "^1.3.1",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"gts": "3.1.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
*/

export * from './instrumentation';
export {
AwsLambdaInstrumentationConfig,
RequestHook,
ResponseHook,
} from './types';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ import {
Handler,
} from 'aws-lambda';

import {
LambdaModule,
AwsLambdaInstrumentationConfig,
EventContextExtractor,
} from './types';
import { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types';
import { VERSION } from './version';
import { LambdaModule } from './internal-types';

const awsPropagator = new AWSXRayPropagator();
const headerGetter: TextMapGetter<APIGatewayProxyEventHeaders> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Handler } from 'aws-lambda';

export type LambdaModule = Record<string, Handler>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

import { Span, Context as OtelContext } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { Handler, Context } from 'aws-lambda';

export type LambdaModule = Record<string, Handler>;
import type { Context } from 'aws-lambda';

export type RequestHook = (
span: Span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@opentelemetry/contrib-test-utils": "^0.32.0",
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.6",
"aws-sdk": "2.1008.0",
"eslint": "8.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@opentelemetry/sdk-trace-node": "^1.3.1",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
"bunyan": "1.8.15",
"gts": "3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

export * from './instrumentation';
export * from './types';
10 changes: 5 additions & 5 deletions plugins/node/opentelemetry-instrumentation-cassandra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ await client.execute('select * from foo');

### Instrumentation options

| Option | Type | Default | Description |
| ------ | ---- | ------- | ----------- |
| `enhancedDatabaseReporting` | `boolean` | `false` | Whether to include database queries with spans. These can contain sensitive information when using unescaped parameters - i.e. `insert into persons (name) values ('Bob')` instead of `insert into persons (name) values (?)`. |
| `maxQueryLength` | `number` | `65536` | If `enhancedDatabaseReporting` is enabled, limits the attached query strings
to this length. |
| Option | Type | Default | Description |
|-----------------------------|--------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `enhancedDatabaseReporting` | `boolean` | `false` | Whether to include database queries with spans. These can contain sensitive information when using unescaped parameters - i.e. `insert into persons (name) values ('Bob')` instead of `insert into persons (name) values (?)`. |
| `responseHook` | `CassandraDriverResponseCustomAttributeFunction` | `undefined` | Hook for adding custom attributes before response is handled |
| `maxQueryLength` | `number` | `65536` | If `enhancedDatabaseReporting` is enabled, limits the attached query strings to this length. |

### Supported versions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@opentelemetry/sdk-trace-base": "^1.3.1",
"@opentelemetry/sdk-trace-node": "^1.3.1",
"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/semver": "7.3.8",
"@types/sinon": "10.0.2",
"cassandra-driver": "4.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

export * from './instrumentation';
export { CassandraDriverInstrumentationConfig } from './types';
export * from './types';
Loading

0 comments on commit 5787c3e

Please sign in to comment.