Skip to content

Conversation

@phacops
Copy link
Contributor

@phacops phacops commented May 6, 2025

Instead of maintaining a separate schema, topic and consumer to ingest logs into the EAP, we're using the new items topic to ingest them.

To do:

  • target the right topic
  • change how the message is serialized

Needs getsentry/pypi#1427

Plan to deploy pause the deploys for DE/US, push to S4S, look at logs ingested after the deploy, revert/move to DE.

@phacops phacops requested a review from Dav1dde May 6, 2025 16:11
@phacops phacops marked this pull request as ready for review May 6, 2025 19:19
@phacops phacops requested a review from a team as a code owner May 6, 2025 19:19
Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

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

I'll have to look more into the specifics and explore options, but for now I do not think we should make protoc a dependency of Relay's build. I can't think of a good reason why this would be necessary. Ideally the proto crate, just contains the generated code instead of relying on a build.rs. opentelemetry-proto also does not force you to have protoc.

@phacops phacops requested a review from Dav1dde May 8, 2025 00:31
@phacops phacops requested a review from Dav1dde May 8, 2025 11:46
Comment on lines +1042 to +1044
LogAttributeValue::Int(value) => AnyValue {
value: Some(Value::IntValue(value)),
},
Copy link
Member

Choose a reason for hiding this comment

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

That was already a bug before I think, this will drop logs with an int value > i64::MAX.

I'll take care of that.

Copy link
Member

@k-fish k-fish left a comment

Choose a reason for hiding this comment

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

The item_id is correctly using uuidv7 is my only real concern. We are currently using timestamp_precise is ordering, but we can switch to the item id if it's a stable replacement.

Comment on lines +108 to +112
item_id=timestamp_nanos.to_bytes(
length=16,
byteorder="little",
signed=False,
),
Copy link
Member

Choose a reason for hiding this comment

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

Does this work? Should the uuidv7 have a random portion when NoContext is set? I think if it's set to 0 we may have collision problems

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work, I couldn't find a proper uuid7 library in Python to make the uuid based on a timestamp. That's why I replace it in the response lower.

Python 3.14 will have a function for this in the standard library.

Copy link
Member

Choose a reason for hiding this comment

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

I was also looking at the output (eg. 'itemId': 'quqO1GMfE61WcAAAAAAAAA=='), isn't the random portion not random here? It seems to be repeating. I am really only concerned that the uuidv7 implementation here wasn't working properly.

If the integration isn't passing maybe just confirm the timestamp portion of the actual log item_id matches the nanos in hex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is repeated because I'm using the item_id coming from Relay. We can't properly make a uuid7 from a custom timestamp in Python just yet so I am just ignoring this value.

The way the uuid7 is generated from the timestamp in Rust is correct though, and has this random portion.

@phacops phacops requested a review from k-fish May 8, 2025 15:32
Copy link
Member

@k-fish k-fish left a comment

Choose a reason for hiding this comment

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

Works for me if the uuidv7 is generating itemid properly. You're missing timestamp precise in the integration tests still, but that's a simple fix.

Comment on lines +108 to +112
item_id=timestamp_nanos.to_bytes(
length=16,
byteorder="little",
signed=False,
),
Copy link
Member

Choose a reason for hiding this comment

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

I was also looking at the output (eg. 'itemId': 'quqO1GMfE61WcAAAAAAAAA=='), isn't the random portion not random here? It seems to be repeating. I am really only concerned that the uuidv7 implementation here wasn't working properly.

If the integration isn't passing maybe just confirm the timestamp portion of the actual log item_id matches the nanos in hex?

Copy link
Member

@k-fish k-fish left a comment

Choose a reason for hiding this comment

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

Just running this on local, will post back any changes required after that

),
"string.attribute": AnyValue(string_value="some string"),
"valid_string_with_other": AnyValue(string_value="test"),
"sentry.timestamp_precise": AnyValue(int_value=timestamp_nanos),
Copy link
Member

Choose a reason for hiding this comment

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

