Skip to content

feat(servicediscovery): add optional otel-events endpoint to the v3 response - #63

Merged
kooomix merged 2 commits into
mainfrom
feat/servicediscovery-v3-otel-events
Sep 9, 2026
Merged

kooomix merged 2 commits into
mainfrom
feat/servicediscovery-v3-otel-events

Conversation

@kooomix

@kooomix kooomix commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional otel-events entry 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 existing metrics and storage entries. 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 / GetOtelEventsUrl
  • pkg/servicediscovery/schema/interface.go: the two accessors on IBackendServices (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 set

Testing

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

Category Used
Skills None
MCP Servers None
Rules/Commands 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

  • New Features
    • Added support for configuring and retrieving an optional OpenTelemetry events endpoint in v3 service discovery.
    • Service discovery responses now include the telemetry endpoint when configured and omit it when unset.
  • Tests
    • Added coverage for endpoint retrieval, omission when unconfigured, and value round-tripping.

@kooomix kooomix added the ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) label Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 60a2eff8-f3d4-48ed-9ca9-104595053572

📥 Commits

Reviewing files that changed from the base of the PR and between 9e20c00 and 276833b.

📒 Files selected for processing (3)
  • pkg/servicediscovery/servicediscovery_test.go
  • pkg/servicediscovery/v1/datastructuresmethods.go
  • pkg/servicediscovery/v2/datastructuremethods.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ecb0dd71-102d-4fe4-9bd1-c54a536c6de7

📥 Commits

Reviewing files that changed from the base of the PR and between 7cce7f4 and 690ce8b.

📒 Files selected for processing (5)
  • pkg/servicediscovery/schema/interface.go
  • pkg/servicediscovery/servicediscovery_test.go
  • pkg/servicediscovery/testdata/v3.json
  • pkg/servicediscovery/v3/datastructuremethods.go
  • pkg/servicediscovery/v3/datastructures.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The v3 service-discovery contract now supports an optional OTLP/gRPC event telemetry endpoint. ServicesV3 exposes the field through setter and getter methods. Tests validate parsing, JSON omission when unset, and round-trip behavior.

Changes

OTLP event telemetry endpoint

Layer / File(s) Summary
Endpoint contract and accessors
pkg/servicediscovery/schema/interface.go, pkg/servicediscovery/v3/datastructures.go, pkg/servicediscovery/v3/datastructuremethods.go
Adds OtelEventsUrl to v3 service discovery, exposes setter and getter methods, and updates IBackendServices.
Parsing and serialization validation
pkg/servicediscovery/testdata/v3.json, pkg/servicediscovery/servicediscovery_test.go
Tests populated and omitted endpoint values, JSON omission when unset, and client round-trip parsing.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 9e20c

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an optional otel-events endpoint to the v3 service-discovery response.
Full details: Docstring Coverage

Explanation

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 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/servicediscovery-v3-otel-events

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kooomix
kooomix force-pushed the feat/servicediscovery-v3-otel-events branch from 690ce8b to 9e20c00 Compare September 9, 2026 05:41
@kooomix
kooomix requested a lite review from Copilot September 9, 2026 05:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 ServicesV3 with OtelEventsUrl serialized as json:"otel-events,omitempty".
  • Add v3 getters/setters and update the shared IBackendServices interface 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.

Comment thread pkg/servicediscovery/schema/interface.go

@matthyx matthyx 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.

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/....

kooomix and others added 2 commits September 9, 2026 08:55
…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>
@kooomix
kooomix force-pushed the feat/servicediscovery-v3-otel-events branch from 18e78ea to 276833b Compare September 9, 2026 05:55

@matthyx matthyx 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.

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.

@kooomix
kooomix merged commit 4d560cd into main Sep 9, 2026
4 checks passed
kooomix added a commit that referenced this pull request Sep 9, 2026
…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>
@matthyx matthyx moved this to To Archive in KS PRs tracking Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants