Skip to content

feat: add connector test cases and missing attributes - #5059

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-09-feat_add_connector_test_cases_and_missing_attributes
Jul 9, 2026
Merged

Pratham-Mishra04 merged 1 commit into
devfrom
07-09-feat_add_connector_test_cases_and_missing_attributes

Conversation

@roroghost17

@roroghost17 roroghost17 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces a canonical enrichment dimension registry (EnrichmentDims) in core/schemas as the single source of truth for the identity/context dimensions (provider, model, team, customer, business unit, virtual key, etc.) that connectors attach to telemetry. This prevents curated emitters — Prometheus labels, Datadog metric tags, BigQuery columns — from silently drifting apart when dimensions are added or removed.

Changes

  • Added core/schemas/enrichment.go defining EnrichmentDim and the EnrichmentDims registry, with helper functions (MetricSafeEnrichmentDims, EnrichmentDimNames, MetricSafeEnrichmentDimNames, EnrichmentDimColumnNames) for deriving connector-specific lists.
  • Added two new canonical span attribute constants, AttrBifrostAlias and AttrBifrostRoutingEngineUsed, to core/schemas/trace.go.
  • Updated framework/tracing/tracer.go to set AttrBifrostAlias and AttrBifrostRoutingEngineUsed on the span inside PopulateLLMResponseAttributes, so all connectors read these post-response dimensions from one place rather than computing them independently.
  • Promoted defaultBifrostLabelNames in plugins/telemetry/main.go from a local variable to a package-level variable so the conformance test can assert against it. Added business_unit_id and business_unit_name as Prometheus labels and extracted their values from context in PostLLMHook.
  • Added core/schemas/enrichment_test.go with structural guards: array (Multi) dimensions must never be MetricSafe, and all dimension names must be unique.
  • Added plugins/telemetry/parity_test.go as a conformance test asserting that the Prometheus label set covers every metric-safe registry dimension and contains no high-cardinality (record-tier) dimensions.

Type of change

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

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go test ./core/schemas/...
go test ./plugins/telemetry/...
go test ./framework/tracing/...
go test ./...

The new conformance test (TestPrometheusLabelsMatchEnrichmentRegistry) will fail if a metric-safe dimension is added to the registry but not to the Prometheus label list, or if a high-cardinality dimension is accidentally added as a label. The structural tests (TestArrayDimsAreNeverMetricSafe, TestEnrichmentDimNamesUnique) guard registry integrity.

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

N/A

Security considerations

No new auth, secrets, or PII handling introduced. The alias and routing_engine_used span attributes contain model names and routing engine identifiers, consistent with existing telemetry data already emitted.

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 applicable

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d64393e3-c85b-4a50-b839-47b1634987e7

📥 Commits

Reviewing files that changed from the base of the PR and between f82483a and 70e68aa.

📒 Files selected for processing (6)
  • core/schemas/enrichment.go
  • core/schemas/enrichment_test.go
  • core/schemas/trace.go
  • framework/tracing/tracer.go
  • plugins/telemetry/main.go
  • plugins/telemetry/parity_test.go
📝 Walkthrough

Walkthrough

This PR adds a canonical EnrichmentDim registry in core/schemas for identity/context dimensions, adds trace attribute constants and tracer enrichment for alias and routing-engine data, and extends telemetry labels with governance fields plus a parity test against the registry.

Changes

Enrichment Registry and Telemetry Parity

Layer / File(s) Summary
Enrichment dimension registry and helpers
core/schemas/enrichment.go, core/schemas/enrichment_test.go
Defines EnrichmentDim and EnrichmentDims, adds helper projections for column names and metric-safe names, and tests uniqueness plus multi-valued/metric-safe invariants.
Trace attribute constants and tracer enrichment
core/schemas/trace.go, framework/tracing/tracer.go
Adds AttrBifrostAlias and AttrBifrostRoutingEngineUsed, and sets both on spans from response extra fields and routing engines in context.
Telemetry label set and business unit enrichment
plugins/telemetry/main.go, plugins/telemetry/parity_test.go
Centralizes default label names, adds business unit label values in PostLLMHook, and verifies Prometheus labels stay aligned with the enrichment registry.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Tracer as PopulateLLMResponseAttributes
  participant Resp as Response
  participant Ctx as Context
  participant Span as Trace Span
  Tracer->>Resp: GetExtraFields (model resolution)
  Tracer->>Span: set AttrBifrostAlias if model differs
  Tracer->>Ctx: read routing engines
  Tracer->>Span: set AttrBifrostRoutingEngineUsed (joined)
