From 1183e42d4b1306192020a8b3d20e064aea8927ad Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Sat, 30 May 2026 01:02:12 +0800 Subject: [PATCH] Wire OpenTelemetry into ClassifiersExample and add gradle task ClassifiersExample.java was the only example missing the explicit braintrust.openTelemetryCreate() call that every other example performs immediately after Braintrust.get(). Without it, spans created during the eval go to the no-op tracer and never reach the Braintrust backend, so the experiment shows up empty in the UI despite the REST experiment record being created. Adding the call brings the example in line with ExperimentExample, TraceScoringExample, etc. Also adds a runClassifiers gradle task so the example can be invoked the same way as the others (./gradlew :examples:runClassifiers). Co-Authored-By: Claude Opus 4.7 (1M context) --- examples/build.gradle | 14 ++++++++++++++ .../braintrust/examples/ClassifiersExample.java | 1 + 2 files changed, 15 insertions(+) diff --git a/examples/build.gradle b/examples/build.gradle index fa732452..33c7a969 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -100,6 +100,20 @@ task runExperiment(type: JavaExec) { } } +task runClassifiers(type: JavaExec) { + group = 'Braintrust SDK Examples' + description = 'Run the classifiers example' + classpath = sourceSets.main.runtimeClasspath + mainClass = 'dev.braintrust.examples.ClassifiersExample' + systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel + debugOptions { + enabled = true + port = 5566 + server = true + suspend = false + } +} + task runAnthropicInstrumentation(type: JavaExec) { group = 'Braintrust SDK Examples' description = 'Run the Anthropic instrumentation example. NOTE: this requires ANTHROPIC_API_KEY to be exported and will make a small call to anthropic, using your tokens' diff --git a/examples/src/main/java/dev/braintrust/examples/ClassifiersExample.java b/examples/src/main/java/dev/braintrust/examples/ClassifiersExample.java index 270dcc61..7aeba04c 100644 --- a/examples/src/main/java/dev/braintrust/examples/ClassifiersExample.java +++ b/examples/src/main/java/dev/braintrust/examples/ClassifiersExample.java @@ -26,6 +26,7 @@ public class ClassifiersExample { public static void main(String[] args) throws Exception { var braintrust = Braintrust.get(); + braintrust.openTelemetryCreate(); // 1. Single-label classifier. Classifier intentClassifier =