Dash0 Logo
Infrastructure MonitoringLog ManagementApplication Performance ManagementDistributed TracingKubernetes MonitoringDashboardsAlertingService MapIntegrationsTransparent CostObservability as Code
PricingDocs
GuidesBlogKnowledgePodcastIntegrationsChangelog
Contact usMeet our TeamCareersSecurity
  • Book A Demo
  • Sign In
  • Start Free Trial
Book a demoSign in
Start Free Trial

    Resources

      PricingBlogKnowledgeIntegrationsDocumentationGlossaryOTelBin.ioSitemap

    Company

      Our TeamCareersSecurity

    Contact

      Contact usGitHubLinkedInXYouTubeDash0 Newsletter
Subscribe to our newsletter

Receive updates on OTelBin, Dash0, Observability, OpenTelemetry, and more.

  • Terms and Conditions
  • Privacy Policy
  • Data Processing Agreement
  • Vulnerability Disclosure

©2025 Dash0 Inc.

Hub/Bun

Technology

Bun

Dash0 seamlessly integrates with your Bun applications, providing clear visibility into your system's activity and performance.

Overview

Overview

Instrumenting your Bun application to generate traces, logs, and metrics is a powerful way to gain deep insights into its behavior and performance. By adding instrumentation, you enable your application to emit valuable data that can be used for monitoring, troubleshooting, and optimization.

Dash0 supports instrumentation of Bun applications through OpenTelemetry's open-source and vendor-agnostic packages. Bun applications require manual setup of an initialization file to properly configure OpenTelemetry.

Use Cases

  • Understand outgoing and incoming HTTP requests through traces and metrics. Allowing drill-downs to the database level.
  • You can see which database statements were executed and how long they took, which gives you valuable data to optimize your applications.
  • Reveal (uncaught) errors and the context in which they happened.

Setup

Install

To instrument your Bun application, you'll need to install the OpenTelemetry SDK and the Node.js auto-instrumentation packages, as Bun is compatible with most Node.js packages:

Configure

Unlike Node.js, Bun requires a manual initialization file since it doesn't support the same --require flag that Node.js uses for auto-instrumentation. You'll need to create a separate initialization file and preload it.

1. Create an initialization file

Create a file named otel.ts in your project root with the following content:

2. Configure environment variables

Set the following environment variables before starting your application:

3. Run your application with the preloaded initialization file

Kubernetes Setup

In case you are not using the Dash0 operator for Kubernetes to deploy your application, you should extend the OpenTelemetry resource attributes to include the Pod UID. This is important to merge the resources between logs, traces, and metrics.

You need to modify your otel.ts file to include these attributes:

And update your Kubernetes deployment:

Supported libraries and frameworks

Since Bun uses the Node.js auto-instrumentation package, it supports most of the same libraries and frameworks. However, compatibility may vary as Bun continues to evolve.

To understand which libraries are automatically instrumented, please refer to the OpenTelemetry documentation.