Loading
sequenceDiagram
  participant Hook as PostLLMHook
  participant Governance
  participant Labels as labelValues map
  participant Prom as Prometheus Metrics
  Hook->>Governance: read business_unit_id/name
  Governance-->>Hook: businessUnitID, businessUnitName
  Hook->>Labels: append business_unit_id/name
  Labels->>Prom: emit request metrics with labels
Loading

Possibly related PRs

  • maximhq/bifrost#3732: Shares the core/schemas/trace.go attribute key space and tracing attribute population path, including bifrost.* constants.

Suggested reviewers: danpiths, akshaydeo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title is related to the change set, but it understates the canonical registry and telemetry label parity work.
Description check ✅ Passed The description matches the template and includes the required sections, with only minor checklist items left incomplete.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-09-feat_add_connector_test_cases_and_missing_attributes

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

@CLAassistant

CLAassistant commented Jul 9, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@roroghost17
roroghost17 force-pushed the 07-09-feat_add_connector_test_cases_and_missing_attributes branch from 1232b37 to af5c51c Compare July 9, 2026 10:00
@roroghost17
roroghost17 force-pushed the 06-30-fix_forwards_request_id_and_trace_id_through_telemetry branch from 8949996 to 575d0b6 Compare July 9, 2026 10:00
@roroghost17 roroghost17 mentioned this pull request Jul 9, 2026
18 tasks
@roroghost17
roroghost17 marked this pull request as ready for review July 9, 2026 10:03
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
core/schemas/enrichment.go Adds the canonical enrichment dimension registry and projection helpers for metric labels, tags, and columns.
core/schemas/enrichment_test.go Adds structural checks for duplicate dimension names and metric-safe array dimensions.
core/schemas/trace.go Adds span attribute constants for alias and routing engine usage.
framework/tracing/tracer.go Sets alias and routing engine span attributes during response attribute population.
plugins/telemetry/main.go Promotes the default Prometheus label list and adds business unit label values.
plugins/telemetry/parity_test.go Adds a parity test between Prometheus labels and the enrichment registry.

Reviews (3): Last reviewed commit: "feat: add connector test cases and missi..." | Re-trigger Greptile