Is this right or should this be a string_value? int_value is i64 which isn't correct for nanos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sentry.timestamp_precise is an integer in the current logs processor https://github.com/getsentry/snuba/blob/master/rust_snuba/src/processors/ourlogs.rs#L141-L144.

@phacops phacops merged commit 2f7c8b6 into master May 12, 2025
27 checks passed
@phacops phacops deleted the pierre/eap-logs-to-items-topic branch May 12, 2025 12:20
@tobias-wilfert
Copy link
Member

So the way we do timestamps here is now causing CI to fail: https://github.com/getsentry/relay/actions/runs/14974415036/job/42062971176?pr=4727

FAILED tests/integration/test_ourlogs.py::test_ourlog_extraction_with_sentry_logs - AssertionError: assert [{'attributes...PE_LOG', ...}] == [{'attributes...PE_LOG', ...}]
  At index 0 diff: {'organizationId': '1', 'projectId': '42', 'traceId': '5b8efff798038103d269b633813fc60c', 'itemId': 'qp23BQ9zaoeRcJ7l1sSWAQ==', 'itemType': 'TRACE_ITEM_TYPE_LOG', 'timestamp': '2025-05-12T14:12:19Z', 'attributes': {'sentry.severity_text': {'stringValue': 'error'}, 'sentry.observed_timestamp_nanos': {'stringValue': '1747059139998272000'}, 'sentry.timestamp_precise': {'intValue': '1747059139998272000'}, 'sentry.span_id': {'stringValue': 'eee19b7ec3c1b175'}, 'sentry.timestamp_nanos': {'stringValue': '1747059139998272000'}, 'sentry.trace_flags': {'intValue': '0'}, 'sentry.severity_number': {'intValue': '17'}, 'sentry.body': {'stringValue': 'This is really bad'}}, 'clientSampleRate': 1.0, 'serverSampleRate': 1.0, 'retentionDays': 90, 'received': '2025-05-12T14:12:20Z'} != {'organizationId': '1', 'projectId': '42', 'traceId': '5b8efff798038103d269b633813fc60c', 'itemId': 'qp23BQ9zaoeRcJ7l1sSWAQ==', 'itemType': 'TRACE_ITEM_TYPE_LOG', 'timestamp': '2025-05-12T14:12:19Z', 'attributes': {'sentry.severity_text': {'stringValue': 'error'}, 'sentry.severity_number': {'intValue': '17'}, 'sentry.timestamp_precise': {'intValue': '1747059139998272000'}, 'sentry.trace_flags': {'intValue': '0'}, 'sentry.span_id': {'stringValue': 'eee19b7ec3c1b175'}, 'sentry.observed_timestamp_nanos': {'stringValue': '1747059139998272000'}, 'sentry.timestamp_nanos': {'stringValue': '1747059139998272000'}, 'sentry.body': {'stringValue': 'This is really bad'}}, 'clientSampleRate': 1.0, 'serverSampleRate': 1.0, 'retentionDays': 90, 'received': '2025-05-12T14:12:19Z'}
  Full diff:
    [
     {'attributes': {'sentry.body': {'stringValue': 'This is really bad'},
                     'sentry.observed_timestamp_nanos': {'stringValue': '1747059139998272000'},
                     'sentry.severity_number': {'intValue': '17'},
                     'sentry.severity_text': {'stringValue': 'error'},
                     'sentry.span_id': {'stringValue': 'eee19b7ec3c1b175'},
                     'sentry.timestamp_nanos': {'stringValue': '1747059139998272000'},
                     'sentry.timestamp_precise': {'intValue': '1747059139998272000'},
                     'sentry.trace_flags': {'intValue': '0'}},
      'clientSampleRate': 1.0,
      'itemId': 'qp23BQ9zaoeRcJ7l1sSWAQ==',
      'itemType': 'TRACE_ITEM_TYPE_LOG',
      'organizationId': '1',
      'projectId': '42',
  -   'received': '2025-05-12T14:12:19Z',
  ?                                 ^^
  +   'received': '2025-05-12T14:12:20Z',
  ?                                 ^^

@tobias-wilfert
Copy link
Member

tobias-wilfert commented May 13, 2025

Looking into fixing this

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.

5 participants