Repository navigation
feat: one-call, env-driven observability and audit instrumentation - #159
Merged
Merged
Conversation
…ndpoint - tel.Instrument(loop) wires loop, LLM and every registered tool; no-op when telemetry is off, idempotent (otelllm/oteltools skip already-wrapped). - tools.Registry.Use wraps an already-populated registry. - Fix: OTEL_EXPORTER_OTLP_ENDPOINT=host:port (no scheme) failed every export with an empty host; it is now passed to the exporter as host:port. - Chat span is named "chat" when the model is unknown.
- FromEnv reads GOPHERAGENT_AUDIT_*; unset endpoint returns a nil client whose methods are no-ops, so the same code runs with auditing on or off. - audit.Instrument(loop) wires tools, HITL, permissions and hook rejections. - Config.DefaultTenantID (env default "default") so single-tenant apps need no WithActor; without it every record failed validation.
- GOPHERAGENT_AUDIT_REQUIRED=true makes a missing endpoint an error instead of silently disabling auditing. - FromEnv reports audit health on the global OTel meter, so failed/dropped records alert without extra wiring. - Both Instrument calls warn once about tools, HITL or permissions attached after them (compared by name, no false alarm on extra middleware).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Makes observability and audit logging one call each, enabled purely by env. Without env they do nothing, so the same code runs everywhere. Also fixes a bug that broke the env-only OTel setup.
Changes
Providers.Instrument(loop, ...): wires the loop, its LLM and every registered tool. No-op when disabled; idempotent.tools.Registry.Use(mw...): wraps an already-populated registry, including YAML-built ones.OTEL_EXPORTER_OTLP_ENDPOINT=host:port(no scheme, as our docs showed) failed every export withdns resolver: missing address. Scheme-less values are now passed as host:port; URLs still go to the exporter.auditlog.FromEnv+Client.Instrument(loop, ...): a nil*Clientis a valid disabled client.Config.DefaultTenantID: single-tenant apps no longer needWithActor. Before this, every Instrument-produced record failed validation.Testing
host:portand URL forms; it fails without the fix.Checklist
gofmt -l .prints nothingmake lintis cleanmake buildpassesmake testandmake test-racepassCHANGELOG.mdupdated if this PR is cut as a release tag (at tag time)pkg/telemetry/changes approved by the maintainer