Skip to content

ref(core): Switch to standardized log envelope #16133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 29, 2025

Conversation

AbhiPrasad
Copy link
Member

To test logs for the alpha we used a standardized otel_log envelope item.

Now that the logs protocol is more stable, we are switching to the sentry specific envelope item. This is fully documented here: https://develop.sentry.dev/sdk/telemetry/logs/

@AbhiPrasad AbhiPrasad requested a review from a team April 24, 2025 19:42
@AbhiPrasad AbhiPrasad self-assigned this Apr 24, 2025
@AbhiPrasad AbhiPrasad requested review from lforst and Lms24 and removed request for a team April 24, 2025 19:42

// Clear the log buffer after envelopes have been constructed.
logBuffer.length = 0;
CLIENT_TO_LOG_BUFFER_MAP.set(client, []);
Copy link
Member Author

Choose a reason for hiding this comment

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

This was an actual bug fix, because we mutated the reference, it has the possibility to cause weird side effects.

Copy link
Contributor

github-actions bot commented Apr 24, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.32 KB +0.16% +37 B 🔺
@sentry/browser - with treeshaking flags 23.13 KB +0.17% +38 B 🔺
@sentry/browser (incl. Tracing) 36.98 KB +0.16% +57 B 🔺
@sentry/browser (incl. Tracing, Replay) 74.15 KB +0.07% +50 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.49 KB +0.04% +24 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 78.8 KB +0.05% +39 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 90.6 KB +0.03% +20 B 🔺
@sentry/browser (incl. Feedback) 39.72 KB +0.12% +46 B 🔺
@sentry/browser (incl. sendFeedback) 27.94 KB +0.16% +43 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.71 KB +0.12% +38 B 🔺
@sentry/react 25.12 KB +0.13% +31 B 🔺
@sentry/react (incl. Tracing) 38.95 KB +0.06% +21 B 🔺
@sentry/vue 27.55 KB +0.16% +45 B 🔺
@sentry/vue (incl. Tracing) 38.73 KB +0.12% +45 B 🔺
@sentry/svelte 23.34 KB +0.14% +33 B 🔺
CDN Bundle 24.52 KB +0.1% +25 B 🔺
CDN Bundle (incl. Tracing) 36.99 KB +0.08% +28 B 🔺
CDN Bundle (incl. Tracing, Replay) 72.03 KB +0.05% +32 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 77.35 KB +0.07% +51 B 🔺
CDN Bundle - uncompressed 71.57 KB +0.11% +79 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 109.41 KB +0.08% +79 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 220.69 KB +0.04% +79 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.23 KB +0.04% +79 B 🔺
@sentry/nextjs (client) 40.55 KB +0.11% +43 B 🔺
@sentry/sveltekit (client) 37.45 KB +0.1% +35 B 🔺
@sentry/node 143.45 KB +0.04% +51 B 🔺
@sentry/node - without tracing 96.54 KB +0.05% +45 B 🔺
@sentry/aws-serverless 120.86 KB +0.04% +47 B 🔺

View base workflow run

Comment on lines +140 to +143
timestamp: timestampInSeconds(),
level,
body: message,
trace_id: traceContext?.trace_id,
severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],
Copy link
Member

Choose a reason for hiding this comment

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

q: are we doing any kind of validation on level and severityNumber if they match? is there some kind of precedence one has over the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

The passed in severityNumber takes priority, but there's no validation (so users can technically pass in whatever if they ignore the type check). Relay should handle normalizing all of this though, so we don't need to worry too much about what gets passed in.

* @param logs - The logs to include in the envelope.
* @param metadata - The metadata to include in the envelope.
* @param tunnel - The tunnel to include in the envelope.
* @param dsn - The DSN to include in the envelope.
* @returns The created envelope.
*/
export function createOtelLogEnvelope(
logs: Array<SerializedOtelLog>,
export function createLogEnvelope(
Copy link
Member

Choose a reason for hiding this comment

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

l: just to confirm - log envelop headers don't need to contain the trace header?

Copy link
Member Author

Choose a reason for hiding this comment

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

@AbhiPrasad AbhiPrasad force-pushed the abhi-use-new-log-format branch from 124f532 to 3d5d500 Compare April 29, 2025 14:25
@AbhiPrasad AbhiPrasad enabled auto-merge (squash) April 29, 2025 17:07
@AbhiPrasad AbhiPrasad merged commit a67ebc4 into develop Apr 29, 2025
154 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-use-new-log-format branch April 29, 2025 17:14
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.

2 participants