Skip to content

feat(ourlogs): Add otel log to sentry log transform - #5128

Merged
AbhiPrasad merged 5 commits into
masterfrom
abhi-relay-otel-pkg
Sep 11, 2025
Merged

AbhiPrasad merged 5 commits into
masterfrom
abhi-relay-otel-pkg

Conversation

@AbhiPrasad

@AbhiPrasad AbhiPrasad commented Sep 9, 2025 •

Copy link
Copy Markdown
Contributor

#skip-changelog

As per #5111, we'd like to add an OTLP logs endpoint to Relay. More details on the motivation can be found in this internal notion doc: https://www.notion.so/sentry/Logs-OTLP-Endpoint-2638b10e4b5d8050a147d0dd46df1915 (contains screenshots so can't put them in GH).

Before we implement the endpoint itself, this PR adds a otel_to_sentry_log to the relay-ourlogs crate. otel_to_sentry_log is a cleaned up version of the otel log to sentry log transform we had previously implemented and then removed in #5082.

To make the otel_to_sentry_log, I extracted out a otel_value_to_attr from the relay-spans crate into a relay-otel crate. Not sure if this is the correct level of abstraction, would appreciate feedback.

Skipping changelog as this does not expose any user facing changes, only new methods and refactors. Once I add the endpoint in a future PR, I will add a changelog there.

@AbhiPrasad
AbhiPrasad requested a review from k-fish September 9, 2025 19:18
@AbhiPrasad AbhiPrasad self-assigned this Sep 9, 2025
@AbhiPrasad
AbhiPrasad requested a review from a team as a code owner September 9, 2025 19:18
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment thread relay-otel/src/lib.rs Resolved
Comment thread relay-otel/src/lib.rs Resolved
Comment thread relay-otel/src/lib.rs Resolved
Comment thread relay-otel/src/lib.rs Resolved
Comment thread relay-ourlogs/src/otel_to_sentry.rs Outdated
use relay_otel::otel_value_to_attribute;
use relay_protocol::{Annotated, Error, Object};

fn otel_value_to_string(value: Option<opentelemetry_proto::tonic::common::v1::AnyValue>) -> String {

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.

Should this return Option<String>? So body can later be an empty Annotated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done with d025437

Comment thread relay-otel/src/lib.rs
Comment on lines +36 to +38
// Filter out nested arrays and key-value lists for safety.
// This is not usually allowed by the OTLP protocol, but we filter
// these values out before serializing for robustness.

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.

What's the reason we do not skip these values like we did before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We always had the filter_map filtering, are you referring to the added KvlistValue logic?

KvlistValue value attributes exist on logs, but not spans so this branch needed to be added.

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.

Yep sorry, I commented on the wrong section.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@AbhiPrasad
AbhiPrasad requested a review from jjbayer September 11, 2025 00:08
Comment thread relay-otel/src/lib.rs
Comment on lines +36 to +38
// Filter out nested arrays and key-value lists for safety.
// This is not usually allowed by the OTLP protocol, but we filter
// these values out before serializing for robustness.

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.

Yep sorry, I commented on the wrong section.

@AbhiPrasad
AbhiPrasad added this pull request to the merge queue Sep 11, 2025
Merged via the queue into master with commit add4bfc Sep 11, 2025
@AbhiPrasad
AbhiPrasad deleted the abhi-relay-otel-pkg branch September 11, 2025 11:39
github-merge-queue Bot pushed a commit that referenced this pull request Sep 15, 2025
resolves #5111

Building on top of #5128, this PR
adds an OTLP endpoint for logs. Much of this approach was inspired by
#4223.

To use this endpoint, you'll need to provide the following environmental
variables (where `DSN_PROJECT_ID` and `DSN_PUBLIC_KEY` are grabbed from
the DSN) when setting up your OTEL setup. An integration test was added
to `tests/integration/test_otlp_logs.py` to show this working.

```sh
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://{HOST}/api/{DSN_PROJECT_ID}/otlp/v1/logs" 
OTEL_EXPORTER_OTLP_HEADERS="x-sentry-auth=sentry sentry_key={DSN_PUBLIC_KEY}"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants