Skip to content

Refactor trace functions and update API documentation#636

Open
rasika2012 wants to merge 7 commits intowso2:mainfrom
rasika2012:remove-traces-bff
Open

Refactor trace functions and update API documentation#636
rasika2012 wants to merge 7 commits intowso2:mainfrom
rasika2012:remove-traces-bff

Conversation

@rasika2012
Copy link
Copy Markdown
Contributor

@rasika2012 rasika2012 commented Mar 26, 2026

Purpose

Related to: #398
This pull request removes all code related to the Trace Observer service from the agent-manager-service codebase. This includes deleting the client implementation, types, utility functions, route registration, mocks, and configuration for the Trace Observer service. The changes simplify the codebase by eliminating unused or deprecated distributed tracing functionality.

Key removals by theme:

Trace Observer Service Client and Types:

  • Deleted the entire traceobserversvc client implementation, including API calls, type definitions, and utility functions from agent-manager-service/clients/traceobserversvc/client.go, types.go, and utils.go. [1] [2] [3]

Mocks and Testing:

  • Removed the mock implementation for the Trace Observer client from agent-manager-service/clients/clientmocks/trace_observer_client_fake.go.

API Routing:

  • Removed the registration and implementation of observability routes from the API, including deleting registerObservabilityRoutes and its usages. [1] [2]

Configuration:

  • Removed all configuration fields and environment variable handling for the Trace Observer service from the config files and .env.example. [1] [2] [3] [4]

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • Architecture Changes

    • Console now connects directly to the Traces Observer service for trace listing/detail/export; agent manager no longer proxies those observability endpoints.
  • Security Enhancements

    • Traces Observer API is protected by JWT bearer authentication.
  • Configuration Updates

    • New runtime/config fields to set the observer base URL and auth settings; deployments and charts updated to supply these values.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 934a8e6e-3f65-4b62-80f3-b850302c77e0

📥 Commits

Reviewing files that changed from the base of the PR and between b142aba and dd8a281.

📒 Files selected for processing (1)
  • agent-manager-service/wiring/wire_gen.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • agent-manager-service/wiring/wire_gen.go

📝 Walkthrough

Walkthrough

The pull request removes trace-observability integration from agent-manager-service, moves trace endpoints and JWT-protected tracing responsibilities to traces-observer-service, updates console frontend to call the observer service using component/environment UIDs, and adjusts deployment/Helm/configs accordingly.

Changes

