Skip to content

[OPIK-7496] [BE] fix: strip otel attribute rule prefix from saved key#7499

Merged
andrescrz merged 12 commits into
comet-ml:mainfrom
albe2669:strip-prefix-from-prefix-rules
Jul 21, 2026
Merged

[OPIK-7496] [BE] fix: strip otel attribute rule prefix from saved key#7499
andrescrz merged 12 commits into
comet-ml:mainfrom
albe2669:strip-prefix-from-prefix-rules

Conversation

@albe2669

Copy link
Copy Markdown
Contributor

Details

In the otel ingestion endpoint there are a few prefix attributes:

  • output
  • opik.metadata
  • gen_ai.usage
  • gen_ai.input
  • gen_ai.output
  • gen_ai.tool
  • gen_ai.agent
  • gen_ai.request
  • gen_ai.response

Which map into input, output or metadata. When matching the prefix rule the enrichSpanAttributes method sets the value in the respective bucket to the attribute key. This means that the attribute:
output: {"choices": [...]}, will be parsed as {"output": {"choices": [...]}}. Similarly, output.choices: [...] would parse as the same thing.

This PR strips the prefix of the matched rule, if the outcome is INPUT, OUTPUT or METADATA. This will allow an OpenTelemetry trace to produce a trace that is significantly closer to a native Opik trace.

Change checklist

  • User facing
  • Documentation update

Issues

AI-WATERMARK

AI-WATERMARK: [no]

Testing

mvn test

@albe2669
albe2669 requested a review from a team as a code owner July 16, 2026 15:31
@github-actions github-actions Bot added java Pull requests that update Java code Backend tests Including test files, or tests related like configuration. 🟡 size/M labels Jul 16, 2026
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
@albe2669
albe2669 marked this pull request as draft July 16, 2026 18:10
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
@albe2669
albe2669 marked this pull request as ready for review July 17, 2026 09:30

@andrescrz andrescrz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @albe2669

Thanks for the PR! I just finished reviewing it and left a few comments. When you have a chance, could you take a look and address them?

Thanks again for your contribution!

Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
@albe2669

Copy link
Copy Markdown
Contributor Author

Thank you for the review @andrescrz
I have tried to address your comments :).

@albe2669
albe2669 requested a review from andrescrz July 20, 2026 13:35

@andrescrz andrescrz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @albe2669

I left follow-up comments on one of the open discussions and also some additional feedback.

The main issue is that CI is failing, and it seems caused by changes related to this PR. Some tests in OpenTelemetryResourceTest seems to be the failing.

Please take a look and make sure the new code doesn't cause any regression.

I'll review once the fixes are in place.

Thanks a lot for your contribution.

Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
Comment thread apps/opik-backend/src/main/java/com/comet/opik/domain/OpenTelemetryMapper.java Outdated
@albe2669
albe2669 force-pushed the strip-prefix-from-prefix-rules branch from e9062f8 to 6b68657 Compare July 21, 2026 11:12
@albe2669
albe2669 marked this pull request as draft July 21, 2026 11:13
@albe2669
albe2669 marked this pull request as ready for review July 21, 2026 12:06

@andrescrz andrescrz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @albe2669

Thanks for the contribution! I reviewed the PR and everything looks good from my side. I've approved it, and all CI checks have passed successfully.

We'll merge it shortly, and the change will be included in the next Opik release.

Thanks again for contributing to Opik!

@andrescrz
andrescrz merged commit 4dc6b0c into comet-ml:main Jul 21, 2026
33 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend baz: pending java Pull requests that update Java code 🟠 size/L tests Including test files, or tests related like configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Strip rule prefix from otel attributes

2 participants