Class BraintrustConfig

java.lang.Object
dev.braintrust.config.BraintrustConfig

public final class BraintrustConfig extends Object
Configuration for Braintrust SDK with sane defaults.

Most SDK users will want to use envars to configure all Braintrust settings.

However, it's also possible to override any envar during config construction.

  • Field Details

  • Method Details

    • fromEnvironment

      public static BraintrustConfig fromEnvironment()
    • of

      public static BraintrustConfig of(String... envOverrides)
    • getBraintrustParentValue

      public Optional<String> getBraintrustParentValue()
      The parent attribute tells braintrust where to send otel data

      The otel ingestion endpoint looks for (a) braintrust.parent = project_id|project_name|experiment_id:value otel attribute and routes accordingly

      (b) if a span has no parent marked explicitly, it will look to see if there's an x-bt-parent http header (with the same format marked above e.g. project_name:andrew) that parent will apply to all spans in a request that don't have one

      If neither (a) nor (b) exists, the data is dropped
    • fetchProjectURI

      public URI fetchProjectURI()
      fetch all project info and IDs from the braintrust api
    • apiKey

      public String apiKey()
    • apiUrl

      public String apiUrl()
    • appUrl

      public String appUrl()
    • tracesPath

      public String tracesPath()
    • logsPath

      public String logsPath()
    • defaultProjectId

      public Optional<String> defaultProjectId()
    • defaultProjectName

      public Optional<String> defaultProjectName()
    • enableTraceConsoleLog

      public boolean enableTraceConsoleLog()
    • debug

      public boolean debug()
    • experimentalOtelLogs

      public boolean experimentalOtelLogs()
    • requestTimeout

      public Duration requestTimeout()
    • exportSpansInMemoryForUnitTest

      public boolean exportSpansInMemoryForUnitTest()
      Setting for unit testing. Do not use in production.
    • getConfig

      @Nonnull protected <T> T getConfig(@Nonnull String settingName, @Nonnull T defaultValue)
    • getConfig

      @Nullable protected <T> T getConfig(@Nonnull String settingName, @Nullable T defaultValue, @Nonnull Class<T> settingClass)
    • getRequiredConfig

      @Nonnull protected String getRequiredConfig(@Nonnull String settingName)
    • getRequiredConfig

      @Nonnull protected <T> T getRequiredConfig(String settingName, Class<T> settingClass)
    • cast

      protected <T> T cast(@Nonnull String value, @Nonnull Class<T> clazz)
    • getEnvValue

      @Nullable protected String getEnvValue(@Nonnull String settingName)