Skip to content

fix: otel plugin fixes#2727

Merged
akshaydeo merged 1 commit into
mainfrom
04-15-fix_otel_plugin_fixes
Apr 15, 2026
Merged

fix: otel plugin fixes#2727
akshaydeo merged 1 commit into
mainfrom
04-15-fix_otel_plugin_fixes

Conversation

@sammaji
Copy link
Copy Markdown
Member

@sammaji sammaji commented Apr 15, 2026

Summary

Normalizes the OTEL plugin trace type from the legacy "otel" value to "genai_extension" across the codebase. This change standardizes the naming convention and improves clarity about the trace format being used.

Changes

  • Added database migration to automatically update existing OTEL plugin configurations from "otel" to "genai_extension"
  • Updated configuration schema to only accept "genai_extension" as a valid trace type
  • Modified UI components to default to "genai_extension" and display clearer option labels
  • Enhanced OTEL plugin metrics recording to emit per-attempt metrics for better observability of retries and fallbacks
  • Refactored span attribute extraction into reusable buildSpanAttrs function
  • Updated UI select component styling for better consistency

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (Next.js)
  • Docs

How to test

Verify the migration runs successfully and existing OTEL configurations are updated:

# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Test that existing OTEL plugin configurations with trace_type: "otel" are automatically migrated to trace_type: "genai_extension" on startup.

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

The migration ensures backward compatibility by automatically updating existing configurations.

Related issues

N/A

Security considerations

The migration handles plugin configuration updates safely by preserving existing settings while only modifying the trace_type field.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicablecg

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

Chores

  • Updated OTEL plugin trace type identifier to "genai_extension"
  • Refreshed UI forms and validation schemas to reflect configuration updates
  • Improved metric recording logic for enhanced span attribute handling
  • Added automatic database migration for existing plugin configurations

Walkthrough

The PR standardizes OTEL trace type nomenclature from "otel" to "genai_extension" through a new database migration that updates existing plugin configurations, refactored metrics recording logic using per-attempt span attributes, and corresponding updates to configuration schemas, frontend forms, and TypeScript type definitions.

Changes

Cohort / File(s) Summary
Database Migration
framework/configstore/migrations.go
Introduced migrationNormalizeOtelTraceType to normalize existing "otel" trace types to "genai_extension" in plugin configurations, with encryption status reset and conditional persistence logic.
Metrics Recording Logic
plugins/otel/main.go
Refactored recordMetricsFromTrace to track finalSpan instead of llmSpan and added buildSpanAttrs helper for consistent per-attempt metric dimension extraction and per-trace metric recording.
Configuration Schema
transports/config.schema.json, ui/lib/types/schemas.ts
Updated trace type enum values from "otel" to "genai_extension" and adjusted default trace type value across JSON schema and Zod validation.
Frontend Form & Components
ui/app/workspace/observability/fragments/otelFormFragment.tsx, ui/components/ui/select.tsx
Updated OTEL form fragment to use "genai_extension" as default and single recommended option, with deprecated options marked as disabled; minor Select component prop and formatting adjustments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hops with glee through trace type trails,
From "otel" whispers to "genai" tales,
Metrics dance with spans anew,
Schemas align in genai blue,
One name to bind them all—hooray!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 04-15-fix_otel_plugin_fixes

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

Copy link
Copy Markdown
Member Author

sammaji commented Apr 15, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Suite Available

This PR can be tested by a repository admin.

Run tests for PR #2727

@sammaji sammaji marked this pull request as ready for review April 15, 2026 09:27
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 15, 2026

Confidence Score: 5/5

Safe to merge — no new P0/P1 issues found; previously raised concerns are addressed or explicitly acknowledged by the team.

All P0/P1 concerns from prior threads (file-config breaking change, insecure default, Zod/JSON-schema divergence) are acknowledged or fixed. The remaining findings are P2 style items (trailing newlines, SpanStatusUnset guard) that do not affect correctness or production behaviour.

