Skip to content

Ark/otel api improvements#11

Merged
Andrew Kent (realark) merged 6 commits into
mainfrom
ark/otel-api-improvements
Sep 19, 2025
Merged

Ark/otel api improvements#11
Andrew Kent (realark) merged 6 commits into
mainfrom
ark/otel-api-improvements

Conversation

@realark

Copy link
Copy Markdown
Contributor

No description provided.

@realark Andrew Kent (realark) force-pushed the ark/otel-api-improvements branch 3 times, most recently from 11318ac to ef3f5ab Compare September 18, 2025 23:07
* <br/><br/>
* NOTE: This method should only be invoked once. Enabling Braintrust multiple times is unsupported and may lead to undesired behavior
*/
public static void enable(@Nonnull BraintrustConfig config, @Nonnull SdkTracerProviderBuilder tracerProviderBuilder, @Nonnull SdkLoggerProviderBuilder loggerProviderBuilder, @Nonnull SdkMeterProviderBuilder meterProviderBuilder) {

@realark Andrew Kent (realark) Sep 18, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only new feature of this PR (everything else is refactors, docs, and misc polish)

This is for SDK users who want to add Braintrust alongside their existing open telemetry.

It's slightly different than Go's because the java SDK uses builders with immutable objects so we have to hook the builder phase.

Another thing worth noting is I'm including a hook for otel metrics as well. The reason for this is enterprise Java people are much more willing to bump a dependency version rather than update code (to the point of irrationality at times). So this gives us the option to pull in metrics later without requiring SDK users to update their code

@realark Andrew Kent (realark) marked this pull request as ready for review September 18, 2025 23:40
@realark Andrew Kent (realark) merged commit cfdeb18 into main Sep 19, 2025
0 of 3 checks passed
@realark Andrew Kent (realark) deleted the ark/otel-api-improvements branch September 19, 2025 00:20
.build();
GlobalOpenTelemetry.set(openTelemetry);
registerShutdownHook(openTelemetry);
var braintrustTracer = BraintrustTracing.getTracer(openTelemetry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required? or does everything still work if they use the global otel version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not strictly required. If we can't find the braintrust context on the span data we use the default project that's configured (which can be a project ID or a project name)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants