GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): Add `getTraceData` function by Lms24 · Pull Request #13134 · getsentry/sentry-javascript

Conversation

@Lms24

@Lms24 Lms24 commented Jul 31, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR adds a getTraceData function to the @sentry/core package and re-exports it in none-browser SDKs inheriting from it.

The logic was taken from the getTraceMetaTagValues function in the Astro SDK but I made some changes to its return type and, after feedback, generalized it to be used whenever we need to propagate trace data in our instrumentation.
Therefore, we simply return an object where the keys denote the trace data name (sentry-trace or baggage) and the values the respective content.

This function is added for two reasons

  1. We want to follow this function's logic to obtain the meta tag data in all our meta framework SDKs (Inject meta tags in Tracing-without-Performance-mode  #8520)
  2. It contributes to a request made a long time ago in Add getTracingMetaTags helper function to Node SDK #8843. In a follow-up PR, I'm gonna add a second function that renders stringified HTML tags directly for ease of use.

ref #8843
ref #8520

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Lms24 Lms24 self-assigned this Jul 31, 2024
@github-actions

github-actions Bot commented Jul 31, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
@sentry/browser 22.46 KB (0%)
@sentry/browser (incl. Tracing) 34.24 KB (0%)
@sentry/browser (incl. Tracing, Replay) 70.3 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.63 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.7 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 87.28 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 89.12 KB (0%)
@sentry/browser (incl. metrics) 26.77 KB (0%)
@sentry/browser (incl. Feedback) 39.38 KB (0%)
@sentry/browser (incl. sendFeedback) 27.08 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.72 KB (0%)
@sentry/react 25.23 KB (0%)
@sentry/react (incl. Tracing) 37.24 KB (0%)
@sentry/vue 26.61 KB (0%)
@sentry/vue (incl. Tracing) 36.07 KB (0%)
@sentry/svelte 22.59 KB (0%)
CDN Bundle 23.65 KB (0%)
CDN Bundle (incl. Tracing) 35.89 KB (0%)
CDN Bundle (incl. Tracing, Replay) 70.33 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.59 KB (0%)
CDN Bundle - uncompressed 69.41 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 106.35 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.2 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 231.03 KB (0%)
@sentry/nextjs (client) 37.09 KB (0%)
@sentry/sveltekit (client) 34.81 KB (0%)
@sentry/node 114.77 KB (0%)
@sentry/node - without tracing 89.33 KB (0%)
@sentry/aws-serverless 98.5 KB (0%)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mydea
mydea reviewed Jul 31, 2024
View reviewed changes
Comment thread packages/astro/src/server/middleware.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

