Skip to content

Commit

Permalink
refactor(instr-router): use exported strings for attributes (#2099)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
  • Loading branch information
david-luna and pichlermarc authored Apr 17, 2024
1 parent fae3010 commit 34796e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 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.

10 changes: 10 additions & 0 deletions plugins/node/opentelemetry-instrumentation-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ registerInstrumentations({

See [examples/router](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/router) for a short example.

## 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 |
| ------------ | ---------------------------------- |
| `http.route` | The matched route (path template). |

## 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 @@ -57,7 +57,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-router#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
InstrumentationNodeModuleFile,
isWrapped,
} from '@opentelemetry/instrumentation';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';

import * as http from 'http';
import type * as Router from 'router';
Expand Down Expand Up @@ -182,7 +182,7 @@ export default class RouterInstrumentation extends InstrumentationBase<any> {
[AttributeNames.NAME]: fnName,
[AttributeNames.VERSION]: this._moduleVersion,
[AttributeNames.TYPE]: type,
[SemanticAttributes.HTTP_ROUTE]: route,
[SEMATTRS_HTTP_ROUTE]: route,
};

const parent = api.context.active();
Expand Down

0 comments on commit 34796e2

Please sign in to comment.