Skip to content

Add OpenTelemetry tracing with OpenInference support - #3773

Merged
vinit-chauhan merged 3 commits into
elastic:mainfrom
mjwolf:doc_update_6
Aug 3, 2026
Merged

Add OpenTelemetry tracing with OpenInference support#3773
vinit-chauhan merged 3 commits into
elastic:mainfrom
mjwolf:doc_update_6

Conversation

@mjwolf

@mjwolf mjwolf commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Adds OpenTelemetry tracing for LLM conversations and tool calls using OpenInference semantic conventions. Tracing is generic and can connect to any OTLP-compatible collector endpoint.

@mjwolf
mjwolf requested review from a team as code owners July 21, 2026 22:05
@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

make check-static fails because the new internal/llmagent/tracing/phoenix.go exceeds the repository’s configured gocognit threshold. This is a deterministic code-quality failure, not an infrastructure or flaky-test issue.

Remediation

  • Refactor (*PhoenixClient).generateSummary (line 355, cognitive complexity 193) into focused helpers for per-span aggregation and each event category, while preserving the existing summary output and sorting.
  • Refactor parseValidationSpan (line 656, cognitive complexity 76) into helpers for attribute extraction and output fallback, or otherwise reduce its branching; avoid suppressing gocognit unless there is a documented, justified exception.
  • Run make check-static (or the repository lint target) on the updated commit.
Investigation details

Root Cause

The failed make check-static step runs golangci-lint-v2.12.2. The configured gocognit.min-complexity is 62 in .golangci.yml, but the PR adds two functions above that limit:

  • internal/llmagent/tracing/phoenix.go:355: (*PhoenixClient).generateSummary has complexity 193.
  • internal/llmagent/tracing/phoenix.go:656: parseValidationSpan has complexity 76.

Both functions are part of the PR’s new Phoenix tracing implementation, so the failure is introduced by this change.

Evidence

  • Build: https://buildkite.com/elastic/elastic-package/builds/8390
  • Job/step: :go: Run check-static / make check-static
  • Key log excerpt: internal/llmagent/tracing/phoenix.go:355:1: cognitive complexity 193 ... (> 62) and internal/llmagent/tracing/phoenix.go:656:1: cognitive complexity 76 ... (> 62)

Verification

No commands were run against the PR checkout; the diagnosis is based on the failed Buildkite log and the PR source/configuration.


What is this? | From workflow: PR Buildkite Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@mjwolf
mjwolf requested a review from vinit-chauhan July 21, 2026 22:57

@mrodm mrodm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM changes related to go.mod/go.sum and README.

Just added a minor question about the README.

Approved but @elastic/integration-experience must approve for the changes under internal/llmagent before merging this PR.

Comment thread tools/readme/readme.md.tmpl Outdated
- To configure LLM providers for AI-powered documentation generation (`elastic-package update documentation`):
- `ELASTIC_PACKAGE_LLM_PROVIDER` / **llm.provider**: Provider name. Gemini is the default provider.
- Gemini: `GOOGLE_API_KEY` / **llm.gemini.api_key**, `GEMINI_MODEL` / **llm.gemini.model**, `GEMINI_THINKING_BUDGET` / **llm.gemini.thinking_budget**.
- LLM tracing is configured via profile config only: **llm.tracing.enabled**, **llm.tracing.endpoint**, **llm.tracing.api_key**, **llm.tracing.project_name** (see `config.yml.example`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it be mentioned that by default is enabled ?

enabledStr := p.Config("llm.tracing.enabled", "false")

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 disabled by default. I've updated this line to say so.

@mjwolf mjwolf changed the title Add OpenTelemetry tracing with Phoenix support Add OpenTelemetry tracing with OpenInference support Jul 30, 2026
Adds OpenTelemetry tracing for LLM conversations and tool calls using
OpenInference semantic conventions. Tracing is generic and can connect
to any OTLP-compatible collector endpoint.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Make tracing backend-neutral and preserve accurate span, tool-call, and shutdown behavior across OTLP exporters.

Co-authored-by: Cursor <[email protected]>
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

@vinit-chauhan

Copy link
Copy Markdown
Contributor

Thanks Mike for adding the commit, I'm approving the overall all change. Requesting @elastic/integration-experience for another set of eyes.

@vinit-chauhan
vinit-chauhan merged commit 0fc98c1 into elastic:main Aug 3, 2026
4 checks passed
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.

4 participants