mydea
mydea reviewed Jul 31, 2024
View reviewed changes
Comment thread packages/node/src/utils/meta.ts Outdated
* @returns an object with the two meta tags. The object keys are the name of the meta tag,
* the respective value is the content.
*/
export function getTracingMetaTags(

@mydea mydea Jul 31, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

m: Can we think of a different name here? IMHO this sounds to me as if that would return the actual tag elements, but it returns strings. What about e.g. getTraceData or something along these lines...?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Lms24 Lms24 Jul 31, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

That's a good point. I chose this return type because returning one (or two) string(s) with rendered HTML is too specific of a return type to cover all use cases (e.g. see #8843 (comment)).
I couldn't really come up with a better return type that's still versatile enough but simpler than the current one to use.

So I guess we give it a more general name then. Just a bit unhappy that it's not as simple as in laravel but at the same time I wanna avoid exposing two functions 😅

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mydea mydea Jul 31, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think the return type is good (more generic, and easier to port)! We can also use something like getTraceMetaTagValues, for example? 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Lms24 Lms24 Jul 31, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

yeah let's go with that, thx!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andreiborza andreiborza Jul 31, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

l: I'd probably just have gone with getTraceData and not try to return meta tag names with them. I feel like it's obvious what they should be, and it's not like you actually read them out when you used them.

Would just return { sentryTrace: string, baggage: string | undefined }.

But feel free to disregard.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Lms24
Lms24 requested review from a team, AbhiPrasad and mydea and removed request for a team July 31, 2024 13:23
@Lms24 Lms24 changed the title feat(node): Add getTracingMetaTags function feat(node): Add getTraceMetaTagValues function Jul 31, 2024
@Lms24 Lms24 changed the title feat(node): Add getTraceMetaTagValues function feat(node): Add getTraceMetaTagValues function Jul 31, 2024
@Lms24 Lms24 mentioned this pull request Jul 31, 2024
feat(javascript): Add documentation for injecting Html <meta> tags getsentry/sentry-docs#10926
Merged
andreiborza
andreiborza reviewed Jul 31, 2024
View reviewed changes
Comment thread packages/node/src/utils/meta.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/node/src/utils/meta.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/node/test/utils/meta.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

AbhiPrasad
AbhiPrasad suggested changes Jul 31, 2024
View reviewed changes

@AbhiPrasad AbhiPrasad left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I agree with @andreiborza, getTraceData feels like a better fit. There is nothing in the implementation or return value of getTracingMetaTags that indicates that it has to do with meta tags. Someone can use this helper to get values that they can serialize across an iframe for example.

Here's how I'd like us to approach this, but please feel free to adjust based what you find during your implementation.

  1. packages/node/src/utils/meta.ts should instead live in @sentry/core and be named getTraceData. This way non-node runtimes also get access to it.
  2. We expose another helper that is similar to the logic in packages/astro/src/server/middleware.ts, that generates meta tags as strings <meta XXX>. This should probably be called getTracingMetaTags (and also live in @sentry/core).

Now we have two workflows for users.

Use generated HTML? Use the meta tag helper and just insert that into your HTML document in the right place. Very easy API surface for users because usage is basically like:

const sentryMetaTags = getTracingMetaTags()

renderHtml(`
  <html>
   <head>
     ${sentryMetaTags}
   </head>
  </html>
`);

Want to get access to the these values to serialize in another way because of your super custom instrumentation setup? no problem just call getTraceData directly and do what you need to do.

Afterwards, we probably want to refactor all of our instrumentation to use getTraceData instead of manually calling generateSentryTraceHeader and dynamicSamplingContextToSentryBaggageHeader everywhere.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andreiborza reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Lms24

Lms24 commented Aug 1, 2024

Copy link
Copy Markdown
Member Author

Thanks for the review @AbhiPrasad! I like your suggestion. I was a bit hesitant about exposing two functions before but since we can't find a good, universal API for one function it's better to split.

I'll repurpose this PR to add the more universal getTraceData function. And I'll add the easy to use string function in a second PR afterwards.

AbhiPrasad and andreiborza reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Lms24 added 4 commits August 2, 2024 11:30
@Lms24
feat(node): Add getTracingMetaTags function
9296b88
@Lms24
actually add files in node lol
a400285
@Lms24
add missing exports, cleanup
91472d4
@Lms24
s/getTracingMetaTags/getTracingMetaTagValues
63283d0
@Lms24
Lms24 marked this pull request as draft August 2, 2024 09:50
@Lms24
rework: export getTraceData from core
63926bf
@Lms24 Lms24 changed the title feat(node): Add getTraceMetaTagValues function feat(core): Add getTraceData function Aug 2, 2024
@Lms24
adjust test
324b747
@Lms24
Lms24 force-pushed the lms/feat-node-add-getTracingMetaTags branch from 219b070 to 324b747 Compare August 2, 2024 10:20
@Lms24
Lms24 requested review from AbhiPrasad and andreiborza August 2, 2024 10:24
@Lms24
Lms24 marked this pull request as ready for review August 2, 2024 10:24
@Lms24

Lms24 commented Aug 2, 2024

Copy link
Copy Markdown
Member Author

I reworked the PR. Would appreciate another round of reviews 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andreiborza
andreiborza reviewed Aug 2, 2024
View reviewed changes
Comment thread packages/core/src/utils/traceData.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/src/utils/traceData.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/src/utils/traceData.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/src/utils/traceData.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/src/utils/traceData.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/test/lib/utils/traceData.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/test/lib/utils/traceData.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/test/lib/utils/traceData.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/test/lib/utils/traceData.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/core/test/lib/utils/traceData.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Lms24 @andreiborza
Apply suggestions from code review
3106bf6
Co-authored-by: Andrei <[email protected]>
andreiborza
andreiborza approved these changes Aug 2, 2024
View reviewed changes
This was referenced Aug 27, 2024
[Snyk] Upgrade @sentry/nextjs from 8.22.0 to 8.23.0 dupipcom/hypnos#52
Open
[Snyk] Upgrade @sentry/nextjs from 8.20.0 to 8.23.0 dupipcom/hygieia#1
Merged
@sleidig sleidig mentioned this pull request Aug 27, 2024
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.23.0 Aam-Digital/account-backend#39
Closed
@tomwwinter tomwwinter mentioned this pull request Aug 27, 2024
[Snyk] Upgrade @sentry/angular from 8.20.0 to 8.23.0 Aam-Digital/ndb-core#2537
Closed
@aam-digital-ci aam-digital-ci mentioned this pull request Aug 27, 2024
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.23.0 Aam-Digital/replication-backend#152
Closed
@chaitanyapotti chaitanyapotti mentioned this pull request Aug 27, 2024
[Snyk] Upgrade @sentry/types from 8.23.0 to 8.24.0 torusresearch/CustomAuth#351
Closed
@gokulk16 gokulk16 mentioned this pull request Aug 28, 2024
[Snyk] Upgrade @sentry/browser from 8.20.0 to 8.24.0 gokulk16/type-to-calculate-web#36
Closed
This was referenced Aug 28, 2024
[Snyk] Upgrade @sentry/nextjs from 8.20.0 to 8.24.0 dupipcom/hygieia#3
Open
[Snyk] Upgrade @sentry/nextjs from 8.22.0 to 8.24.0 dupipcom/hypnos#53
Open
@q1blue q1blue mentioned this pull request Aug 28, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.24.0 https-quantumblockchainai-atlassian-net/ossinsight#833
Open
This was referenced Aug 29, 2024
[Snyk] Upgrade @sentry/nextjs from 8.22.0 to 8.24.0 dupipcom/hypnos#54
Open
[Snyk] Upgrade @sentry/nextjs from 8.20.0 to 8.24.0 dupipcom/hygieia#4
Open
@sleidig sleidig mentioned this pull request Aug 29, 2024
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.24.0 Aam-Digital/account-backend#40
Closed
@gokulk16 gokulk16 mentioned this pull request Aug 30, 2024
[Snyk] Upgrade @sentry/browser from 8.20.0 to 8.25.0 gokulk16/type-to-calculate-web#38
Merged
This was referenced Aug 30, 2024
[Snyk] Upgrade @sentry/nextjs from 8.22.0 to 8.25.0 dupipcom/hypnos#55
Open
[Snyk] Upgrade @sentry/nextjs from 8.20.0 to 8.25.0 dupipcom/hygieia#5
Open
This was referenced Aug 30, 2024
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.25.0 Aam-Digital/replication-backend#154
Closed
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.25.0 Aam-Digital/account-backend#41
Closed
@q1blue q1blue mentioned this pull request Aug 30, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.25.0 https-quantumblockchainai-atlassian-net/ossinsight#835
Open
@angeloreale angeloreale mentioned this pull request Aug 31, 2024
[Snyk] Upgrade @sentry/nextjs from 8.22.0 to 8.25.0 dupipcom/hypnos#60
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Sep 1, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.25.0 FengShangWuQi/fengshangwuqi.github.io#1918
Closed
@PierreGode PierreGode mentioned this pull request Sep 4, 2024
[Snyk] Upgrade @sentry/node from 8.9.2 to 8.25.0 PierreGode/shields#1
Closed
This was referenced Sep 4, 2024
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.26.0 Aam-Digital/account-backend#42
Closed
[Snyk] Upgrade @sentry/node from 8.22.0 to 8.26.0 Aam-Digital/replication-backend#158
Closed
@q1blue q1blue mentioned this pull request Sep 7, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.26.0 https-quantumblockchainai-atlassian-net/ossinsight#846
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Sep 8, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.26.0 FengShangWuQi/fengshangwuqi.github.io#1919
Closed
@bagulm123 bagulm123 mentioned this pull request Sep 8, 2024
[Snyk] Upgrade: , , chart.js, classnames, cytoscape, typescript bagulm123/komiser#18
Open
@KeeghanM KeeghanM mentioned this pull request Sep 12, 2024
[Snyk] Upgrade: , , , , , , next, posthog-js, posthog-node, react-chessboard, stripe KeeghanM/chess-training-app#94
Merged
This was referenced Sep 13, 2024
[Snyk] Upgrade: , , chart.js, classnames, cytoscape, next, typescript bagulm123/komiser#19
Open
[Snyk] Upgrade: , , , chart.js, classnames, cytoscape, next, typescript bagulm123/komiser#20
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@andreiborza andreiborza andreiborza approved these changes
@mydea mydea Awaiting requested review from mydea
+1 more reviewer
@AbhiPrasad AbhiPrasad AbhiPrasad approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Lms24 Lms24

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Lms24 @mydea @AbhiPrasad @andreiborza
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.