Repository navigation
feat(ourlogs): Add OTLP endpoint for logs - #5130
Conversation
jjbayer
left a comment
There was a problem hiding this comment.
Looks good AFAICT. A test case along the lines of
relay/tests/integration/test_nel.py
Line 8 in b044a69
b044a69 to
9242f66
Compare
| // NOTE: semantically wrong, but too expensive to parse. | ||
| ItemType::OtelLogsData => smallvec![ | ||
| (DataCategory::LogByte, self.len().max(1)), | ||
| (DataCategory::LogItem, item_count) |
There was a problem hiding this comment.
| // NOTE: semantically wrong, but too expensive to parse. | |
| ItemType::OtelLogsData => smallvec![ | |
| (DataCategory::LogByte, self.len().max(1)), | |
| (DataCategory::LogItem, item_count) | |
| ItemType::OtelLogsData => smallvec![ | |
| (DataCategory::LogByte, self.len().max(1)), | |
| (DataCategory::LogItem, item_count) // NOTE: semantically wrong, but too expensive to parse. | |
| mod minidump; | ||
| mod monitor; | ||
| mod nel; | ||
| mod otel_log; |
There was a problem hiding this comment.
Should we rename this otlp_logs and rename traces to otlp_traces to match the endpoint routes?
| mod event; | ||
| mod metrics; | ||
| mod nel; | ||
| mod otel_log; |
There was a problem hiding this comment.
I would name the helper module log and rename the function to convert_otel_logs to be consistent with:
relay/relay-server/src/services/processor.rs
Line 2214 in ed78b72
| // Convert OTLP logs data to individual log items | ||
| otel_log::convert_to_logs(&mut managed_envelope); |
There was a problem hiding this comment.
Question for @Dav1dde for when you're back: Is this something that should move into LogsProcessor::prepare_envelope eventually?
There was a problem hiding this comment.
Done in #5136.
Maybe we want to refine this in the future, prepare_envelope was meant to be very very very lightweight, no processing at all. So it has to happen in the expansion. But this is good because we will apply everything we can before the expensive expansion (e.g. if we could inbound filters). It also means we don't have to deserialize -> serialize -> deserialize.
| if let Ok(()) = ItemContainer::from(logs).write_to(&mut item) { | ||
| envelope.envelope_mut().add_item(item); | ||
| } |
There was a problem hiding this comment.
I see this was copied from nel, but I would do at least .inspect_err() here. See
relay/relay-server/src/processing/spans/mod.rs
Lines 311 to 313 in ed78b72
There was a problem hiding this comment.
Good suggestion! I elected to pattern match and track a DiscardReason outcome. 334df53
| ItemType::Span => true, | ||
| ItemType::OtelSpan => true, | ||
| ItemType::OtelTracesData => true, | ||
| ItemType::OtelLogsData => true, |
There was a problem hiding this comment.
I believe this should be false (also OtelTracesData in the line above). The otel types are already custom container types, so I don't believe they will ever be nested within an ItemContainer. cc @Dav1dde
There was a problem hiding this comment.
Yeah I had thought about this too, but I elected to follow the existing pattern with OtelTracesData in case there was some part of the processing pipeline that relied on this (or future work that was planned).
Changed with 8f451d7
There was a problem hiding this comment.
Yup correct, this should be false. The otel format is already a container 👍
…rocessor (#5136) The implementation in #5130 added the expansion right into the processor service, not the logs processor (e.g. how the old implementation did it #5082). This not only means we have to serialize and deserialize an additional time, it also goes against the design where we want to go towards. This was most likely caused by my 'NEL' hack, which I now also separated out again. We can implement a proper NEL processor once we pick up the NEL work again. The implementation also did not deal with outcomes correctly. This implementation fixes the issues and also introduces `RecordKeeper::modify_by` to track changes in outcome quantities exactly, instead of just `lenient`ly. We can also work towards moving all occurrences of `lenient` to `modify_by` in follow-up PRs.
This is a sanity check integration test to make sure that we are recording outcomes properly for otlp logs. The intial set of integration tests were added in #5130
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_IDandDSN_PUBLIC_KEYare grabbed from the DSN) when setting up your OTEL setup. An integration test was added totests/integration/test_otlp_logs.pyto show this working.