No files require special attention beyond the acknowledged file-based config migration caveat.

Important Files Changed

Filename Overview
framework/configstore/migrations.go Adds migrationNormalizeOtelTraceType to rename trace_type "otel"→"genai_extension" in DB; migration correctly relies on AfterFind/BeforeSave GORM hooks to handle encrypted configs transparently
plugins/otel/main.go Adds custom UnmarshalJSON for Insecure default (true when omitted), extracts buildSpanAttrs helper, and refactors recordMetricsFromTrace to emit per-attempt request/latency/error metrics for every llm.call and retry span while keeping token/cost/TTFT metrics on the final span only
plugins/otel/metrics.go Bumps semconv import from v1.39.0 to v1.40.0; go.mod pins otel v1.43.0 which carries the new semconv sub-package
transports/config.schema.json Restricts trace_type enum to "genai_extension" only; file-based config users with "otel" must manually update (no auto-migration for file configs); trailing newline removed
ui/app/workspace/observability/fragments/otelFormFragment.tsx Updates trace_type default to "genai_extension", adds vercel/open_inference as disabled "coming soon" options, renames the existing option label
ui/components/ui/select.tsx Adds native disabled={disabled} prop to SelectPrimitive.Item (previously only data-disabled was set, leaving items functionally clickable), reorders Tailwind class groups, trailing newline removed
ui/lib/types/schemas.ts Updates otelConfigSchema trace_type enum to ["genai_extension","vercel","open_inference"]; vercel/open_inference pass Zod validation but are rejected by config.schema.json (already noted in prior thread)
plugins/otel/changelog.md New changelog file documenting the insecure default change (now correctly says "true") and per-attempt fallback metrics fix; missing trailing newline

Reviews (3): Last reviewed commit: "fix: otel plugin fixes" | Re-trigger Greptile

Comment thread transports/config.schema.json
Comment thread ui/lib/types/schemas.ts
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
plugins/otel/main.go (1)

379-422: ⚠️ Potential issue | 🔴 Critical

Remove schemas.SpanKindRetry from the candidate pool when selecting finalSpan for usage metrics.

Retry spans are created as control-flow wrappers (line 4778 in core/bifrost.go) and do not receive usage attributes. All usage attribute population occurs exclusively in LLM response handlers in framework/tracing/llmspan.go and framework/tracing/tracer.go, which only fire for LLM call attempts, not retry control flow. Since finalSpan selection picks the span with the latest EndTime, a retry wrapper that ends after all LLM calls will suppress metrics recording on retried requests. Change line 360 to consider only schemas.SpanKindLLMCall spans.

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

In `@plugins/otel/main.go` around lines 379 - 422, The finalSpan selection
currently considers retry wrapper spans and can pick a retry
(schemas.SpanKindRetry) which has no usage attrs; update the selection logic in
plugins/otel/main.go so that when iterating spans to choose finalSpan you only
consider spans of kind schemas.SpanKindLLMCall (ignore schemas.SpanKindRetry),
ensuring finalSpan points to an LLM call span that contains usage attributes (so
subsequent reads of finalSpan.Attributes, buildSpanAttrs, and
metricsExporter.Record* calls use the correct span).
transports/config.schema.json (1)

1318-1323: ⚠️ Potential issue | 🟠 Major

Test fixtures must be updated to use "genai_extension" or schema validation will fail.

The enum change at line 1322 restricts trace_type to ["genai_extension"] only. However, ValidateConfigSchema() in transports/bifrost-http/lib/validator.go validates input JSON directly against the schema without normalizing legacy "otel" values. This will cause immediate failures in three test functions:

  • TestValidateConfigSchema_OtelPlugin_Valid (line 1195)
  • TestValidateConfigSchema_OtelPlugin_MissingCollectorUrl (line 1218)
  • TestValidateConfigSchema_OtelPlugin_MissingProtocol (line 1264)

