LangfuseTelemetry
NexusLabs.Foundry.Langfuse¶
LangfuseTelemetry Class¶
Entry point for exporting Foundry agent telemetry to Langfuse without requiring a generic host. Designed for evals, console apps, and test fixtures that build telemetry by hand.
Inheritance System.Object 🡒 LangfuseTelemetry
Remarks¶
Start(LangfuseOptions) constructs standalone OpenTelemetry tracer and meter
providers that subscribe to Foundry's gen_ai activity source and meters and export them
to Langfuse over OTLP/HTTP. Dispose the returned ILangfuseSession to perform
bounded final shutdown using ShutdownTimeout.
For ASP.NET Core / generic-host applications that already call AddOpenTelemetry(), use
AddFoundryLangfuse(this IServiceCollection, Action<LangfuseOptions>)
instead so the providers participate in the host lifecycle.\<example>
\<code>
using var langfuse = LangfuseTelemetry.Start(LangfuseOptions.FromEnvironment());
using (langfuse.BeginScenario("trip-planner: NYC -> Tokyo", sessionId: runId))
{
var run = await runner.RunAsync(...);
// ... evaluate and record scores ...
}
\</code>
\</example>
Methods¶
LangfuseTelemetry.Start(LangfuseOptions) Method¶
Starts a Langfuse export session for the supplied options.
public static NexusLabs.Foundry.Langfuse.ILangfuseSession Start(NexusLabs.Foundry.Langfuse.LangfuseOptions options);
Parameters¶
options LangfuseOptions
The export configuration. When IsConfigured is false (for example, missing credentials), a disabled no-op session is returned so callers never need to branch on configuration state.
Returns¶
ILangfuseSession
An ILangfuseSession that exports telemetry until disposed.