Skip to content

Commit

Permalink
fix: remove express types from dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna committed Nov 16, 2023
1 parent 7370386 commit 0983c72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

8 changes: 8 additions & 0 deletions plugins/node/opentelemetry-instrumentation-express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ Express instrumentation has few options available to choose from. You can set th
- `info: ExpressRequestInfo` containing the incoming Express.js request, the current route handler creating a span and `ExpressLayerType` - the type of the handling layer.
- `defaultName: string` - original name proposed by the instrumentation.

`requestHook` is invoked with 2 arguments:

- `span: Span` - the span associated with the express request.
- `info: ExpressRequestInfo` containing the incoming Express.js request, the current route handler creating a span and `ExpressLayerType` - the type of the handling layer.

NOTE: `ExpressRequestInfo.request` is typed as `any`. If you want type support make sure you have `@types/express` installed then you can use `ExpressRequestInfo<express.Request>`


#### Ignore a whole Express route

In order to ignore whole traces that represent a given Express route, use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@opentelemetry/context-async-hooks": "^1.8.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@opentelemetry/sdk-trace-node": "^1.8.0",
"@types/express": "4.17.18",
"@types/mocha": "7.0.2",
"@types/node": "18.6.5",
"@types/sinon": "10.0.18",
Expand All @@ -64,8 +65,7 @@
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@types/express": "4.17.18"
"@opentelemetry/semantic-conventions": "^1.0.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

import type { Request } from 'express';
import { Span } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { ExpressLayerType } from './enums/ExpressLayerType';

export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);

export type ExpressRequestInfo = {
request: Request;
export type ExpressRequestInfo<T = any> = {
/** An express request object */
request: T;
route: string;
layerType: ExpressLayerType;
};
Expand All @@ -36,6 +36,7 @@ export type SpanNameHook = (
defaultName: string
) => string;


/**
* Function that can be used to add custom attributes to the current span or the root span on
* a Express request
Expand All @@ -47,7 +48,7 @@ export interface ExpressRequestCustomAttributeFunction {
}

/**
* Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-Instrumentation-express#express-Instrumentation-options))
* Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#express-instrumentation-options))
*/
export interface ExpressInstrumentationConfig extends InstrumentationConfig {
/** Ignore specific based on their name */
Expand Down

0 comments on commit 0983c72

Please sign in to comment.