| | | 1 | | namespace NexusLabs.Needlr.AgentFramework.Langfuse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Shared guard logic for the Langfuse export entry points. Surfaces a diagnostic when credentials |
| | | 5 | | /// are present but no explicit export target was chosen, so the "disabled to avoid cloud egress" |
| | | 6 | | /// decision is visible rather than silent. |
| | | 7 | | /// </summary> |
| | | 8 | | internal static class LangfuseExportGuard |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Invokes <see cref="LangfuseOptions.DiagnosticsCallback"/> when credentials are present and |
| | | 12 | | /// enabled but neither a <see cref="LangfuseOptions.Host"/> nor a |
| | | 13 | | /// <see cref="LangfuseOptions.Region"/> was set, explaining why export is disabled. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="options">The export options.</param> |
| | | 16 | | public static void WarnIfCredentialsWithoutTarget(LangfuseOptions options) |
| | | 17 | | { |
| | 6 | 18 | | ArgumentNullException.ThrowIfNull(options); |
| | | 19 | | |
| | 6 | 20 | | if (options.HasCredentials && !options.HasExplicitTarget) |
| | | 21 | | { |
| | 2 | 22 | | options.DiagnosticsCallback?.Invoke( |
| | 2 | 23 | | "Langfuse credentials were provided but no export target was set, so export is " + |
| | 2 | 24 | | "disabled. This prevents accidentally sending traces (which may include prompts, " + |
| | 2 | 25 | | "agent outputs, and customer data) to Langfuse Cloud. Set LangfuseOptions.Host for " + |
| | 2 | 26 | | "a self-hosted deployment, or LangfuseOptions.Region to opt in to a Langfuse Cloud " + |
| | 2 | 27 | | "region."); |
| | | 28 | | } |
| | 5 | 29 | | } |
| | | 30 | | } |