Skip to main content
Logs support in the OpenTelemetry JavaScript SDK is currently experimental and subject to change. To check the status for each language, refer to the OpenTelemetry status page.
This example shows how to configure the OpenTelemetry JavaScript SDK to capture Bunyan logging calls and send logs from a JavaScript application to Honeycomb or an OpenTelemetry Collector.
1

Acquire Dependencies

Install the OpenTelemetry Node.js SDK, Bunyan instrumentation, and Bunyan logging framework packages:
2

Configure the SDK

Create an initialization file (for example, telemetry.js) that sets up the SDK with Bunyan instrumentation. The exporter configuration is provided by the otelconfig.yaml file at runtime.
Then, in your application, create and use Bunyan loggers to capture interesting things:
3

Create a Config File

Create an otelconfig.yaml file to configure your exporter.To send logs to Honeycomb:
To send logs to an OpenTelemetry Collector instead:
When OTEL_CONFIG_FILE is set, the configuration file is the single source of truth for the SDK. Other OTEL_* environment variables are ignored by design, so set all SDK options in the YAML file. You can still reference environment variables from inside the YAML using ${VAR_NAME} substitution.
4

Run Your Application

Point the SDK at your configuration file using OTEL_CONFIG_FILE, then run your application:

Supported Logging Frameworks

The OpenTelemetry JavaScript SDK can automatically create logs from these supported logging frameworks:
  • Bunyan
  • Winston