Langfuse.OpenTelemetry 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Langfuse.OpenTelemetry --version 1.0.0
                    
NuGet\Install-Package Langfuse.OpenTelemetry -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Langfuse.OpenTelemetry" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Langfuse.OpenTelemetry" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Langfuse.OpenTelemetry" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Langfuse.OpenTelemetry --version 1.0.0
                    
#r "nuget: Langfuse.OpenTelemetry, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Langfuse.OpenTelemetry@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Langfuse.OpenTelemetry&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Langfuse.OpenTelemetry&version=1.0.0
                    
Install as a Cake Tool

.NET Langfuse OTEL Exporter

NuGet Build License: MIT

Export .NET OpenTelemetry traces to Langfuse with one line of code. Agentic Frameworks like Semantic Kernel are instrumented to emit OpenTelemetry and this library aims to collect OTEL data and export it to LangFuse's OTEL endpoints.

Quick Start

1. Install

dotnet add package Langfuse.OpenTelemetry

2. Set environment variables

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com

3. Add to your app

using Langfuse.OpenTelemetry;
using Microsoft.SemanticKernel;
using OpenTelemetry;
using OpenTelemetry.Trace;

// Enable GenAI diagnostics (prompts, tokens, completions)
AppContext.SetSwitch("Microsoft.SemanticKernel.Experimental.GenAI.EnableOTelDiagnosticsSensitive", true);

// Setup OpenTelemetry
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource("Microsoft.SemanticKernel*")
    .AddLangfuseExporter()
    .Build();

// Use Semantic Kernel as normal
var kernel = Kernel.CreateBuilder()
    .AddOpenAIChatCompletion("gpt-4o-mini", apiKey)
    .Build();

var result = await kernel.InvokePromptAsync("Hello!");

Configuration

Set these environment variables and call .AddLangfuseExporter() with no parameters:

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com

Option 2: Manual Configuration

Pass configuration directly to the exporter:

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource("Microsoft.SemanticKernel*")
    .AddLangfuseExporter(options =>
    {
        options.PublicKey = "pk-lf-...";
        options.SecretKey = "sk-lf-...";
        options.BaseUrl = "https://cloud.langfuse.com";
    })
    .Build();

Option 3: IConfiguration

Load from appsettings.json or other configuration sources:

// In appsettings.json:
// {
//   "Langfuse": {
//     "PublicKey": "pk-lf-...",
//     "SecretKey": "sk-lf-...",
//     "BaseUrl": "https://cloud.langfuse.com"
//   }
// }

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource("Microsoft.SemanticKernel*")
    .AddLangfuseExporter(configuration.GetSection("Langfuse"))
    .Build();

Test

# Set environment variables
$env:OPENAI_API_KEY="sk-..."
$env:LANGFUSE_PUBLIC_KEY="pk-lf-..."
$env:LANGFUSE_SECRET_KEY="sk-lf-..."
$env:LANGFUSE_BASE_URL="https://cloud.langfuse.com"

# Run sample
cd samples/SemanticKernel.Sample
dotnet run

Check your Langfuse dashboard to see the traces.


Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.1 205 1/19/2026
1.4.0 112 1/11/2026
1.3.0 104 1/9/2026
1.2.0 467 12/11/2025
1.1.0 203 11/26/2025
1.0.0 245 10/8/2025
0.1.0 196 10/8/2025