feat(servicediscovery): add optional otel-events endpoint to the v3 response - #63
Conversation
|
Warning Review limit reachedNext included review available in 43 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe v3 service-discovery contract now supports an optional OTLP/gRPC event telemetry endpoint. ChangesOTLP event telemetry endpoint
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Service discovery v3 now advertises the OTLP event endpoint when configured and preserves existing responses when it is not. Configured, omitted, and round-trip behavior is covered, with no remaining merge-readiness risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
690ce8b to
9e20c00
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Adding v3-only methods to the shared IBackendServices interface can trigger runtime panics in v1/v2 implementations due to embedded nil interfaces.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an optional otel-events field to the v3 service-discovery response so backends can advertise an OTLP/gRPC endpoint for in-cluster agents to export raw event telemetry, while keeping the key omitted when unset for backward compatibility.
Changes:
- Extend
ServicesV3withOtelEventsUrlserialized asjson:"otel-events,omitempty". - Add v3 getters/setters and update the shared
IBackendServicesinterface with the new accessors. - Update v3 fixtures/tests to cover parsing, omission when unset, and round-tripping.
File summaries
| File | Description |
|---|---|
| pkg/servicediscovery/v3/datastructures.go | Adds optional otel-events field to the v3 services payload. |
| pkg/servicediscovery/v3/datastructuremethods.go | Adds v3 setter/getter and relies on omitempty for server omission behavior. |
| pkg/servicediscovery/schema/interface.go | Adds new accessors to IBackendServices for the v3-only endpoint. |
| pkg/servicediscovery/testdata/v3.json | Extends the v3 JSON fixture to include otel-events. |
| pkg/servicediscovery/servicediscovery_test.go | Adds assertions and a server-response omission/round-trip test for otel-events. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
matthyx
left a comment
There was a problem hiding this comment.
Blocking: the new accessors are added to the cross-version IBackendServices interface, but ServicesV1 and ServicesV2 only acquire them through their nil embedded schema.IBackendServices. Consequently, code that calls GetOtelEventsUrl() on a result from a v1/v2 service-discovery response panics instead of returning the documented empty value. This is especially risky during mixed-version rollout, where an updated agent may still talk to an older backend.
Please either implement explicit v1/v2 no-op accessors (GetOtelEventsUrl() string { return "" }, setter ignored) or split the interface so this accessor is only exposed on a v3 extension. Please also add v1/v2 regression coverage proving the chosen behavior does not panic. The v3 field/serialization path otherwise looks good, and go test plus go vet pass for ./pkg/servicediscovery/....
…esponse Backends can now advertise the OTLP/gRPC endpoint (host:port, TLS) that in-cluster agents export raw event telemetry to, alongside the existing metrics/storage entries. The key is omitted when unset, so existing clients and backends are unaffected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: kooomix <eranm@armosec.io>
…ared interface never panics Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: kooomix <eranm@armosec.io>
18e78ea to
276833b
Compare
matthyx
left a comment
There was a problem hiding this comment.
The follow-up commit adds explicit no-op v1/v2 accessors and regression coverage, resolving the mixed-version panic blocker. The v3 optional-field behavior and round trip look correct. Re-ran go test ./pkg/servicediscovery/..., go vet ./pkg/servicediscovery/..., and git diff --check; all pass.
…ew v4 response (#64) * feat(servicediscovery): move the optional otel-events endpoint to a new v4 response v3 returns to its pre-#63 shape; v4 = v3 + otel-events (omitted when unset). The shared interface keeps the accessors; v1/v2/v3 return an empty value. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: kooomix <eranm@armosec.io> * fix(servicediscovery/v4): close the HTTP body and file on every path, surface parse errors Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: kooomix <eranm@armosec.io> --------- Signed-off-by: kooomix <eranm@armosec.io> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Summary
Adds an optional
otel-eventsentry to the v3 service-discovery response so a backend can advertise the OTLP/gRPC endpoint (host:port, TLS) that in-cluster agents export raw event telemetry to, next to the existingmetricsandstorageentries. The key is omitted when the backend has no such endpoint configured, so current clients and backends are unaffected.Source of Truth
ARMO internal tracker SUB-8534 (agents fetch the AI-Sandbox OTel collector endpoint from service discovery instead of a hard-coded env var).
Changes
pkg/servicediscovery/v3/datastructures.go:ServicesV3.OtelEventsUrl(json:"otel-events,omitempty")pkg/servicediscovery/v3/datastructuremethods.go:SetOtelEventsUrl/GetOtelEventsUrlpkg/servicediscovery/schema/interface.go: the two accessors onIBackendServices(v3 only; v1/v2 embed the interface as before)pkg/servicediscovery/testdata/v3.json+servicediscovery_test.go: file fixture carries the key; stream fixture without it parses to empty; new test proves the server omits the key when unset and the client round-trips it when setTesting
go vet ./pkg/servicediscovery/... && go test ./pkg/servicediscovery/...— pass.Docs
Docs-exempt: field-level doc comments in the Go types; the package README documents only the test invocation.
AI Context
open_pr🤖 Generated with Claude Code
AI-skills: superpowers:brainstorming,armosec-shared-rules:agent-dispatch-policy,superpowers:writing-plans,superpowers:subagent-driven-development,armosec-shared-rules:open_pr,armosec-shared-rules:sync_plugin | cmds: /armosec-shared-rules:pr_comments
Summary by CodeRabbit