Feature Request: Add Langfuse Tracing #152

Open
opened 2026-02-16 17:25:27 -05:00 by yindo · 8 comments
Owner

Originally created by @tito on GitHub (Jun 19, 2025).

Originally assigned to: @thdxr on GitHub.

Summary

Add tracing/observability to OpenCode using Langfuse.

Why

  • Currently no way to trace execution or monitor performance
  • Difficult to debug issues in production
  • Missing insights on usage patterns and bottlenecks

Proposal

Integrate Langfuse (https://langfuse.com/) for tracing, which is already supported by Goose (https://block.github.io/goose/) per their documentation.

Benefits

  • Simple debugging
  • Performance monitoring
  • Usage analytics
  • Low implementation effort
Originally created by @tito on GitHub (Jun 19, 2025). Originally assigned to: @thdxr on GitHub. **Summary** Add tracing/observability to OpenCode using Langfuse. **Why** - Currently no way to trace execution or monitor performance - Difficult to debug issues in production - Missing insights on usage patterns and bottlenecks **Proposal** Integrate Langfuse (https://langfuse.com/) for tracing, which is already supported by Goose (https://block.github.io/goose/) per their [documentation](https://github.com/block/goose/blob/09a00790948892eaf3f3d1507921d7eb55432781/documentation/docs/tutorials/langfuse.md). **Benefits** - Simple debugging - Performance monitoring - Usage analytics - Low implementation effort
Author
Owner

@ColeMurray commented on GitHub (Jun 20, 2025):

langfuse supports Otel, so preferably we could instrument with Otel and have langfuse as one of N many different OtelProcessors

https://langfuse.com/docs/opentelemetry/get-started

@ColeMurray commented on GitHub (Jun 20, 2025): langfuse supports Otel, so preferably we could instrument with Otel and have langfuse as one of N many different OtelProcessors https://langfuse.com/docs/opentelemetry/get-started
Author
Owner

@adrielp commented on GitHub (Jul 17, 2025):

👍🏼 to this. Would love to be able to opt-in to emitting native instrumentation for as much of the stack as possible simply by adding the OTEL exporter env vars + leveraging the GenAI semantic conventions I'd be happy to assist on this as well.

@adrielp commented on GitHub (Jul 17, 2025): 👍🏼 to this. Would love to be able to opt-in to emitting native instrumentation for as much of the stack as possible simply by adding the `OTEL` exporter env vars + leveraging the [GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) I'd be happy to assist on this as well.
Author
Owner

@mattzhango commented on GitHub (Sep 7, 2025):

+1 to having tracing/observability, especially with the release of the SDK

@mattzhango commented on GitHub (Sep 7, 2025): +1 to having tracing/observability, especially with the release of the SDK
Author
Owner

@noamzbr commented on GitHub (Dec 5, 2025):

Following https://github.com/sst/opencode/pull/4978, Langfuse tracing is now possible with a minimal plugin that can look something like

/**
 * Langfuse OpenTelemetry Plugin for OpenCode
 * 
 * Requires: bun add @langfuse/otel @opentelemetry/sdk-node
 * Env vars: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST
 */
import { NodeSDK } from "@opentelemetry/sdk-node"
import { LangfuseSpanProcessor } from "@langfuse/otel"

let initialized = false

export const LangfusePlugin = async () => ({
  async config(config) {
    if (!config.open_telemetry || initialized) return
    initialized = true

    const processor = new LangfuseSpanProcessor()
    new NodeSDK({ spanProcessors: [processor] }).start()

    // // Flush frequently - Required in headless mode to make sure flushes are made before process exit
    // setInterval(() => processor.forceFlush(), 500)
  },
})

(Probably worth finding a better solution for headless mode)

@noamzbr commented on GitHub (Dec 5, 2025): Following https://github.com/sst/opencode/pull/4978, Langfuse tracing is now possible with a minimal plugin that can look something like ``` /** * Langfuse OpenTelemetry Plugin for OpenCode * * Requires: bun add @langfuse/otel @opentelemetry/sdk-node * Env vars: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST */ import { NodeSDK } from "@opentelemetry/sdk-node" import { LangfuseSpanProcessor } from "@langfuse/otel" let initialized = false export const LangfusePlugin = async () => ({ async config(config) { if (!config.open_telemetry || initialized) return initialized = true const processor = new LangfuseSpanProcessor() new NodeSDK({ spanProcessors: [processor] }).start() // // Flush frequently - Required in headless mode to make sure flushes are made before process exit // setInterval(() => processor.forceFlush(), 500) }, }) ``` (Probably worth finding a better solution for headless mode)
Author
Owner

@modelnova-ai commented on GitHub (Dec 6, 2025):

Following #4978, Langfuse tracing is now possible with a minimal plugin that can look something like

/**
 * Langfuse OpenTelemetry Plugin for OpenCode
 * 
 * Requires: bun add @langfuse/otel @opentelemetry/sdk-node
 * Env vars: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST
 */
import { NodeSDK } from "@opentelemetry/sdk-node"
import { LangfuseSpanProcessor } from "@langfuse/otel"

let initialized = false

export const LangfusePlugin = async () => ({
  async config(config) {
    if (!config.open_telemetry || initialized) return
    initialized = true

    const processor = new LangfuseSpanProcessor()
    new NodeSDK({ spanProcessors: [processor] }).start()

    // // Flush frequently - Required in headless mode to make sure flushes are made before process exit
    // setInterval(() => processor.forceFlush(), 500)
  },
})

(Probably worth finding a better solution for headless mode)

Is it possible to record telemetry on a per user level with this plugin? if not how to trace user level tracing in langfuse

@modelnova-ai commented on GitHub (Dec 6, 2025): > Following [#4978](https://github.com/sst/opencode/pull/4978), Langfuse tracing is now possible with a minimal plugin that can look something like > > ``` > /** > * Langfuse OpenTelemetry Plugin for OpenCode > * > * Requires: bun add @langfuse/otel @opentelemetry/sdk-node > * Env vars: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST > */ > import { NodeSDK } from "@opentelemetry/sdk-node" > import { LangfuseSpanProcessor } from "@langfuse/otel" > > let initialized = false > > export const LangfusePlugin = async () => ({ > async config(config) { > if (!config.open_telemetry || initialized) return > initialized = true > > const processor = new LangfuseSpanProcessor() > new NodeSDK({ spanProcessors: [processor] }).start() > > // // Flush frequently - Required in headless mode to make sure flushes are made before process exit > // setInterval(() => processor.forceFlush(), 500) > }, > }) > ``` > > (Probably worth finding a better solution for headless mode) Is it possible to record telemetry on a per user level with this plugin? if not how to trace user level tracing in langfuse
Author
Owner

@omercnet commented on GitHub (Jan 11, 2026):

https://github.com/omercnet/opencode-plugin-langfuse

@omercnet commented on GitHub (Jan 11, 2026): https://github.com/omercnet/opencode-plugin-langfuse
Author
Owner

@pai4451 commented on GitHub (Jan 13, 2026):

@omercnet Do you know what opentelemetry metrics does opencode emits? I couldn't find any telemetry metrics and logs even I configure

{
  "experimental": {
    "openTelemetry": true
  },
  "plugin": ["opencode-plugin-langfuse"]
}
@pai4451 commented on GitHub (Jan 13, 2026): @omercnet Do you know what opentelemetry metrics does opencode emits? I couldn't find any telemetry metrics and logs even I configure ``` { "experimental": { "openTelemetry": true }, "plugin": ["opencode-plugin-langfuse"] } ```
Author
Owner

@omercnet commented on GitHub (Jan 13, 2026):

@pai4451 make sure you set env vars properly, try in terminal first with opencode --print-logs --log-level WARN run test to see any warning logs

and kindly open issues on the plugin repo so we can handle any bugs

@omercnet commented on GitHub (Jan 13, 2026): @pai4451 make sure you set env vars properly, try in terminal first with `opencode --print-logs --log-level WARN run test` to see any warning logs and kindly open issues on the plugin repo so we can handle any bugs
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#152