Services

OpenTelemetry

An Effect service that sets up OpenTelemetry traces, metrics, and log export via OTLP using Effect's unstable observability and HTTP modules, with Effect Logger bridging so all application logs are sent to the collector.

Install
Add this registry item to your app with shadcn.
bunx --bun shadcn@latest add https://krakstack.net/r/service-opentelemetry.json

Overview

service-opentelemetry uses Otlp and OtlpSerialization from effect/unstable/observability with FetchHttpClient from effect/unstable/http to set up traces, metrics, and log export to an OTLP collector over HTTP/JSON. It bridges Effect's Logger so all application logs are emitted as OpenTelemetry log records.

Environment variables are read through effect/Config so they integrate with Effect's configuration layer and can be overridden in tests.

Usage

import { Effect } from "effect";
import { OpenTelemetry } from "@/services/opentelemetry";

const program = Effect.gen(function* () {
  // Spans, metrics, and logs are automatically exported
  // to the configured OTLP endpoint.
});

await Effect.runPromise(
  program.pipe(Effect.provide(OpenTelemetry.layer)),
);

Environment Variables

  • OTEL_SERVICE_NAME — Service name used in the OTel resource. Defaults to "app"
  • OTEL_EXPORTER_OTLP_ENDPOINT — Base URL for the OTLP collector. Defaults to http://localhost:4318
Dependencies
Packages and shadcn components required by this registry item.

Dependencies