Skip to content
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

feat(tracing): Add transaction source field #5367

Merged
merged 1 commit into from Jul 6, 2022

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jul 5, 2022

Ref: #5345

This patch adds source information to Transaction, which is typed by TransactionSource in @sentry/tracing. This helps track how the name of a transaction was determined, which will be used by the server for
server-side controls.

For now, we are placing the source field under transaction metadata. In the future, we can move this up into a top level API (an argument to startTransaction or transaction.setSource) if needed, but this should be fine to get us started.

For next steps, after this patch gets merged, we will start going through various routing instrumentation frameworks and adding transaction source.

This patch adds `source` information to `Transaction`, which is typed by
`TransactionSource` in `@sentry/tracing`. This helps track how the name
of a transaction was determined, which will be used by the server for
server-side controls.

For now, we are placing the `source` field under transaction metadata.
In the future, we can move this up into a top level API (an argument to
`startTransaction` or `transaction.setSource`) if needed, but this
should be fine to get us started.

For next steps, after this patch gets merged, we will start going
through various routing instrumentation frameworks and adding
transaction source.
@AbhiPrasad AbhiPrasad self-assigned this Jul 5, 2022
@AbhiPrasad AbhiPrasad mentioned this pull request Jul 5, 2022
15 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.34 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 59.86 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.94 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 52.78 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.71 KB (0%)
@sentry/browser - Webpack (minified) 64.16 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.73 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 43.93 KB (+0.07% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.71 KB (+0.08% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.97 KB (+0.1% 🔺)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM overall. Had some questions.
One more question: We're using setMetadata for the time being to not expose Transaction.setSource as public API, correct?

packages/tracing/src/transaction.ts Show resolved Hide resolved
packages/types/src/event.ts Show resolved Hide resolved
packages/types/src/transaction.ts Show resolved Hide resolved
@AbhiPrasad
Copy link
Member Author

One more question: We're using setMetadata for the time being to not expose Transaction.setSource as public API, correct?

Yes exactly! We can come back and change this later if needed.

@AbhiPrasad AbhiPrasad merged commit 782f2f5 into master Jul 6, 2022
@AbhiPrasad AbhiPrasad deleted the abhi-transaction-source branch July 6, 2022 16:01
@Lms24
Copy link
Member

Lms24 commented Jul 6, 2022

Thanks for clarifying, makes sense to me!

@lobsterkatie
Copy link
Member

lobsterkatie commented Jul 7, 2022

In the future, we can move this up into a top level API (an argument to startTransaction or transaction.setSource) if needed

FWIW, we don't need to do this, I don't think, because we can just do startTransaction({ name: 'someName', metadata: { source: 'someSource' }}). No need for a new method.

Lms24 added a commit that referenced this pull request Jul 8, 2022
… an unparameterized URL (#5392)

This patch re-introduces the `transaction` field in the Dynamic Sampling Context (DSC). However, its presence is now determined by the [transaction source](https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations) which was introduced in #5367.

As of this we we add the `transaction` field back, if the source indicates that the transaction name is not an unparameterized URL (meaning, the source is set and it is not `url`). 

Additionally, the PR (once again) adjusts our unit and integration tests to reflect this change. Repurposed some DSC<=>`sendDefaultPii` tests that we previously skipped to now cover the transaction<=>transaction source dependence. Did some cleanup of commented out old code and explanations that no longer apply.

Remove he `'unknown'` field from the `TransactionSource` type because it is only used by Relay and SDKs shouldn't set it.
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.

None yet

3 participants