The Sumo Logic OpenTelemetry auto-instrumentation for JavaScript library enables tracing in the browser.
The easiest way to start collecting traces from your website is to put the code below inside the <head></head>
tags on your website:
<script
src="https://cdn-nite-www.sumologic.net/ui/js/thirdparty/sumologic-opentelemetry.js"
data-collection-source-url="sumo_logic_traces_collector_source_url"
data-service-name="name_of_your_web_application"
>
See functionalities for informations about the script size and configuration for all supported options.
There are no other required actions needed to take. With properly provided data-collection-source-url
and data-service-name
your website is ready and will send collected traces to the specified Sumo Logic collector.
You can load the script asynchronously by adding the async
flag but some functionalities like user interactions or requests made before script run will be limited.
The other option is to bundle this library inside your project and initialize it.
Inside your project directory execute npm install @sumologic/opentelemetry-tracing
.
Tracing needs to be initialized preferably before other functionalities in your code:
import { initializeTracing } from '@sumologic/opentelemetry-tracing';
initializeTracing({
collectionSourceUrl: 'sumo_logic_traces_collector_source_url',
serviceName: 'name_of_your_web_service',
});
This library contains built-in OpenTelemetry packages:
- @opentelemetry/core
- @opentelemetry/tracing
- @opentelemetry/web
- @opentelemetry/plugin-xml-http-request
- @opentelemetry/context-zone
- @opentelemetry/plugin-document-load
- @opentelemetry/plugin-user-interaction
See @opentelemetry/plugin-xml-http-request, @opentelemetry/plugin-document-load and @opentelemetry/plugin-user-interaction for more details about auto-instrumented functionalities.
To connect your traces with backend operations, make sure you support W3C Trace Context HTTP headers.
Both script
tag and manual installation can be configured with following parameters:
Parameter | data- Attribute |
Type | Default | Description |
---|---|---|---|---|
collectionSourceUrl | data-collection-source-url | string |
required | Sumo Logic collector source url |
authorizationToken | data-authorization-token | string |
Sumo Logic collector authorization token | |
serviceName | data-service-name | string |
"unknown" |
Name of your web service |
applicationName | data-application-name | string |
Name of your application | |
defaultAttributes | data-default-attributes | object |
{} |
Attributes added to each span |
samplingProbability | data-sampling-probability | number |
1 |
1 means all traces are sent, 0 - no traces are send, 0.5 - there is 50% change for a trace to be sent |
bufferMaxSpans | data-buffer-max-spans | number |
100 |
Maximum number of spans waiting to be send |
bufferTimeout | data-buffer-timeout | number |
2000 ms |
Maximum time in milliseconds for spans waiting to be send |
ignoreUrls | data-ignore-urls | (string|RegExp)[] |
[] |
List of URLs from which traces will not be collected |
propagateTraceHeaderCorsUrls | data-propagate-trace-header-cors-urls | (string|RegExp)[] |
[/.*/] |
List of URLs where W3C Trace Context HTTP headers will be injected |
This project is released under the Apache 2.0 License.
Please refer to our Contributing documentation to get started.
Please refer to our Code of Conduct.