Skip to content

LangfuseServiceCollectionExtensions

NexusLabs.Foundry.Langfuse

LangfuseServiceCollectionExtensions Class

Registers Langfuse OTLP export and a complete non-owning ILangfuseClient facade on an Microsoft.Extensions.DependencyInjection.IServiceCollection for dependency-injection-based applications.

public static class LangfuseServiceCollectionExtensions

Inheritance System.Object 🡒 LangfuseServiceCollectionExtensions

Remarks

Unlike Start(LangfuseOptions) — which builds standalone providers for evals and console apps — this integrates with the host's AddOpenTelemetry() pipeline so the tracer and meter providers share the application lifecycle. The registered facade can create scenarios and experiment runs without constructing a standalone ILangfuseSession. When options are not configured, the same facade and specialized interfaces are registered as coherent no-ops.

Fields

LangfuseServiceCollectionExtensions.HttpClientName Field

Gets the named System.Net.Http.HttpClient used by the built-in hosted Langfuse REST clients.

public const string HttpClientName = "NexusLabs.Foundry.Langfuse";

Field Value

System.String

Remarks

Register or configure this named client before calling AddFoundryLangfuse(this IServiceCollection) to customize handlers, proxies, certificates, connection pooling, or other transport behavior.

Methods

LangfuseServiceCollectionExtensions.AddFoundryLangfuse(this IServiceCollection) Method

Adds Langfuse OTLP/HTTP export using environment-derived options and registers the non-owning ILangfuseClient facade plus all specialized client interfaces.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddFoundryLangfuse(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The service collection to configure.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The same Microsoft.Extensions.DependencyInjection.IServiceCollection for chaining.

Exceptions

System.ArgumentNullException
services is null.

LangfuseServiceCollectionExtensions.AddFoundryLangfuse(this IServiceCollection, Action<LangfuseOptions>) Method

Adds Langfuse OTLP/HTTP export to the host's OpenTelemetry pipeline, applies the supplied configuration, and registers the non-owning ILangfuseClient facade plus all specialized client interfaces.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddFoundryLangfuse(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<NexusLabs.Foundry.Langfuse.LangfuseOptions> configure);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The service collection to configure.

configure System.Action<LangfuseOptions>

Callback that customizes options initialized from FromEnvironment().

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The same Microsoft.Extensions.DependencyInjection.IServiceCollection for chaining.

Exceptions

System.ArgumentNullException
services is null.

System.ArgumentNullException
configure is null.