Feature: LLM Observability for HTTP Service Calls #3245
Replies: 5 comments 7 replies
|
@aryanmehrotra @Umang01-hash please share your thoughts - will implement it accordingly |
|
This looks useful, especially if the same HTTP client may be used inside agent/tool loops rather than only direct chat completions. A few metric/label additions I would consider keeping optional so cardinality stays sane:
For buffering, I would make the size cap and redaction behavior explicit. LLM responses can be large, and observability code should fail open without changing the response path unless the user opts into strict behavior. Disclosure: I work on Armorer Labs. We see a similar pattern in agent ops: token metrics are useful, but they become much more actionable when they can be joined back to the specific run step, tool call, verifier, or retry that produced them. |
|
https://github.com/gofr-dev/gofr/releases/tag/v1.58.0 - this release has almost all the features we were discussing here |
|
reopen if needed |
Uh oh!
There was an error while loading. Please reload this page.
Problem
GoFr tracks standard HTTP metrics (
app_http_service_response) for outgoing service calls, but has no awareness of LLM-specific semantics. When users make HTTP calls to LLM providers (OpenAI, Anthropic, etc.), they get generic HTTP observability but no insight into:Proposal
Add an HTTP service decorator in a new package
pkg/gofr/service/observability/that intercepts responses from LLM APIs, extracts usage data from response bodies and headers, and records LLM-specific metrics.Metrics
app_llm_token_usageapp_llm_request_countapp_llm_tokens_per_requestLatency is already covered by the existing
app_http_service_responsehistogram.Pluggable Parser Interface
A
ResponseParserinterface allows users to add support for any LLM provider:Built-in parsers ship for OpenAI (also covers Azure OpenAI, Groq, Together, etc.) and Anthropic response formats. More can be added later.
User-Facing API
How It Works
The decorator follows GoFr's existing
service.Optionspattern (same as CircuitBreaker, Retry, RateLimiter):Structured Logging
An
llmLogstruct withPrettyPrintsupport logs each LLM call with: provider, model, operation, prompt tokens, completion tokens, total tokens, and status.Design Decisions
service/observability/) rather than adding to the already-largeservice/package. Other observability concerns can move here later.Feedback Welcome
Looking for input on:
All reactions