Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 105 additions & 102 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,75 +1,78 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.diffplug.spotless' version '6.25.0'
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.diffplug.spotless' version '6.25.0'
id("io.freefair.lombok") version "9.0.0-rc2"
}

group = 'dev.braintrust'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}

repositories {
mavenCentral()
mavenCentral()
}

ext {
otelVersion = '1.36.0'
jacksonVersion = '2.16.1'
junitVersion = '5.10.1'
assertjVersion = '3.25.1'
mockitoVersion = '5.8.0'
slf4jVersion = '2.0.9'
otelVersion = '1.36.0'
jacksonVersion = '2.16.1'
junitVersion = '5.10.1'
assertjVersion = '3.25.1'
mockitoVersion = '5.8.0'
slf4jVersion = '2.0.9'
}

dependencies {
// OpenTelemetry
api "io.opentelemetry:opentelemetry-api:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk-trace:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk-logs:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-exporter-otlp:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-exporter-logging:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-semconv:1.25.0-alpha"

// HTTP Client (Java 11+)
implementation 'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:' + jacksonVersion
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:' + jacksonVersion

// Logging
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
runtimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"

// Utilities
implementation 'com.google.code.findbugs:jsr305:3.0.2' // @Nullable annotations
implementation 'org.apache.commons:commons-lang3:3.14.0'

// AI SDKs (optional dependencies)
compileOnly 'com.openai:openai-java:2.8.1' // Official OpenAI SDK
implementation "io.opentelemetry.instrumentation:opentelemetry-openai-java-1.1:2.19.0-alpha"
// compileOnly 'com.anthropic:anthropic-java:0.1.0' // Not yet available

// Testing
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testImplementation "org.assertj:assertj-core:${assertjVersion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}"
testImplementation "io.opentelemetry:opentelemetry-sdk-testing:${otelVersion}"
// OpenTelemetry
api "io.opentelemetry:opentelemetry-api:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk-trace:${otelVersion}"
api "io.opentelemetry:opentelemetry-sdk-logs:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-exporter-otlp:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-exporter-logging:${otelVersion}"
implementation "io.opentelemetry:opentelemetry-semconv:1.25.0-alpha"

// HTTP Client (Java 11+)
implementation 'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:' + jacksonVersion
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:' + jacksonVersion

// Logging
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
runtimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"

// Utilities
implementation 'com.google.code.findbugs:jsr305:3.0.2' // @Nullable annotations
implementation 'org.apache.commons:commons-lang3:3.14.0'

// AI SDKs (optional dependencies)
compileOnly 'com.openai:openai-java:2.8.1' // Official OpenAI SDK
implementation "io.opentelemetry.instrumentation:opentelemetry-openai-java-1.1:2.19.0-alpha"
// compileOnly 'com.anthropic:anthropic-java:0.1.0' // Not yet available

// Testing
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testImplementation "org.assertj:assertj-core:${assertjVersion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}"
testImplementation "io.opentelemetry:opentelemetry-sdk-testing:${otelVersion}"
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
environment 'TEST_VAR1', 'fromenv1'
environment 'TEST_VAR2', 'fromenv2'
}

