---
type: concept
x-llmwiki:
  schemaVersion: "0.1"
  contentHash: 534303e5c25a2bb2d0d27c85a77120e6883ad0785bfc90576104d9af2ef2a62a
  pageDirectory: concepts
  sources:
    - export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md
  confidence: 0.9
  provenanceState: extracted
  freshnessStatus: unverified
  aliases:
    - langfuse-otel-exporter-hijacking
    - LOEH
  citations:
    - file: export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md
title: Langfuse OTEL Exporter Hijacking
description: Setting Langfuse environment variables to dummy values and attaching a custom BatchSpanProcessor with an OTLPSpanExporter to intercept Langfuse-generated OTel spans and redirect them to Databricks instead of the Langfuse server.
tags:
  - tracing
  - opentelemetry
  - langfuse
  - databricks
timestamp: "2026-06-19T18:46:17.722Z"
---

# Langfuse OTEL Exporter Hijacking

**Langfuse OTEL Exporter Hijacking** refers to the technique of redirecting the OpenTelemetry (OTEL) spans generated by the Langfuse SDK away from Langfuse’s own servers and toward a different OTLP-compatible endpoint, such as the Databricks MLflow trace ingestion API. This is achieved by disabling Langfuse’s built-in trace collection and attaching a custom OTEL span exporter to the same tracer provider that Langfuse registers globally. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Overview

Langfuse is an observability platform for LLM applications. Its Python SDK uses OpenTelemetry internally to create and export trace spans. By default, those spans are sent to the Langfuse backend. Hijacking the exporter replaces that default destination with any OTLP endpoint, allowing traces to be stored in a different system—for example, in [Unity Catalog](/concepts/unity-catalog.md) tables through Databricks MLflow. This approach avoids sending any trace data to Langfuse servers while preserving the benefit of Langfuse’s instrumentation decorators (e.g., `@observe()`). ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Mechanism

The hijacking relies on two key actions:

1. **Disabling Langfuse’s own export** – Set the `LANGFUSE_HOST`, `LANGFUSE_PUBLIC_KEY`, and `LANGFUSE_SECRET_KEY` environment variables to dummy values so that Langfuse’s built-in exporters do not activate. Alternatively, set `LANGFUSE_TRACING_ENABLED=False`. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

2. **Adding a custom OTEL exporter** – After initializing the Langfuse client (which registers a global TracerProvider), retrieve that provider via `opentelemetry.trace.get_tracer_provider()`. Then attach a `BatchSpanProcessor` with an `OTLPSpanExporter` that points to the desired OTLP endpoint. Because Langfuse’s own export path is disabled, the attached exporter becomes the sole receiver of all spans produced by Langfuse-instrumented code. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Requirements

- A Langfuse SDK version ≥ 3.14.5.
- An OpenTelemetry SDK and the OTLP HTTP protobuf exporter (`opentelemetry-exporter-otlp-proto-http`).
- The Databricks workspace must have the “OpenTelemetry on Databricks” preview enabled, and the MLflow experiment must be linked to a Unity Catalog location via `set_experiment_trace_location()`. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Implementation Steps (Summary)

1. Install required packages: `langfuse`, `mlflow[databricks]`, `opentelemetry-api`, `opentelemetry-sdk`, `opentelemetry-exporter-otlp-proto-http`.
2. Set dummy environment variables for `LANGFUSE_HOST`, `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`.
3. Retrieve the Databricks workspace host and API token (uses `dbutils.notebook.entry_point` inside a Databricks notebook).
4. Create an MLflow experiment and set its trace location to a Unity Catalog schema using `mlflow.entities.UCSchemaLocation` and `set_experiment_trace_location()`.
5. Initialize the Langfuse client.
6. Get the global `TracerProvider` from `opentelemetry.trace`.
7. Create an `OTLPSpanExporter` with endpoint `{DATABRICKS_HOST}/api/2.0/otel/v1/traces`, the token in the `Authorization` header, and the `X-Databricks-UC-Table-Name` header set to the trace location’s full OTEL spans table name.
8. Attach a `BatchSpanProcessor` containing this exporter to the provider.
9. Use Langfuse’s `@observe()` decorator on functions; the spans are sent exclusively to Databricks. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Benefits

- **Centralized trace storage** – Langfuse-instrumented calls appear in the same Databricks MLflow experiment as traces from other frameworks.
- **Query at scale** – Trace data in Unity Catalog tables can be analyzed with Databricks SQL.
- **Unified governance** – [Unity Catalog](/concepts/unity-catalog.md) access controls, lineage, and auditing apply to all traces, including those generated through Langfuse. ^[export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md]

## Related Concepts

- OpenTelemetry on Databricks – The platform feature that ingests OTLP spans into Unity Catalog.
- [MLflow Tracing](/concepts/mlflow-tracing.md) – The broader tracing subsystem in MLflow for observing LLM applications.
- OTLPSpanExporter – The OpenTelemetry exporter class used to send spans to a remote OTLP endpoint.
- BatchSpanProcessor – The standard processor that batches spans before exporting.
- [Langfuse @observe() Decorator](/concepts/langfuse-observe-decorator.md) – The primary instrumentation mechanism that creates spans.

## Sources

- export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md

# Citations

1. [export-langfuse-traces-to-databricks-mlflow-databricks-on-aws.md](/references/export-langfuse-traces-to-databricks-mlflow-databricks-on-aws-edce6b99.md)
