LangfuseOptions
NexusLabs.Needlr.AgentFramework.Langfuse¶
LangfuseOptions Class¶
Configuration for exporting Needlr agent telemetry and evaluation scores to Langfuse.
Inheritance System.Object 🡒 LangfuseOptions
Remarks¶
The common path is FromEnvironment(), which reads the standard Langfuse environment variables. When the public/secret keys are absent the integration disables itself and behaves as a no-op, so credential-less CI runs never fail.
Needlr emits OpenTelemetry traces and metrics under well-known source and meter names.
The defaults here match NexusLabs.Needlr.AgentFramework.Diagnostics.AgentFrameworkMetricsOptions. If a consumer has
customised those names via ConfigureMetrics(...), set
AgentActivitySourceName, AgentMeterName, and
GenAiMeterName to the same values, or add them through
AdditionalActivitySources / AdditionalMeters.
Fields¶
LangfuseOptions.HostEnvironmentVariable Field¶
Environment variable read for the Langfuse host (base URL) by FromEnvironment().
Field Value¶
LangfuseOptions.PublicKeyEnvironmentVariable Field¶
Environment variable read for the Langfuse public key by FromEnvironment().
Field Value¶
LangfuseOptions.SecretKeyEnvironmentVariable Field¶
Environment variable read for the Langfuse secret key by FromEnvironment().
Field Value¶
Properties¶
LangfuseOptions.AdditionalActivitySources Property¶
Gets a mutable list of additional System.Diagnostics.ActivitySource names to export — for example a host's own source or MAF's agent source.
Property Value¶
System.Collections.Generic.IList<System.String>
LangfuseOptions.AdditionalMeters Property¶
Gets a mutable list of additional System.Diagnostics.Metrics.Meter names to export.
Property Value¶
System.Collections.Generic.IList<System.String>
LangfuseOptions.AgentActivitySourceName Property¶
Gets or sets the name of Needlr's agent System.Diagnostics.ActivitySource to export. Defaults to NexusLabs.Needlr.AgentFramework.Diagnostics.AgentFrameworkMetricsOptions.MeterName's default.
Property Value¶
LangfuseOptions.AgentMeterName Property¶
Gets or sets the name of Needlr's agent System.Diagnostics.Metrics.Meter to export. Defaults to NexusLabs.Needlr.AgentFramework.Diagnostics.AgentFrameworkMetricsOptions.MeterName's default.
Property Value¶
LangfuseOptions.DiagnosticsCallback Property¶
Gets or sets an optional callback for library diagnostic messages — for example, the warning emitted when credentials are present but no export target (Host or Region) was chosen. Wire it to your logger to surface these conditions.
Property Value¶
LangfuseOptions.Enabled Property¶
Gets or sets a value indicating whether export is enabled. When true (the default) export still only occurs if PublicKey and SecretKey are both present — see IsConfigured. Set to false to force a no-op regardless of credentials.
Property Value¶
LangfuseOptions.Environment Property¶
Gets or sets the Langfuse deployment environment (for example ci, local,
staging, or production). When set, it is emitted as langfuse.environment
on every exported span so Langfuse partitions this run's data — keeping CI eval noise out of
production dashboards. null by default (Langfuse uses its default
environment).
Property Value¶
LangfuseOptions.GenAiMeterName Property¶
Gets or sets the name of the meter that owns the gen_ai.client.token.usage
histogram shared by Needlr and MEAI. Defaults to
NexusLabs.Needlr.AgentFramework.Diagnostics.AgentFrameworkMetricsOptions.GenAiMeterName's default
("Experimental.Microsoft.Extensions.AI").
Property Value¶
LangfuseOptions.HasCredentials Property¶
Gets a value indicating whether both API keys are present and export is enabled. Does not account for whether an export target was chosen — see HasExplicitTarget and IsConfigured.
Property Value¶
LangfuseOptions.HasExplicitTarget Property¶
Gets a value indicating whether an explicit export target was chosen — either a Host (self-hosted) or a Region (deliberate Langfuse Cloud opt-in).
Property Value¶
LangfuseOptions.Host Property¶
Gets or sets the Langfuse base URL (for example https://cloud.langfuse.com or a
self-hosted http://localhost:3000). When set, this takes precedence over
Region. When null, the URL is derived from
Region.
Property Value¶
LangfuseOptions.IncludeMetrics Property¶
Gets or sets a value indicating whether Needlr's gen_ai metrics (including the
gen_ai.client.token.usage histogram) are exported alongside traces. Defaults to
false.
Property Value¶
Remarks¶
As of Langfuse v3.x the OTLP metrics endpoint (/api/public/otel/v1/metrics) accepts
requests (returns HTTP 200) but does \<strong>not\</strong> ingest the data — there is no
corresponding metrics read API, so exported metrics are silently discarded. Token usage is
already carried on the generation spans, so metrics export is off by default. Enable this
only if you point the exporter at a backend that ingests OTLP metrics.
LangfuseOptions.IsConfigured Property¶
Gets a value indicating whether the integration is fully configured to export: credentials are present, export is enabled, and an explicit target (Host or Region) was chosen. Requiring an explicit target prevents accidentally sending traces to Langfuse Cloud.
Property Value¶
LangfuseOptions.NormalizeScoreNames Property¶
Gets or sets a value indicating whether evaluator metric names are normalised to
snake_case before being sent as Langfuse score names. Off by default; names are sent
verbatim. Enable for consistent dashboard filtering/grouping.
Property Value¶
LangfuseOptions.PublicKey Property¶
Gets or sets the Langfuse public key (pk-lf-...). Required for export.
Property Value¶
LangfuseOptions.Region Property¶
Gets or sets the Langfuse Cloud data region. null by default — exporting to a cloud region is therefore an explicit, opt-in choice. Ignored when Host is set.
public System.Nullable<NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseRegion> Region { get; set; }
Property Value¶
System.Nullable<LangfuseRegion>
Remarks¶
To avoid silently sending traces (which may include prompts, agent outputs, and customer data) to Langfuse Cloud, this integration requires an \<strong>explicit\</strong> target: set Host for a self-hosted deployment, or set Region to deliberately opt in to a Langfuse Cloud region. When neither is set, export is disabled even if credentials are present (see IsConfigured) and a message is sent to DiagnosticsCallback.
LangfuseOptions.Release Property¶
Gets or sets the application release identifier (for example a git SHA or semantic version).
When set, it is emitted as langfuse.release on every exported span so scores, cost,
and latency can be compared across releases. null by default.
Property Value¶
LangfuseOptions.SamplingRatio Property¶
Gets or sets the head-based trace sampling ratio in the range 0.0 to 1.0.
Defaults to 1.0 (sample everything), which is appropriate for eval workloads.
Property Value¶
LangfuseOptions.ScoreErrorCallback Property¶
Gets or sets an optional callback invoked when a score upload fails under NonFatal. Use it to log the loss with your own logger.
public System.Action<NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseScoreError>? ScoreErrorCallback { get; set; }
Property Value¶
System.Action<LangfuseScoreError>
LangfuseOptions.ScoreFailureMode Property¶
Gets or sets how a failed evaluation-score upload is handled. Defaults to NonFatal so a transient Langfuse outage does not turn a passing eval into a failure.
public NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseScoreFailureMode ScoreFailureMode { get; set; }
Property Value¶
LangfuseOptions.SecretKey Property¶
Gets or sets the Langfuse secret key (sk-lf-...). Required for export.
Property Value¶
LangfuseOptions.ServiceName Property¶
Gets or sets the OpenTelemetry service.name resource attribute applied to exported
telemetry. Surfaces in Langfuse as the originating service. Defaults to
"needlr-agent".
Property Value¶
LangfuseOptions.ServiceVersion Property¶
Gets or sets the optional OpenTelemetry service.version resource attribute.
Property Value¶
Methods¶
LangfuseOptions.FromEnvironment() Method¶
Builds a LangfuseOptions from the standard Langfuse environment variables (PublicKeyEnvironmentVariable, SecretKeyEnvironmentVariable, and HostEnvironmentVariable).
Returns¶
LangfuseOptions
A populated LangfuseOptions. When the keys are absent the result has
IsConfigured equal to false and the integration no-ops.