This is a Boomerang plugin for collecting spans using the OpenTelemetry framework and exporting them, e.g., to an OpenTelemetry collector. The plugin is based on the opentelemetry-js implementation. The plugin version always corresponds to the opentelemetry-js version that's being used internally.
Currently implemented features:
- Automatic instrumentation of asynhrounous XHR requests with the B3 propagation. More details ↗
- Provides access to the OpenTelemtry Tracing-API for manual instrumentation
The basic setup requires only to include the boomerang-opentelemetry.js
file to the list of the boomerang plugins to run.
This setup works out-of-the-box with the inspectit-ocelot EUM server and traces will be sent to the server endpoint relative to the defined beacon_url
Boomerang property.
If you want to use the standard OpenTelemetry collector, check out the configuration section.
The plugin is configured using the standard Boomerang configuration. All available configuration options are optional.
<script>
BOOMR.init({
beacon_url: 'http://localhost:8080/beacon/',
OpenTelemetry: {
samplingRate: 0.5,
corsUrls: ['https://my.backend.com'],
collectorConfiguration: {
url: 'http://my.opentelemetry.collector'
}
}
});
</script>
Available options are:
| Option | Description | Default value |
|---|---|---|
| `collectorConfiguration` | Object that defines the OpenTelemetry collector configuration, like the URL to send spans to. See [CollectorExporterConfig](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-exporter-collector/src/CollectorExporter.ts) interface for all options. | `undefined` |
| `samplingRate` | Sampling rate to use when collecting spans. Value must be [0-1]. | `1` |
| `corsUrls` | Array of CORS URLs to take into consideration when propagating trace information. By default, CORS URLs are excluded from the propagation. | `[]` |
| `consoleOnly` | If `true` spans will be logged on the console and not sent to the OpenTelemetry collector. | `false` |
## Manual Instrumentation
The boomerang OpenTelemetry Plugin also exposes the OpenTelemetry tracing API for manual instrumentation:
var tracer = window.BOOMR.plugins.OpenTelemetry.getTracer("my-library-name", "0.1.0");
var span = tracer.startSpan("doSomething", { parent: tracer.getCurrentSpan() }); tracer.withSpan(span2, function() => { //do something here... }) span.end();
Make sure to check that `window.BOOMR.plugins.OpenTelemetry` actually exists prior to using it in your code in case you load boomerang asynchronously.