The database migration migrationNormalizeOtelTraceType handles existing rows, but does not affect validation of static config files or test fixtures. Per coding guidelines, verify stack coordination: ensure fixture updates are included in this PR or a dependent stack PR, and update the example config at examples/configs/withobservability/config.json:32 accordingly.

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

In `@transports/config.schema.json` around lines 1318 - 1323, Update the tests and
example config to use the new enum value "genai_extension" so schema validation
passes: change the trace_type in the fixtures used by
TestValidateConfigSchema_OtelPlugin_Valid,
TestValidateConfigSchema_OtelPlugin_MissingCollectorUrl, and
TestValidateConfigSchema_OtelPlugin_MissingProtocol to "genai_extension" and
update the example config used by examples/docs to match; alternatively, if you
prefer preserving legacy "otel" during validation, add a normalization step
inside ValidateConfigSchema() to map "otel" -> "genai_extension" before running
JSON schema validation (note migrationNormalizeOtelTraceType only handles DB
rows and does not affect static fixture validation).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/lib/types/schemas.ts`:
- Around line 714-717: The UI schema for trace_type in ui/lib/types/schemas.ts
currently enumerates ["genai_extension", "vercel", "open_inference"], which
diverges from the backend-authoritative transports/config.schema.json that only
allows "genai_extension"; update the enum in the trace_type schema to only
permit "genai_extension" (preserve the default "genai_extension") so the
client-side validation matches the backend schema and avoids
client-pass/server-fail mismatches.

---

Outside diff comments:
In `@plugins/otel/main.go`:
- Around line 379-422: The finalSpan selection currently considers retry wrapper
spans and can pick a retry (schemas.SpanKindRetry) which has no usage attrs;
update the selection logic in plugins/otel/main.go so that when iterating spans
to choose finalSpan you only consider spans of kind schemas.SpanKindLLMCall
(ignore schemas.SpanKindRetry), ensuring finalSpan points to an LLM call span
that contains usage attributes (so subsequent reads of finalSpan.Attributes,
buildSpanAttrs, and metricsExporter.Record* calls use the correct span).

In `@transports/config.schema.json`:
- Around line 1318-1323: Update the tests and example config to use the new enum
value "genai_extension" so schema validation passes: change the trace_type in
the fixtures used by TestValidateConfigSchema_OtelPlugin_Valid,
TestValidateConfigSchema_OtelPlugin_MissingCollectorUrl, and
TestValidateConfigSchema_OtelPlugin_MissingProtocol to "genai_extension" and
update the example config used by examples/docs to match; alternatively, if you
prefer preserving legacy "otel" during validation, add a normalization step
inside ValidateConfigSchema() to map "otel" -> "genai_extension" before running
JSON schema validation (note migrationNormalizeOtelTraceType only handles DB
rows and does not affect static fixture validation).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e55929f-9843-4164-be0d-3174dd0f7008

📥 Commits

Reviewing files that changed from the base of the PR and between 67938e2 and 6aa86b9.

📒 Files selected for processing (6)
  • framework/configstore/migrations.go
  • plugins/otel/main.go
  • transports/config.schema.json
  • ui/app/workspace/observability/fragments/otelFormFragment.tsx
  • ui/components/ui/select.tsx
  • ui/lib/types/schemas.ts

Comment thread ui/lib/types/schemas.ts
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 15, 2026
Comment thread plugins/otel/main.go
@sammaji sammaji force-pushed the 04-15-fix_otel_plugin_fixes branch from 577dc33 to e2f70ee Compare April 15, 2026 11:56
@akshaydeo akshaydeo merged commit 5d3b34b into main Apr 15, 2026
17 of 18 checks passed
@akshaydeo akshaydeo deleted the 04-15-fix_otel_plugin_fixes branch April 15, 2026 12:18
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.

2 participants