Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[BOT ISSUE] LangChain4j instrumentation only supports OpenAI-backed chat models

未关闭
#60 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
java
领域
observability

调研方向

从 BraintrustLangchain.java 开始,重点查看模型检查和 OpenAI 特定的包装,然后阅读 LangchainInstrumentationModule.java 和 WrappedHttpClient.java。跟踪现有的 OpenAI builder advice 和 HTTP client wrapper 的工作方式。完成的标准是,列出的非 OpenAI LangChain4j provider 在包装和自动插桩路径中都获得等效的 LLM 级 instrumentation。

由索引模型根据 Issue 内容生成。

描述

Summary

The LangChain4j instrumentation only wraps OpenAiChatModel and OpenAiStreamingChatModel. All other LangChain4j model providers — including Anthropic, Google Gemini, Azure OpenAI, and Mistral — are explicitly skipped with a warning, producing no LLM-level span data for those calls.

Unlike the Spring AI integration (where unsupported providers can fall through to direct SDK auto-instrumentation, e.g. the GenAI module intercepts Client$Builder.build()), LangChain4j model providers use their own internal HTTP clients rather than the upstream SDK clients. This means no other auto-instrumentation module catches these calls.

What is missing

BraintrustLangchain.wrap(OpenTelemetry, AiServices) (lines 36-51) performs instanceof checks against only two model classes:

if (chatModel instanceof OpenAiChatModel oaiModel) {
    aiServices.chatModel(wrap(openTelemetry, oaiModel));
} else {
    log.warn("unsupported model: {}. LLM calls will not be instrumented",
            chatModel.getClass().getName());
}

The auto-instrumentation module (LangchainInstrumentationModule) similarly only registers ByteBuddy advice for OpenAiChatModel$OpenAiChatModelBuilder.build() and OpenAiStreamingChatModel$OpenAiStreamingChatModelBuilder.build().

The most impactful missing model providers are:

LangChain4j model class Provider
AnthropicChatModel Anthropic Claude
GoogleAiGeminiChatModel / GoogleAiGeminiStreamingChatModel Google Gemini
VertexAiGeminiChatModel / VertexAiGeminiStreamingChatModel Google Vertex AI
AzureOpenAiChatModel / AzureOpenAiStreamingChatModel Azure OpenAI
MistralAiChatModel / MistralAiStreamingChatModel Mistral AI

Since the existing OpenAI instrumentation works by wrapping LangChain4j's internal HttpClient interface (extracted via reflection from the model's internal client), the same pattern could apply to other providers — each uses the same dev.langchain4j.http.client.HttpClient interface internally.

Braintrust docs status

Braintrust docs do not have a LangChain4j-specific page. The Java SDK is listed as supported for OpenAI, Anthropic, and Gemini providers at https://www.braintrust.dev/docs/integrations/ai-providers, but LangChain4j as a framework integration is not_found in docs.

Upstream sources

  • LangChain4j supports 20+ model providers as first-party integrations: https://github.com/langchain4j/langchain4j
  • LangChain4j model provider modules: langchain4j-anthropic, langchain4j-google-ai-gemini, langchain4j-vertex-ai-gemini, langchain4j-azure-open-ai, langchain4j-mistral-ai, etc.
  • All LangChain4j model providers use their own dev.langchain4j.http.client.HttpClient internally (not the upstream provider SDK), so upstream SDK auto-instrumentation does not cover them.

Local files inspected

  • braintrust-sdk/instrumentation/langchain_1_8_0/src/main/java/dev/braintrust/instrumentation/langchain/v1_8_0/BraintrustLangchain.java — lines 36-51 (instanceof check limits to OpenAI only), lines 88-152 (OpenAI-specific wrapping via internal HttpClient)
  • braintrust-sdk/instrumentation/langchain_1_8_0/src/main/java/dev/braintrust/instrumentation/langchain/v1_8_0/auto/LangchainInstrumentationModule.java — lines 55-68, 85-100 (auto-instrumentation only targets OpenAI builders)
  • braintrust-sdk/instrumentation/langchain_1_8_0/src/main/java/dev/braintrust/instrumentation/langchain/v1_8_0/WrappedHttpClient.java — the HTTP client wrapper that could be reused for other providers
主要语言
Java
星标
21
派生
5
平均合并
1 天 20 小时
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

braintrustdata/braintrust-sdk-java 的其他 Issue

查看 braintrustdata/braintrust-sdk-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。