-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: prefer use of global TracerProvider/MeterProvider (#450)
Remove setting of TracerProvider in samples where it is actually not needed as the global TracerProvider should be preferred on default. I found it also inconsistent to set a TracerProvider but no MeterProvider. Co-authored-by: Daniel Dyla <[email protected]> Co-authored-by: Valentin Marchaud <[email protected]> Co-authored-by: Naseem <[email protected]>
- Loading branch information
1 parent
862ab4e
commit 041508f
Showing
24 changed files
with
75 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,6 @@ registerInstrumentations({ | |
// mergeItems: true, | ||
}), | ||
], | ||
tracerProvider: provider, | ||
}); | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,10 @@ For automatic instrumentation see the | |
```bash | ||
npm install --save @opentelemetry/instrumentation-hapi | ||
``` | ||
|
||
### Supported Versions | ||
- @hapi/hapi `^17.0.0` | ||
|
||
- @hapi/hapi `^17.0.0` | ||
|
||
## Usage | ||
|
||
|
@@ -27,12 +29,15 @@ To load a specific instrumentation (Hapi in this case), specify it in the regist | |
```js | ||
const { NodeTracerProvider } = require('@opentelemetry/node'); | ||
const { registerInstrumentations } = require('@opentelemetry/instrumentation'); | ||
const { HapiInstrumentation } = require('@opentelemetry/instrumentation-hapi'); | ||
|
||
const provider = new NodeTracerProvider(); | ||
provider.register(); | ||
|
||
registerInstrumentations({ | ||
tracerProvider: provider, | ||
instrumentations: [ | ||
new HapiInstrumentation(), | ||
], | ||
}); | ||
``` | ||
|
||
|
@@ -48,34 +53,18 @@ const hapiInstrumentation = new HapiInstrumentation(); | |
hapiInstrumentation.setTracerProvider(provider); | ||
``` | ||
|
||
You can combine loading default plugins and HapiInstrumentation at the same time: | ||
|
||
```js | ||
const { NodeTracerProvider } = require('@opentelemetry/node'); | ||
const { HapiInstrumentation } = require('@opentelemetry/instrumentation-hapi'); | ||
const { registerInstrumentations } = require('@opentelemetry/instrumentation'); | ||
|
||
const provider = new NodeTracerProvider(); | ||
provider.register(); | ||
|
||
registerInstrumentations({ | ||
instrumentations: [ | ||
new HapiInstrumentation(), | ||
], | ||
tracerProvider: provider, | ||
}); | ||
``` | ||
|
||
See [examples/hapi](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/hapi) for a short example using Hapi | ||
|
||
<!-- | ||
The dev dependency of `@hapi/[email protected]` is required to force the compatible type declarations. See: https://github.com/hapijs/hapi/issues/4240 | ||
--> | ||
|
||
## Hapi Instrumentation Support | ||
|
||
This package provides automatic tracing for hapi server routes and [request lifecycle](https://github.com/hapijs/hapi/blob/main/API.md#request-lifecycle) extensions defined either directly or via a Hapi plugin. | ||
|
||
## Useful links | ||
|
||
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js> | ||
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.