Cohort / File(s) Summary
Agent Manager Service — Observability removed
agent-manager-service/api/observability_routes.go, agent-manager-service/controllers/observability_controller.go, agent-manager-service/services/observability_manager.go, agent-manager-service/models/traces.go, agent-manager-service/clients/traceobserversvc/*, agent-manager-service/clients/clientmocks/*, agent-manager-service/tests/*
Deleted observability routes, controller, service, models, trace-observer client and mocks, and associated tests. Agent-manager no longer exposes or proxies trace endpoints.
Agent Manager Service — wiring & API surface
agent-manager-service/api/app.go, agent-manager-service/spec/api_default.go, agent-manager-service/docs/api_v1_openapi.yaml, agent-manager-service/wiring/..., agent-manager-service/config/*, agent-manager-service/.env.example
Removed trace-observer config and route registration; eliminated observability controller from DI/wire provider sets and OpenAPI/SDK clients. Removed TRACE_OBSERVER_URL example.
Console Frontend — observer client & hooks
console/workspaces/libs/api-client/src/apis/traces.ts, console/workspaces/libs/api-client/src/utils/utils.ts, console/workspaces/libs/api-client/src/hooks/traces.ts, console/workspaces/libs/types/src/config/index.ts
Added httpGETObserver, switched trace APIs to call observer endpoints directly, introduced UID-based params (componentUid, environmentUid, traceId), updated hooks and types, and added obsApiBaseUrl to config.
Console Frontend — components
console/workspaces/pages/traces/src/Traces.Component.tsx, console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx
Components now resolve componentUid and environmentUid (via agent/environments), gate requests on those prerequisites, and pass UIDs to observer APIs; updated export gating and loading/error states.
Traces Observer Service — API, auth, routing, docs
traces-observer-service/docs/openapi.yaml, traces-observer-service/openapi.yaml (deleted), traces-observer-service/main.go, traces-observer-service/middleware/auth.go, traces-observer-service/config/*, traces-observer-service/go.mod
Added JWT auth middleware with JWKS support and local-dev mode; restructured routing to mount authenticated /api/v1/* and unauthenticated /health; introduced new OpenAPI spec for observer service; expanded config and tests for auth settings.
Deployments & Helm changes
deployments/docker-compose.yml, deployments/helm-charts/.../values.yaml, deployments/helm-charts/.../templates/*, deployments/scripts/setup-openchoreo.sh
Removed backend TRACE_OBSERVER_URL config; added console OBS_API_BASE_URL Helm value; added traces-observer auth Helm values/env vars and adjusted setup script to helm upgrade --install with local-dev auth overrides.
Traces Observer Service examples & env
traces-observer-service/.env.example
Added IS_LOCAL_DEV_ENV and Key Manager example env vars (KEY_MANAGER_ISSUER, KEY_MANAGER_AUDIENCE, KEY_MANAGER_JWKS_URL).

Sequence Diagram(s)

sequenceDiagram
    participant Browser as Browser / Console
    participant AMS as Agent Manager Service
    participant TOS as Traces Observer Service
    participant KM as Key Manager (JWKS)

    rect rgba(200,150,255,0.5)
    Note over Browser,AMS: Old Flow (removed)
    Browser->>AMS: GET /api/v1/.../traces (org/proj/agent params)
    AMS->>AMS: Validate & translate
    AMS->>TOS: GET /api/v1/traces (observer)
    TOS-->>AMS: Trace response
    AMS-->>Browser: JSON response
    end

    rect rgba(150,255,150,0.5)
    Note over Browser,TOS: New Flow (current)
    Browser->>Browser: Resolve componentUid & environmentUid
    Browser->>TOS: GET /api/v1/traces?componentUid=...&environmentUid=... (Authorization: Bearer)
    TOS->>TOS: JWTAuth middleware extracts token
    TOS->>KM: Fetch JWKS (if needed)
    KM-->>TOS: JWKS keys
    TOS->>TOS: Verify signature, iss, aud
    TOS-->>Browser: TraceOverviewResponse
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

"🐰
I hopped through routes both old and new,
Pulled traces to their proper view,
JWT keys I stash in a cache,
UIDs now lead each frontend's dash,
Hooray — observability hops straight through!"

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a Purpose section with links to the related issue and lists key removals by theme, but most other required sections (Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Related PRs, Migrations, Test environment, Learning) are either completely missing or contain only placeholder template text. Complete the PR description by filling in all required sections, especially Goals, Release note, Documentation, Security checks (with yes/no answers), and Automation tests with actual test coverage details.
Docstring Coverage ⚠️ Warning Docstring coverage is 27.03% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Refactor trace functions and update API documentation" is partially related to the PR. While the PR does involve trace-related changes, the title is vague and doesn't clearly convey the main objective: removing Trace Observer service functionality from the codebase. Consider a more specific title such as "Remove Trace Observer service integration from agent-manager-service" to clearly communicate the primary change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (2)
traces-observer-service/docs/openapi.yaml (1)

416-421: Consider adding maxItems constraint to span arrays.

The spans array in TraceDetailsResponse lacks a maximum items constraint. Given that traces can contain many spans, consider adding maxItems to document the server-side limit and help API consumers handle pagination appropriately.

Optional enhancement
        spans:
          type: array
+          maxItems: 10000
          items:
            $ref: "#/components/schemas/Span"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@traces-observer-service/docs/openapi.yaml` around lines 416 - 421, The
TraceDetailsResponse schema's spans array (items: $ref:
"#/components/schemas/Span") lacks a maximum size; update the OpenAPI schema for
the spans property to include a sensible maxItems value (or a $ref to a reusable
constant) and a brief description indicating the server-side limit or that
pagination should be used, so consumers know the maximum number of Span objects
returned per response and can handle pagination using totalCount.
console/workspaces/libs/api-client/src/hooks/traces.ts (1)

92-112: Redundant validation for required typed properties.

The ExportTracesParams type defines componentUid and environmentUid as required string properties (lines 93-94). The runtime checks on lines 105-107 are therefore redundant since TypeScript enforces these at compile time. Unless you're defending against JavaScript callers bypassing type checks, consider removing this validation.

♻️ Suggested simplification
   return useApiMutation({
     action: { verb: 'create', target: 'trace export' },
     mutationFn: async (params: ExportTracesParams): Promise<TraceExportResponse> => {
       const { componentUid, environmentUid, startTime, endTime, limit, offset, sortOrder } = params;
-
-      if (!componentUid || !environmentUid) {
-        throw new Error("Missing required parameters for export");
-      }
-
       return exportTraces({ componentUid, environmentUid, startTime, endTime, limit, offset, sortOrder }, getToken);
     },
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@console/workspaces/libs/api-client/src/hooks/traces.ts` around lines 92 -
112, The runtime check in useExportTraces that throws an Error when componentUid
or environmentUid are missing is redundant because ExportTracesParams declares
those fields as required; remove the conditional block (the if (!componentUid ||
!environmentUid) { throw new Error(...) }) from the mutationFn in
useExportTraces so the function directly calls exportTraces({ componentUid,
environmentUid, startTime, endTime, limit, offset, sortOrder }, getToken); if
you intend to defend against untyped JS callers instead, replace the throw with
a brief runtime-guard comment and keep validation only after explicitly deciding
to support that scenario.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@console/workspaces/libs/api-client/src/utils/utils.ts`:
- Around line 121-122: The nullish-coalescing use in the base URL selection
allows empty strings to win; update the logic that sets baseUrl (currently using
globalConfig.obsApiBaseUrl ?? globalConfig.apiBaseUrl) to treat empty or
whitespace-only obsApiBaseUrl as "missing" and fall back to
globalConfig.apiBaseUrl instead; change the condition so it checks that
globalConfig.obsApiBaseUrl is a non-empty trimmed string (reference symbols:
baseUrl, globalConfig.obsApiBaseUrl, globalConfig.apiBaseUrl and the fetch call
that builds `${baseUrl}${context}?...`) and use that result for the fetch.

In `@console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx`:
- Around line 61-74: The trace UI currently calls useTrace before its
prerequisite UIDs are resolved; update the logic so trace fetching is gated on
agentData and environmentsData being settled and valid: ensure useTrace is only
invoked (or enabled) when componentUid (from agentData?.uuid) and environmentUid
(from environmentsData?.find(...)?.id) are non-null, and surface an explicit
loading state while those queries are pending and an explicit empty/error state
when either UID cannot be resolved; reference the hooks/useGetAgent,
useListEnvironments, and useTrace and the variables componentUid,
environmentUid, agentData, environmentsData, traceDetails, and isLoading when
implementing the gating and error/empty UI.

In `@console/workspaces/pages/traces/src/Traces.Component.tsx`:
- Around line 74-77: The code incorrectly treats route param envId as an
environment name and reverse-looks up environmentsData to get an id; instead
resolve the observer UID from the same stable identifier the router persists
(envId). Replace the lookup in Traces.Component.tsx (remove
environmentsData?.find(...) usage and the environmentUid assignment) and simply
set environmentUid = envId (or envId ?? undefined) so the route-provided ID is
used directly; apply the same change to the analogous code in TraceDetails.tsx
and ensure the type matches the expected environment UID type.

In `@traces-observer-service/config/config.go`:
- Around line 68-73: The AuthConfig is being loaded but not validated causing
the service to start with a broken JWT setup; update the config.validate() (or
add a validate() method on AuthConfig) to fail fast: if
Auth.AuthConfig.IsLocalDevEnv is false then require Auth.AuthConfig.JWKSUrl to
be non-empty (and optionally require Issuer/Audience entries), returning an
error when missing so startup aborts; ensure main.go (where the
config.validate() result is checked) propagates this error to stop the process
rather than starting with a bad config.

In `@traces-observer-service/docs/openapi.yaml`:
- Around line 58-59: Update the OpenAPI security requirement entries to use the
object-with-array syntax by replacing the bare "- bearerAuth" with "-
bearerAuth: []" for each trace endpoint; specifically edit the security block
under the /api/v1/trace, /api/v1/traces, and /api/v1/traces/export path
definitions so the security requirement lists bearerAuth with an empty array of
scopes.

In `@traces-observer-service/go.mod`:
- Line 7: The go.mod require line for github.com/golang-jwt/jwt/v5 is
incorrectly marked as indirect; since the jwt v5 package is directly imported in
the codebase (import path github.com/golang-jwt/jwt/v5), edit the go.mod require
statement for that module to remove the trailing "// indirect" so it reads
"require github.com/golang-jwt/jwt/v5 v5.3.1".

In `@traces-observer-service/middleware/auth.go`:
- Around line 119-128: The current JWKS lookup returns an immediate error when
the kid is missing from the cached jwks; change the flow in the code that calls
fetchJWKS and jwkToRSAPublicKey so that on a kid cache miss you attempt one
forced-refresh of the JWKS and retry the lookup before returning an error:
perform the initial fetchJWKS(cfg.JWKSUrl) and search jwks.Keys for kid, and if
not found call fetchJWKS with a force-refresh option (e.g.
fetchJWKS(cfg.JWKSUrl, true) or add a force parameter to fetchJWKS), re-scan the
returned jwks.Keys and only then call jwkToRSAPublicKey(&key) if found or return
fmt.Errorf("no key found for kid: %s", kid) after the retry.
- Around line 214-218: Replace the direct http.Get(jwksURL) call with a
context-aware request using a dedicated http.Client with a bounded timeout (use
10s to match the codebase), have the JWKS-fetching function accept a
context.Context parameter and propagate it into the request (e.g., create req,
use req = req.WithContext(ctx), then client.Do(req)), and validate
resp.StatusCode (expect 2xx) before reading/decoding the body; on non-2xx return
a clear error and still close resp.Body. Ensure callers of the JWKS fetch
function are updated to pass the context through.

---

Nitpick comments:
In `@console/workspaces/libs/api-client/src/hooks/traces.ts`:
- Around line 92-112: The runtime check in useExportTraces that throws an Error
when componentUid or environmentUid are missing is redundant because
ExportTracesParams declares those fields as required; remove the conditional
block (the if (!componentUid || !environmentUid) { throw new Error(...) }) from
the mutationFn in useExportTraces so the function directly calls exportTraces({
componentUid, environmentUid, startTime, endTime, limit, offset, sortOrder },
getToken); if you intend to defend against untyped JS callers instead, replace
the throw with a brief runtime-guard comment and keep validation only after
explicitly deciding to support that scenario.

In `@traces-observer-service/docs/openapi.yaml`:
- Around line 416-421: The TraceDetailsResponse schema's spans array (items:
$ref: "#/components/schemas/Span") lacks a maximum size; update the OpenAPI
schema for the spans property to include a sensible maxItems value (or a $ref to
a reusable constant) and a brief description indicating the server-side limit or
that pagination should be used, so consumers know the maximum number of Span
objects returned per response and can handle pagination using totalCount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f5094519-fcf8-4ad9-8223-aa38222b5b46

📥 Commits

Reviewing files that changed from the base of the PR and between ec8762a and b9af3cc.

⛔ Files ignored due to path filters (1)
  • traces-observer-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (42)
  • agent-manager-service/.env.example
  • agent-manager-service/api/app.go
  • agent-manager-service/api/observability_routes.go
  • agent-manager-service/clients/clientmocks/trace_observer_client_fake.go
  • agent-manager-service/clients/traceobserversvc/client.go
  • agent-manager-service/clients/traceobserversvc/types.go
  • agent-manager-service/clients/traceobserversvc/utils.go
  • agent-manager-service/config/config.go
  • agent-manager-service/config/config_loader.go
  • agent-manager-service/controllers/observability_controller.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/traces.go
  • agent-manager-service/services/observability_manager.go
  • agent-manager-service/spec/api_default.go
  • agent-manager-service/spec/client.go
  • agent-manager-service/spec/configuration.go
  • agent-manager-service/tests/get_trace_test.go
  • agent-manager-service/tests/list_traces_test.go
  • agent-manager-service/wiring/params.go
  • agent-manager-service/wiring/wire.go
  • agent-manager-service/wiring/wire_gen.go
  • console/apps/webapp/public/config.js
  • console/apps/webapp/public/config.template.js
  • console/workspaces/libs/api-client/src/apis/traces.ts
  • console/workspaces/libs/api-client/src/hooks/traces.ts
  • console/workspaces/libs/api-client/src/utils/utils.ts
  • console/workspaces/libs/types/src/config/index.ts
  • console/workspaces/pages/traces/src/Traces.Component.tsx
  • console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx
  • deployments/docker-compose.yml
  • deployments/helm-charts/wso2-agent-manager/templates/agent-manager-service/configmap.yaml
  • deployments/helm-charts/wso2-agent-manager/templates/console/configmap.yaml
  • deployments/helm-charts/wso2-agent-manager/values.yaml
  • deployments/helm-charts/wso2-amp-observability-extension/templates/deployment.yaml
  • deployments/helm-charts/wso2-amp-observability-extension/values.yaml
  • traces-observer-service/.env.example
  • traces-observer-service/config/config.go
  • traces-observer-service/docs/openapi.yaml
  • traces-observer-service/go.mod
  • traces-observer-service/main.go
  • traces-observer-service/middleware/auth.go
  • traces-observer-service/openapi.yaml
💤 Files with no reviewable changes (21)
  • agent-manager-service/config/config_loader.go
  • agent-manager-service/.env.example
  • deployments/docker-compose.yml
  • agent-manager-service/api/app.go
  • agent-manager-service/tests/get_trace_test.go
  • agent-manager-service/config/config.go
  • agent-manager-service/clients/traceobserversvc/utils.go
  • agent-manager-service/wiring/params.go
  • agent-manager-service/api/observability_routes.go
  • deployments/helm-charts/wso2-agent-manager/templates/agent-manager-service/configmap.yaml
  • agent-manager-service/wiring/wire.go
  • traces-observer-service/openapi.yaml
  • agent-manager-service/models/traces.go
  • agent-manager-service/controllers/observability_controller.go
  • agent-manager-service/clients/traceobserversvc/types.go
  • agent-manager-service/clients/clientmocks/trace_observer_client_fake.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/tests/list_traces_test.go
  • agent-manager-service/clients/traceobserversvc/client.go
  • agent-manager-service/services/observability_manager.go
  • agent-manager-service/spec/api_default.go

…s with JWT authentication middleware for secure access.
- Refactor trace-related components to improve readability and error handling, including updates to API calls and JWT validation. Enhance local development environment configurations and ensure proper handling of prerequisites in trace details and export functionalities.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
traces-observer-service/config/config.go (1)

133-138: Consider case-insensitive boolean parsing.

getEnvAsBool only recognizes "true" and "1" as truthy values. Common environment variable conventions also accept "TRUE", "True", "yes", etc. Consider using strings.EqualFold for case-insensitive comparison.

Proposed fix
 func getEnvAsBool(key string, defaultValue bool) bool {
 	if value := os.Getenv(key); value != "" {
-		return value == "true" || value == "1"
+		return strings.EqualFold(value, "true") || value == "1"
 	}
 	return defaultValue
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@traces-observer-service/config/config.go` around lines 133 - 138,
getEnvAsBool currently only treats "true" and "1" as truthy and is
case-sensitive; update getEnvAsBool to perform case-insensitive comparisons
(e.g., use strings.EqualFold or strings.ToLower) and extend accepted truthy
values to common variants like "true", "1", "yes", "y", "on" so values like
"TRUE" or "Yes" are recognized; modify the logic in getEnvAsBool to normalize
the env value and compare against the accepted set before falling back to
defaultValue.
traces-observer-service/docs/openapi.yaml (1)

455-460: Consider adding maxItems constraint to trace arrays.

The TraceListResponse.traces array (and similarly TraceExportResponse.traces at lines 518-521) lacks a maxItems constraint. While TraceDetailsResponse.spans correctly specifies maxItems: 1000, adding similar bounds to these arrays improves API contract clarity and helps clients allocate resources appropriately.

Proposed fix
     traces:
       type: array
+      maxItems: 1000
       items:
         $ref: "#/components/schemas/Trace"

Apply similar constraint to TraceExportResponse.traces.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@traces-observer-service/docs/openapi.yaml` around lines 455 - 460, Add a
maxItems constraint to the TraceListResponse.traces (and the
TraceExportResponse.traces) array schema to match the bound used for spans;
update the OpenAPI component where TraceListResponse.traces is defined to
include maxItems: 1000 (or the same numeric limit used by
TraceDetailsResponse.spans) so clients know the upper bound and can allocate
resources accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@traces-observer-service/config/config.go`:
- Around line 133-138: getEnvAsBool currently only treats "true" and "1" as
truthy and is case-sensitive; update getEnvAsBool to perform case-insensitive
comparisons (e.g., use strings.EqualFold or strings.ToLower) and extend accepted
truthy values to common variants like "true", "1", "yes", "y", "on" so values
like "TRUE" or "Yes" are recognized; modify the logic in getEnvAsBool to
normalize the env value and compare against the accepted set before falling back
to defaultValue.

In `@traces-observer-service/docs/openapi.yaml`:
- Around line 455-460: Add a maxItems constraint to the TraceListResponse.traces
(and the TraceExportResponse.traces) array schema to match the bound used for
spans; update the OpenAPI component where TraceListResponse.traces is defined to
include maxItems: 1000 (or the same numeric limit used by
TraceDetailsResponse.spans) so clients know the upper bound and can allocate
resources accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1f8b203-8951-46f0-88f2-49754d59538c

📥 Commits

Reviewing files that changed from the base of the PR and between b9af3cc and 24d1e4f.

⛔ Files ignored due to path filters (2)
  • console/common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • traces-observer-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • console/workspaces/libs/api-client/src/hooks/traces.ts
  • console/workspaces/libs/api-client/src/utils/utils.ts
  • console/workspaces/pages/traces/src/Traces.Component.tsx
  • console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx
  • deployments/scripts/setup-openchoreo.sh
  • traces-observer-service/config/config.go
  • traces-observer-service/config/config_test.go
  • traces-observer-service/docs/openapi.yaml
  • traces-observer-service/go.mod
  • traces-observer-service/middleware/auth.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • traces-observer-service/go.mod
  • console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx
  • console/workspaces/libs/api-client/src/utils/utils.ts
  • traces-observer-service/middleware/auth.go

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
traces-observer-service/docs/openapi.yaml (1)

455-460: Consider adding maxItems to array schemas for consistency.

Static analysis flagged that traces array in TraceListResponse lacks a maxItems constraint. While TraceDetailsResponse.spans has maxItems: 1000, other response arrays don't. This is a minor documentation hygiene issue that doesn't affect functionality.

💡 Optional fix
     TraceListResponse:
       type: object
       required:
         - traces
         - totalCount
       properties:
         traces:
           type: array
+          maxItems: 1000
           items:
             $ref: "#/components/schemas/Trace"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@traces-observer-service/docs/openapi.yaml` around lines 455 - 460, The
TraceListResponse schema's traces array is missing a maxItems constraint; add a
maxItems entry (e.g. maxItems: 1000 to match TraceDetailsResponse.spans) under
the traces property in the TraceListResponse schema so it reads traces: type:
array, items: $ref: "#/components/schemas/Trace", maxItems: 1000; ensure you
update the TraceListResponse definition referencing traces (and keep consistency
with TraceDetailsResponse.spans).
deployments/helm-charts/wso2-amp-observability-extension/templates/deployment.yaml (1)

44-52: Consider adding liveness/readiness probes targeting the unauthenticated /health endpoint.

The JWT auth environment variables are correctly configured. However, the Deployment lacks liveness and readiness probes. If probes are added later and mistakenly target /api/v1/* paths, they will fail with 401 Unauthorized since those paths require JWT authentication. The /health endpoint (line 94 of main.go) is unauthenticated and suitable for probes.

💡 Example probe configuration
           - name: KEY_MANAGER_AUDIENCE
             value: "{{ .Values.tracesObserver.auth.audience }}"
         resources:
           limits:
             memory: {{ .Values.tracesObserver.resourceLimits.memory }}
             cpu: {{ .Values.tracesObserver.resourceLimits.cpu }}
           requests:
             memory: {{ .Values.tracesObserver.resourceRequests.memory }}
             cpu: {{ .Values.tracesObserver.resourceRequests.cpu }}
+        livenessProbe:
+          httpGet:
+            path: /health
+            port: http
+          initialDelaySeconds: 10
+          periodSeconds: 15
+        readinessProbe:
+          httpGet:
+            path: /health
+            port: http
+          initialDelaySeconds: 5
+          periodSeconds: 10
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@deployments/helm-charts/wso2-amp-observability-extension/templates/deployment.yaml`
around lines 44 - 52, Add Kubernetes liveness/readiness probes to the
Deployment's container spec so they call the unauthenticated /health endpoint
(implemented in main.go at the /health handler) instead of any /api/v1/* paths
that require JWT; update the templates/deployment.yaml near the JWT env vars
(IS_LOCAL_DEV_ENV, KEY_MANAGER_JWKS_URL, KEY_MANAGER_ISSUER,
KEY_MANAGER_AUDIENCE) to include an httpGet probe for /health on the container
port, with sensible initialDelaySeconds/periodSeconds and failureThreshold for
both liveness and readiness so probes never hit auth-protected endpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@agent-manager-service/wiring/wire_gen.go`:
- Line 24: Regenerate the Wire output so the provider sets in wire_gen.go match
wire.go: run the Wire code generator (e.g., `wire`) from the package that
contains wire.go to update wire_gen.go, ensuring the missing providers
ProvideGitCredentialsService, services.NewGitSecretService, and
controllers.NewGitSecretController are included in the generated provider sets;
then commit the updated wire_gen.go so codegenfmt-check passes.

---

Nitpick comments:
In
`@deployments/helm-charts/wso2-amp-observability-extension/templates/deployment.yaml`:
- Around line 44-52: Add Kubernetes liveness/readiness probes to the
Deployment's container spec so they call the unauthenticated /health endpoint
(implemented in main.go at the /health handler) instead of any /api/v1/* paths
that require JWT; update the templates/deployment.yaml near the JWT env vars
(IS_LOCAL_DEV_ENV, KEY_MANAGER_JWKS_URL, KEY_MANAGER_ISSUER,
KEY_MANAGER_AUDIENCE) to include an httpGet probe for /health on the container
port, with sensible initialDelaySeconds/periodSeconds and failureThreshold for
both liveness and readiness so probes never hit auth-protected endpoints.

In `@traces-observer-service/docs/openapi.yaml`:
- Around line 455-460: The TraceListResponse schema's traces array is missing a
maxItems constraint; add a maxItems entry (e.g. maxItems: 1000 to match
TraceDetailsResponse.spans) under the traces property in the TraceListResponse
schema so it reads traces: type: array, items: $ref:
"#/components/schemas/Trace", maxItems: 1000; ensure you update the
TraceListResponse definition referencing traces (and keep consistency with
TraceDetailsResponse.spans).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7b3f32aa-e23e-41c6-9089-c7d20a8fb1a1

📥 Commits

Reviewing files that changed from the base of the PR and between 24d1e4f and 742163c.

⛔ Files ignored due to path filters (2)
  • console/common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • traces-observer-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (43)
  • agent-manager-service/.env.example
  • agent-manager-service/api/app.go
  • agent-manager-service/clients/clientmocks/trace_observer_client_fake.go
  • agent-manager-service/clients/traceobserversvc/client.go
  • agent-manager-service/clients/traceobserversvc/types.go
  • agent-manager-service/clients/traceobserversvc/utils.go
  • agent-manager-service/config/config.go
  • agent-manager-service/config/config_loader.go
  • agent-manager-service/controllers/observability_controller.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/traces.go
  • agent-manager-service/services/observability_manager.go
  • agent-manager-service/spec/api_default.go
  • agent-manager-service/spec/client.go
  • agent-manager-service/spec/configuration.go
  • agent-manager-service/tests/get_trace_test.go
  • agent-manager-service/tests/list_traces_test.go
  • agent-manager-service/wiring/params.go
  • agent-manager-service/wiring/wire.go
  • agent-manager-service/wiring/wire_gen.go
  • console/apps/webapp/public/config.js
  • console/apps/webapp/public/config.template.js
  • console/workspaces/libs/api-client/src/apis/traces.ts
  • console/workspaces/libs/api-client/src/hooks/traces.ts
  • console/workspaces/libs/api-client/src/utils/utils.ts
  • console/workspaces/libs/types/src/config/index.ts
  • console/workspaces/pages/traces/src/Traces.Component.tsx
  • console/workspaces/pages/traces/src/subComponents/TraceDetails.tsx
  • deployments/docker-compose.yml
  • deployments/helm-charts/wso2-agent-manager/templates/agent-manager-service/configmap.yaml
  • deployments/helm-charts/wso2-agent-manager/templates/console/configmap.yaml
  • deployments/helm-charts/wso2-agent-manager/values.yaml
  • deployments/helm-charts/wso2-amp-observability-extension/templates/deployment.yaml
  • deployments/helm-charts/wso2-amp-observability-extension/values.yaml
  • deployments/scripts/setup-openchoreo.sh
  • traces-observer-service/.env.example
  • traces-observer-service/config/config.go
  • traces-observer-service/config/config_test.go
  • traces-observer-service/docs/openapi.yaml
  • traces-observer-service/go.mod
  • traces-observer-service/main.go
  • traces-observer-service/middleware/auth.go
  • traces-observer-service/openapi.yaml
💤 Files with no reviewable changes (20)
  • agent-manager-service/config/config_loader.go
  • agent-manager-service/api/app.go
  • agent-manager-service/.env.example
  • agent-manager-service/clients/traceobserversvc/utils.go
  • deployments/docker-compose.yml
  • deployments/helm-charts/wso2-agent-manager/templates/agent-manager-service/configmap.yaml
  • agent-manager-service/wiring/wire.go
  • agent-manager-service/clients/clientmocks/trace_observer_client_fake.go
  • agent-manager-service/config/config.go
  • agent-manager-service/tests/get_trace_test.go
  • agent-manager-service/controllers/observability_controller.go
  • agent-manager-service/clients/traceobserversvc/types.go
  • traces-observer-service/openapi.yaml
  • agent-manager-service/models/traces.go
  • agent-manager-service/wiring/params.go
  • agent-manager-service/tests/list_traces_test.go
  • agent-manager-service/services/observability_manager.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/clients/traceobserversvc/client.go
  • agent-manager-service/spec/api_default.go
✅ Files skipped from review due to trivial changes (8)
  • agent-manager-service/spec/configuration.go
  • console/apps/webapp/public/config.js
  • console/apps/webapp/public/config.template.js
  • traces-observer-service/go.mod
  • traces-observer-service/.env.example
  • deployments/helm-charts/wso2-amp-observability-extension/values.yaml
  • console/workspaces/libs/types/src/config/index.ts
  • agent-manager-service/spec/client.go
🚧 Files skipped from review as they are similar to previous changes (6)
  • deployments/helm-charts/wso2-agent-manager/values.yaml
  • console/workspaces/libs/api-client/src/utils/utils.ts
  • deployments/helm-charts/wso2-agent-manager/templates/console/configmap.yaml
  • console/workspaces/pages/traces/src/Traces.Component.tsx
  • console/workspaces/libs/api-client/src/hooks/traces.ts
  • traces-observer-service/middleware/auth.go

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