Skip to content

Commit

Permalink
Add browser-detector plugin (#52)
Browse files Browse the repository at this point in the history
* add browser detector

* update spanProcessing

* add configuration option

* update README

* fix README
  • Loading branch information
EddeCCC authored Feb 16, 2024
1 parent 5253e4f commit 8a44d3b
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 96 deletions.
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ A list of OpenTelemetry instrumentation and non-instrumentation plugins that are
* [@opentelemetry/instrumentation-fetch](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch)
* [@opentelemetry/instrumentation-document-load](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load)
* [@opentelemetry/instrumentation-user-interaction](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction)
* [@opentelemetry/browser-detector](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-browser-detector)

## Setup

Expand Down Expand Up @@ -103,7 +104,8 @@ BOOMR.init({
instrument_fetch: true,
instrument_xhr: true,
instrument_document_load: true,
instrument_user_interaction: true
instrument_user_interaction: true,
browser_detector: true
},
// Additional instrumentation config, which will be applied to all plugins
global_instrumentation: {
Expand All @@ -130,27 +132,28 @@ BOOMR.init({
```
Available options are:

| Option | Description | Default value |
|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| `samplingRate` | Sampling rate to use when collecting spans. Value must be between `0` and `1`. | `1` |
| `corsUrls` | Array of CORS URLs to take into consideration when propagating trace information. By default, CORS URLs are excluded from the propagation. | `[]` |
| `collectorConfiguration` | Object that defines the OpenTelemetry collector configuration, like the URL to send spans to. See [OTLPExporterNodeConfigBase](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-http) interface for all options. | `undefined` |
| `consoleOnly` | If `true` spans will be logged on the console and not sent to the collector endpoint. | `false` |
| `plugins` | Object for enabling and disabling OpenTelemetry plugins. | |
| `plugins.instrument_fetch` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch) for instrumentation of the fetch API. This will only be used in case the `fetch` API exists. | `true` |
| `plugins.instrument_xhr` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request) for instrumentation of the XMLHttpRequest API. | `true` |
| `plugins.instrument_document_load` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load) for instrumentation of the document load (initial request). | `true` |
| `plugins.instrument_user_interaction` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction) for instrumentation of user interactions. | `true` |
| `global_instrumentation` | Object for configuring additional instrumentations, which will be applied to every OpenTelemetry plugin. ||
| `global_instrumentation.requestParameter` | If enabled, existing request parameters will be added as attributes to spans and, if not excluded, will be added to the corresponding beacon as well. ||
| `exporter` | Object for configuring the span exporter. Only used if `consoleOnly` is not enabled. ||
| `exporter.maxQueueSize` | The maximum queue size. After the size is reached spans are dropped. | `100` |
| `exporter.maxExportBatchSize` | The maximum batch size of every export. It must be smaller or equal to `maxQueueSize`. | `10` |
| `exporter.scheduledDelayMillis` | The interval between two consecutive exports. | `500` |
| `exporter.exportTimeoutMillis` | How long the export can run before it is cancelled. | `30000` |
| `commonAttributes` | An Object defining common span attributes which will be added to each recorded span. | `{}` |
| `serviceName` | A `string` or function which can be used to set the spans' service name. A function can be defined for dynamically providing the service name, e.g. based on Boomerang values. | `undefined` |
| `propagationHeader` | Defines the format of the context propagation header. Available formats: `TRACE_CONTEXT`, `B3_SINGLE`, `B3_MULTI` | `TRACE_CONTEXT` |
| Option | Description | Default value |
|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| `samplingRate` | Sampling rate to use when collecting spans. Value must be between `0` and `1`. | `1` |
| `corsUrls` | Array of CORS URLs to take into consideration when propagating trace information. By default, CORS URLs are excluded from the propagation. | `[]` |
| `collectorConfiguration` | Object that defines the OpenTelemetry collector configuration, like the URL to send spans to. See [OTLPExporterNodeConfigBase](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-http) interface for all options. | `undefined` |
| `consoleOnly` | If `true` spans will be logged on the console and not sent to the collector endpoint. | `false` |
| `plugins` | Object for enabling and disabling OpenTelemetry plugins. | |
| `plugins.instrument_fetch` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch) for instrumentation of the fetch API. This will only be used in case the `fetch` API exists. | `true` |
| `plugins.instrument_xhr` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request) for instrumentation of the XMLHttpRequest API. | `true` |
| `plugins.instrument_document_load` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load) for instrumentation of the document load (initial request). | `true` |
| `plugins.instrument_user_interaction` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction) for instrumentation of user interactions. | `true` |
| `plugins.browser_detector` | Enabling the [OpenTelemetry plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-browser-detector) for detecting browser attributes. | `true` |
| `global_instrumentation` | Object for configuring additional instrumentations, which will be applied to every OpenTelemetry plugin. | |
| `global_instrumentation.requestParameter` | If enabled, existing request parameters will be added as attributes to spans and, if not excluded, will be added to the corresponding beacon as well. | |
| `exporter` | Object for configuring the span exporter. Only used if `consoleOnly` is not enabled. | |
| `exporter.maxQueueSize` | The maximum queue size. After the size is reached spans are dropped. | `100` |
| `exporter.maxExportBatchSize` | The maximum batch size of every export. It must be smaller or equal to `maxQueueSize`. | `10` |
| `exporter.scheduledDelayMillis` | The interval between two consecutive exports. | `500` |
| `exporter.exportTimeoutMillis` | How long the export can run before it is cancelled. | `30000` |
| `commonAttributes` | An Object defining common span attributes which will be added to each recorded span. | `{}` |
| `serviceName` | A `string` or function which can be used to set the spans' service name. A function can be defined for dynamically providing the service name, e.g. based on Boomerang values. | `undefined` |
| `propagationHeader` | Defines the format of the context propagation header. Available formats: `TRACE_CONTEXT`, `B3_SINGLE`, `B3_MULTI` | `TRACE_CONTEXT` |

## Manual Instrumentation

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@opentelemetry/instrumentation-fetch": "^0.48.0",
"@opentelemetry/instrumentation-user-interaction": "^0.35.0",
"@opentelemetry/instrumentation-xml-http-request": "^0.48.0",
"@opentelemetry/opentelemetry-browser-detector": "^0.48.0",
"@opentelemetry/propagator-b3": "^1.21.0",
"@opentelemetry/sdk-trace-web": "^1.21.0",
"regenerator-runtime": "^0.14.1",
Expand Down
Loading

0 comments on commit 8a44d3b

Please sign in to comment.