Comment thread framework/tracing/tracer.go
Comment thread plugins/telemetry/parity_test.go

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/schemas/enrichment.go`:
- Around line 3-46: The type-level comment on EnrichmentDim is stale and
contradicts the registry and tracer behavior for alias and routing_engine_used.
Update the doc comment in EnrichmentDim to match the actual registry entries and
framework/tracing/tracer.go’s PopulateLLMResponseAttributes, stating that these
dimensions do have SpanAttr values and are attached to the span like other
dimensions so connectors can read them normally. Remove the obsolete guidance
about special-casing empty SpanAttr so future Datadog/BigQuery authors follow
the registry correctly.
🪄 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 Plus

Run ID: 48200d91-bab0-4890-8e79-3a6aeb99ff6a

📥 Commits

Reviewing files that changed from the base of the PR and between 575d0b6 and af5c51c.

📒 Files selected for processing (6)
  • core/schemas/enrichment.go
  • core/schemas/enrichment_test.go
  • core/schemas/trace.go
  • framework/tracing/tracer.go
  • plugins/telemetry/main.go
  • plugins/telemetry/parity_test.go

Comment thread core/schemas/enrichment.go
@roroghost17
roroghost17 force-pushed the 07-09-feat_add_connector_test_cases_and_missing_attributes branch from af5c51c to f82483a Compare July 9, 2026 11:53
@roroghost17
roroghost17 force-pushed the 06-30-fix_forwards_request_id_and_trace_id_through_telemetry branch from 575d0b6 to 4453cfd Compare July 9, 2026 11:53
@coderabbitai
coderabbitai Bot requested review from akshaydeo and danpiths July 9, 2026 11:55
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 9, 2026

Pratham-Mishra04 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Merge activity

  • Jul 9, 12:11 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 9, 12:25 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 9, 12:26 PM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 06-30-fix_forwards_request_id_and_trace_id_through_telemetry to graphite-base/5059 July 9, 2026 12:19
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5059 to dev July 9, 2026 12:24
@Pratham-Mishra04
Pratham-Mishra04 dismissed coderabbitai[bot]’s stale review July 9, 2026 12:24

The base branch was changed.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-09-feat_add_connector_test_cases_and_missing_attributes branch from f82483a to 70e68aa Compare July 9, 2026 12:24
@Pratham-Mishra04
Pratham-Mishra04 merged commit 384dfe3 into dev Jul 9, 2026
13 of 14 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-09-feat_add_connector_test_cases_and_missing_attributes branch July 9, 2026 12:26
akshaydeo pushed a commit that referenced this pull request Jul 14, 2026
## Summary

Introduces a canonical enrichment dimension registry (`EnrichmentDims`) in `core/schemas` as the single source of truth for the identity/context dimensions (provider, model, team, customer, business unit, virtual key, etc.) that connectors attach to telemetry. This prevents curated emitters — Prometheus labels, Datadog metric tags, BigQuery columns — from silently drifting apart when dimensions are added or removed.

## Changes

- Added `core/schemas/enrichment.go` defining `EnrichmentDim` and the `EnrichmentDims` registry, with helper functions (`MetricSafeEnrichmentDims`, `EnrichmentDimNames`, `MetricSafeEnrichmentDimNames`, `EnrichmentDimColumnNames`) for deriving connector-specific lists.
- Added two new canonical span attribute constants, `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed`, to `core/schemas/trace.go`.
- Updated `framework/tracing/tracer.go` to set `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed` on the span inside `PopulateLLMResponseAttributes`, so all connectors read these post-response dimensions from one place rather than computing them independently.
- Promoted `defaultBifrostLabelNames` in `plugins/telemetry/main.go` from a local variable to a package-level variable so the conformance test can assert against it. Added `business_unit_id` and `business_unit_name` as Prometheus labels and extracted their values from context in `PostLLMHook`.
- Added `core/schemas/enrichment_test.go` with structural guards: array (`Multi`) dimensions must never be `MetricSafe`, and all dimension names must be unique.
- Added `plugins/telemetry/parity_test.go` as a conformance test asserting that the Prometheus label set covers every metric-safe registry dimension and contains no high-cardinality (record-tier) dimensions.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [x] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/schemas/...
go test ./plugins/telemetry/...
go test ./framework/tracing/...
go test ./...
```

The new conformance test (`TestPrometheusLabelsMatchEnrichmentRegistry`) will fail if a metric-safe dimension is added to the registry but not to the Prometheus label list, or if a high-cardinality dimension is accidentally added as a label. The structural tests (`TestArrayDimsAreNeverMetricSafe`, `TestEnrichmentDimNamesUnique`) guard registry integrity.

## Screenshots/Recordings

N/A

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

No new auth, secrets, or PII handling introduced. The `alias` and `routing_engine_used` span attributes contain model names and routing engine identifiers, consistent with existing telemetry data already emitted.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
## Summary

Introduces a canonical enrichment dimension registry (`EnrichmentDims`) in `core/schemas` as the single source of truth for the identity/context dimensions (provider, model, team, customer, business unit, virtual key, etc.) that connectors attach to telemetry. This prevents curated emitters — Prometheus labels, Datadog metric tags, BigQuery columns — from silently drifting apart when dimensions are added or removed.

## Changes