// Enable preview features for pattern matching, etc.
Expand All @@ -87,75 +90,75 @@ test {
// }

jar {
manifest {
attributes(
'Implementation-Title': 'Braintrust Java SDK',
'Implementation-Version': version,
'Implementation-Vendor': 'Braintrust'
)
}
manifest {
attributes(
'Implementation-Title': 'Braintrust Java SDK',
'Implementation-Version': version,
'Implementation-Vendor': 'Braintrust'
)
}
}

publishing {
publications {
maven(MavenPublication) {
from components.java

pom {
name = 'Braintrust Java SDK'
description = 'OpenTelemetry-based Braintrust SDK for Java'
url = 'https://github.com/braintrustdata/braintrust-x-java'

licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}

developers {
developer {
id = 'braintrust'
name = 'Braintrust Team'
email = 'support@braintrust.dev'
}
}
}
publications {
maven(MavenPublication) {
from components.java

pom {
name = 'Braintrust Java SDK'
description = 'OpenTelemetry-based Braintrust SDK for Java'
url = 'https://github.com/braintrustdata/braintrust-x-java'

licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}

developers {
developer {
id = 'braintrust'
name = 'Braintrust Team'
email = 'support@braintrust.dev'
}
}
}
}
}
}


// Configure Spotless for code formatting
spotless {
java {
target 'src/*/java/**/*.java', 'examples/src/*/java/**/*.java'
java {
target 'src/*/java/**/*.java', 'examples/src/*/java/**/*.java'

// Use Google Java Format
googleJavaFormat('1.19.2').aosp().reflowLongStrings()
// Use Google Java Format
googleJavaFormat('1.19.2').aosp().reflowLongStrings()

// Remove unused imports
removeUnusedImports()
// Remove unused imports
removeUnusedImports()

// Trim trailing whitespace
trimTrailingWhitespace()
// Trim trailing whitespace
trimTrailingWhitespace()

// End with newline
endWithNewline()
}
// End with newline
endWithNewline()
}
}

// Task to install git hooks
task installGitHooks(type: Exec) {
description = 'Install git hooks for code formatting'
group = 'Build Setup'
commandLine 'bash', 'scripts/install-hooks.sh'
description = 'Install git hooks for code formatting'
group = 'Build Setup'
commandLine 'bash', 'scripts/install-hooks.sh'
}

// Run installGitHooks after project evaluation
afterEvaluate {
// Install hooks when building for the first time
tasks.named('build').configure {
dependsOn installGitHooks
}
// Install hooks when building for the first time
tasks.named('build').configure {
dependsOn installGitHooks
}
}
82 changes: 41 additions & 41 deletions examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
plugins {
id 'java'
id 'application'
id 'java'
id 'application'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation project(':')
// TODO: not sure why I have to do this. I would have expected this to come over in the project root transitive deps
implementation "io.opentelemetry:opentelemetry-exporter-otlp:${otelVersion}"
implementation project(':')
// TODO: not sure why I have to do this. I would have expected this to come over in the project root transitive deps
implementation "io.opentelemetry:opentelemetry-exporter-otlp:${otelVersion}"

// Official OpenAI Java SDK
implementation 'com.openai:openai-java:2.8.1'
// Official OpenAI Java SDK
implementation 'com.openai:openai-java:2.8.1'

// OkHttp for HTTP client (required by OpenAI SDK)
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
// OkHttp for HTTP client (required by OpenAI SDK)
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
}

application {
mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample'
mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample'
}

task runSimpleOpenTelemetry(type: JavaExec) {
group = 'Braintrust SDK Examples'
description = 'Run the simple OpenTelemetry example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample'
group = 'Braintrust SDK Examples'
description = 'Run the simple OpenTelemetry example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample'
}

task runCustomOpenTelemetry(type: JavaExec) {
group = 'Braintrust SDK Examples'
description = 'Run the custom OpenTelemetry example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.CustomOpenTelemetryExample'
group = 'Braintrust SDK Examples'
description = 'Run the custom OpenTelemetry example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.CustomOpenTelemetryExample'
}

task runOpenAIInstrumentation(type: JavaExec) {
group = 'Braintrust SDK Examples'
description = 'Run the OpenAI instrumentation example. NOTE: this requires OPENAI_API_KEY to be exported and will make a small call to openai, using your tokens'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.OpenAIInstrumentationExample'
debugOptions {
enabled = true
port = 5566
server = true
suspend = false
}
group = 'Braintrust SDK Examples'
description = 'Run the OpenAI instrumentation example. NOTE: this requires OPENAI_API_KEY to be exported and will make a small call to openai, using your tokens'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.OpenAIInstrumentationExample'
debugOptions {
enabled = true
port = 5566
server = true
suspend = false
}
}

task runExperiment(type: JavaExec) {
group = 'Braintrust SDK Examples'
description = 'Run the experiment example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.ExperimentExample'
debugOptions {
enabled = true
port = 5566
server = true
suspend = false
}
group = 'Braintrust SDK Examples'
description = 'Run the experiment example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'dev.braintrust.examples.ExperimentExample'
debugOptions {
enabled = true
port = 5566
server = true
suspend = false
}
}
Loading