Skip to content

feat(go): Go SDK with OpenAI instrumentor#166

Open
pmady wants to merge 5 commits intofuture-agi:mainfrom
pmady:feat/go-sdk
Open

feat(go): Go SDK with OpenAI instrumentor#166
pmady wants to merge 5 commits intofuture-agi:mainfrom
pmady:feat/go-sdk

Conversation

@pmady
Copy link
Copy Markdown

@pmady pmady commented May 6, 2026

What does this PR do?

Adds a Go SDK for traceAI. Two modules:

  • go/traceai — core setup (TracerProvider config, GenAI semconv keys, env-based defaults)
  • go/traceai_openai — HTTP middleware for the openai-go client that captures chat/completion/embedding calls as OTel spans

Why?

Go SDK was listed on the roadmap (#164 finding 7). Lots of Go services calling LLM APIs directly or through gateways, and there was no Go instrumentation path.

How was it tested?

  • go test ./... passes in both modules (4 tests covering happy path, passthrough, error, content capture toggle)
  • go vet ./... clean
  • Integration tests pass (or N/A — no live API calls in tests)

Checklist

  • Branch is off main
  • Commit messages follow Conventional Commits
  • No TODOs or commented-out code
  • No API keys or secrets in the diff
  • README included

Notes for reviewers

5 commits over ~9 days. The middleware operates on net/http types so it doesn't pull in the openai-go library as a dependency — works with any HTTP client that hits the OpenAI API path patterns.

Related: #164, #165

pmady added 5 commits April 28, 2026 16:25
Scaffold the Go SDK with OTel TracerProvider setup, GenAI
semantic convention keys, and the Instrumentor interface.

Signed-off-by: pmady <pavan4devops@gmail.com>
HTTP middleware that intercepts chat/completion/embedding
calls and records them as OTel spans with GenAI semconv
attributes.

Signed-off-by: pmady <pavan4devops@gmail.com>
Covers chat completion happy path, non-AI endpoint passthrough,
error response handling, and content capture toggle.

Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady
Copy link
Copy Markdown
Author

pmady commented May 6, 2026

this covers finding 7 from #164. middleware approach means no hard dep on the openai-go library -- any HTTP client hitting their API paths gets traced.

the module structure mirrors what python does (core + per-framework packages) so adding anthropic/cohere later is straightforward.

cc @niaborowy @JayaSurya-27

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.

1 participant