Documentation Index
Fetch the complete documentation index at: https://docs.infrastack.ai/llms.txt
Use this file to discover all available pages before exploring further.
What you will learn
- Configuring the infrastack.ai Javascript SDK for your needs
Prerequisites
- An application using the infrastack.ai Javascript SDK
@infrastack/otel
Overview
Our Javascript SDK provides flexibility to developers to configure the SDK. There are 2 ways to configure the SDK:- Via environment variables
- Via code
Setting the API Key
API key is required when you initialize the SDK to use it with infrastack.ai. To set the API key, you can set theapiKey option in the Infrastack.init function or set the INFRASTACK_API_KEY environment variable.
Setting the service name
The service name is used to identify the service in the infrastack.ai dashboard. To set the service name, you can set theserviceName option in the Infrastack.init function or set the OTEL_SERVICE_NAME environment variable.
If you do not provide a service name from either of the options, it will generate a random service name.
Setting the service version
The service version is used to identify the version of the service in the infrastack.ai dashboard. It becomes useful to capture deployment information and other versioning information. If you do not provide a service version from either of the options, it will default to0.0.1.
To set the service version, you can set the serviceVersion option in the Infrastack.init function or set the OTEL_SERVICE_VERSION environment variable.
Development mode
Development mode is disabled by default. In that case, it will not log anything to the console and will useBatchSpanProcessor for span exports.
Visit the Documentation OpenTelemetry - Picking the right span processor for more information.
To toggle development mode, you can set the developmentMode option to true in the Infrastack.init function or set the INFRASTACK_DEVELOPMENT_MODE environment variable to true.
Disabling the SDK logs
By default, when you set up the SDK and run your application, you will see logs in the console as below:logsEnabled option to false in the Infrastack.init function or set the INFRASTACK_LOGS_ENABLED environment variable to false.
Tags
You can define a set of tags to enrich your spans. It is also recommended to add the tag for your environment (Production, Staging, Development etc.) All of these tags will be added to every span that is created. To set the tags, you can set thetags option in the Infrastack.init function or set the INFRASTACK_TAGS environment variable.
Configuring the exporter endpoint
By default, the SDK will use theinfrastack.ai collector endpoint. However, it can be overriden to use a different endpoint.
To set the endpoint, you can set the endpoint option in the Infrastack.init function or set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
Configuring the exporter protocol
By default, the SDK will use thegrpc protocol. However, it can be overriden to use a different protocol.
To set the protocol, you can set the protocol option in the Infrastack.init function or set the OTEL_EXPORTER_OTLP_PROTOCOL environment variable.
http protocol to export the spans to the collector.
Disabling instrumentations
You can disable specific instrumentations by setting thedisabledInstrumentations option in the Infrastack.init function or set the INFRASTACK_DISABLED_INSTRUMENTATIONS environment variable.
List of instrumentations can be found here.