Langfuse.OpenTelemetry
1.0.0
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
<PackageReference Include="Langfuse.OpenTelemetry" Version="1.0.0" />
<PackageVersion Include="Langfuse.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="Langfuse.OpenTelemetry" />
paket add Langfuse.OpenTelemetry --version 1.0.0
#r "nuget: Langfuse.OpenTelemetry, 1.0.0"
#:package Langfuse.OpenTelemetry@1.0.0
#addin nuget:?package=Langfuse.OpenTelemetry&version=1.0.0
#tool nuget:?package=Langfuse.OpenTelemetry&version=1.0.0
.NET Langfuse OTEL Exporter
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
Option 1: Environment Variables (Recommended)
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.
Links
| Product | Versions 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. |
-
net8.0
- OpenTelemetry (>= 1.9.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.