- Added `core/schemas/enrichment.go` defining `EnrichmentDim` and the `EnrichmentDims` registry, with helper functions (`MetricSafeEnrichmentDims`, `EnrichmentDimNames`, `MetricSafeEnrichmentDimNames`, `EnrichmentDimColumnNames`) for deriving connector-specific lists.
- Added two new canonical span attribute constants, `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed`, to `core/schemas/trace.go`.
- Updated `framework/tracing/tracer.go` to set `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed` on the span inside `PopulateLLMResponseAttributes`, so all connectors read these post-response dimensions from one place rather than computing them independently.
- Promoted `defaultBifrostLabelNames` in `plugins/telemetry/main.go` from a local variable to a package-level variable so the conformance test can assert against it. Added `business_unit_id` and `business_unit_name` as Prometheus labels and extracted their values from context in `PostLLMHook`.
- Added `core/schemas/enrichment_test.go` with structural guards: array (`Multi`) dimensions must never be `MetricSafe`, and all dimension names must be unique.
- Added `plugins/telemetry/parity_test.go` as a conformance test asserting that the Prometheus label set covers every metric-safe registry dimension and contains no high-cardinality (record-tier) dimensions.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [x] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/schemas/...
go test ./plugins/telemetry/...
go test ./framework/tracing/...
go test ./...
```

The new conformance test (`TestPrometheusLabelsMatchEnrichmentRegistry`) will fail if a metric-safe dimension is added to the registry but not to the Prometheus label list, or if a high-cardinality dimension is accidentally added as a label. The structural tests (`TestArrayDimsAreNeverMetricSafe`, `TestEnrichmentDimNamesUnique`) guard registry integrity.

## Screenshots/Recordings

N/A

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

No new auth, secrets, or PII handling introduced. The `alias` and `routing_engine_used` span attributes contain model names and routing engine identifiers, consistent with existing telemetry data already emitted.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
## Summary

Introduces a canonical enrichment dimension registry (`EnrichmentDims`) in `core/schemas` as the single source of truth for the identity/context dimensions (provider, model, team, customer, business unit, virtual key, etc.) that connectors attach to telemetry. This prevents curated emitters — Prometheus labels, Datadog metric tags, BigQuery columns — from silently drifting apart when dimensions are added or removed.

## Changes

- Added `core/schemas/enrichment.go` defining `EnrichmentDim` and the `EnrichmentDims` registry, with helper functions (`MetricSafeEnrichmentDims`, `EnrichmentDimNames`, `MetricSafeEnrichmentDimNames`, `EnrichmentDimColumnNames`) for deriving connector-specific lists.
- Added two new canonical span attribute constants, `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed`, to `core/schemas/trace.go`.
- Updated `framework/tracing/tracer.go` to set `AttrBifrostAlias` and `AttrBifrostRoutingEngineUsed` on the span inside `PopulateLLMResponseAttributes`, so all connectors read these post-response dimensions from one place rather than computing them independently.
- Promoted `defaultBifrostLabelNames` in `plugins/telemetry/main.go` from a local variable to a package-level variable so the conformance test can assert against it. Added `business_unit_id` and `business_unit_name` as Prometheus labels and extracted their values from context in `PostLLMHook`.
- Added `core/schemas/enrichment_test.go` with structural guards: array (`Multi`) dimensions must never be `MetricSafe`, and all dimension names must be unique.
- Added `plugins/telemetry/parity_test.go` as a conformance test asserting that the Prometheus label set covers every metric-safe registry dimension and contains no high-cardinality (record-tier) dimensions.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [x] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/schemas/...
go test ./plugins/telemetry/...
go test ./framework/tracing/...
go test ./...
```

The new conformance test (`TestPrometheusLabelsMatchEnrichmentRegistry`) will fail if a metric-safe dimension is added to the registry but not to the Prometheus label list, or if a high-cardinality dimension is accidentally added as a label. The structural tests (`TestArrayDimsAreNeverMetricSafe`, `TestEnrichmentDimNamesUnique`) guard registry integrity.

## Screenshots/Recordings

N/A

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

No new auth, secrets, or PII handling introduced. The `alias` and `routing_engine_used` span attributes contain model names and routing engine identifiers, consistent with existing telemetry data already emitted.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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.

3 participants