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

ref(js): Rewrite outdated "Transaction Name" documentation #12091

Open
wants to merge 2 commits into
base: lms/feat-updateSpanName
Choose a base branch
from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Dec 11, 2024

DESCRIBE YOUR PR

⚠️ to be merged after #11824 (which this PR is based on)

This PR rewrites the "Enriching Events"->"Transaction Name" page which is was fairly outdated and misleading for JavaScript.

Most importantly, it now mentions that scope.setTransactionName only applies to error events and has nothing to do with spans and root span names. The page now disambiguates the two concepts and lists ways how to update both names individually.

As an experiment, I added a "Further Information" section at the bottom of the page which tries to explain the historic context of why these two names are convoluted and appear ambiguous. I'm happy to remove this but this question and the confusion around the two names is coming up repeatedly on GitHub, in Discord as well as internally. While reviewing, feel free to let me know your thoughts if we should keep the section or reword it.

I decided to rewrite this page while triaging an older issue in the SDK repo where the two names were mixed up multiple times.

closes getsentry/sentry-javascript#13391

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 10:59am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Dec 11, 2024 10:59am
develop-docs ⬜️ Ignored (Inspect) Visit Preview Dec 11, 2024 10:59am

@Lms24 Lms24 changed the base branch from master to lms/feat-updateSpanName December 11, 2024 10:30
@Lms24 Lms24 requested a review from a team as a code owner December 11, 2024 10:30
@Lms24 Lms24 force-pushed the lms/feat-updateSpanName branch from 99ec67e to e5d3f66 Compare December 11, 2024 10:31
@Lms24 Lms24 requested review from mydea and s1gr1d December 11, 2024 10:36
Copy link

codecov bot commented Dec 11, 2024

Bundle Report

Changes will decrease total bundle size by 255.91kB (-1.26%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.34MB 255.91kB (-2.41%) ⬇️

Copy link
Contributor

@lizokm lizokm left a comment

Choose a reason for hiding this comment

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

Thanks for adding this! Left a few comments.

@@ -1,19 +1,37 @@
---
title: Transaction Name
description: "Learn how to set or override the transaction name to capture the user and gain critical pieces of information that construct a unique identity in Sentry."
description: "Learn how to set or override the transaction name to improve issue and trace grouping."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: "Learn how to set or override the transaction name to improve issue and trace grouping."
description: "Learn how to set or override transaction names to improve issue and trace-grouping."

Comment on lines +11 to +12
The Sentry SDK sets a "transaction name" which is used to annotate error events with their point of failure.
Furthermore, if you use <PlatformLink to="/tracing/">Tracing</PlatformLink>, Sentry refers to the root spans of your application as a "transaction" and groups traces based on the root span's "transaction" name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Sentry SDK sets a "transaction name" which is used to annotate error events with their point of failure.
Furthermore, if you use <PlatformLink to="/tracing/">Tracing</PlatformLink>, Sentry refers to the root spans of your application as a "transaction" and groups traces based on the root span's "transaction" name.
The Sentry SDK uses an _error transaction name_ to mark where something went wrong in an error event. If you use <PlatformLink to="/tracing/">Tracing</PlatformLink>, Sentry will also mark the root span in your application with a _root span transaction name_, which will group traces around that name.

Comment on lines +14 to +19
This means that there are in fact two transaction names:

1. The _error transaction name_ which is applied to error events
2. The _root span transaction name_ which is the name of the root span in your applications span tree.

Both are used to annotate and group error and trace events respectively and are usually set by the SDK or an integration automatically.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This means that there are in fact two transaction names:
1. The _error transaction name_ which is applied to error events
2. The _root span transaction name_ which is the name of the root span in your applications span tree.
Both are used to annotate and group error and trace events respectively and are usually set by the SDK or an integration automatically.
To automatically set transaction names, add `browserTracingIntegration` when initializing the SDK.

Comment on lines +20 to +26

<PlatformCategorySection supported={['browser']}>

You need to add `browserTracingIntegration` when initializing the SDK to automatically set a transaction name.

</PlatformCategorySection>

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<PlatformCategorySection supported={['browser']}>
You need to add `browserTracingIntegration` when initializing the SDK to automatically set a transaction name.
</PlatformCategorySection>

Comment on lines +27 to +34
Generally, **you don't need to set or override the transaction name manually.**
In most cases, the automatically determined name is a good grouping mechanism.
However, if this does not work for your use case, you can set both transaction names independently.

## What is a "Good" Transaction Name?

The transaction name can reference the current web app or server route, mobile screen or activity, or the current task being executed.
For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Generally, **you don't need to set or override the transaction name manually.**
In most cases, the automatically determined name is a good grouping mechanism.
However, if this does not work for your use case, you can set both transaction names independently.
## What is a "Good" Transaction Name?
The transaction name can reference the current web app or server route, mobile screen or activity, or the current task being executed.
For example:
Because automatically-determined names are a good grouping mechanism, unless you have a special use-case, **you won't need to set or override transaction names manually.**
## What's a "Good" Transaction Name?
Your transaction name can reference the current web app or server route, mobile screen or activity, or the current task being executed.
For example:

Comment on lines +131 to +133
You might be wondering why these two types of transaction names exist and why they are set independently.
The reason is mostly historic evolvement of the Sentry product and the SDKs.
The error transaction name existed long before Sentry provided tracing capabilities and where it was only applied to error events to better group issues.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You might be wondering why these two types of transaction names exist and why they are set independently.
The reason is mostly historic evolvement of the Sentry product and the SDKs.
The error transaction name existed long before Sentry provided tracing capabilities and where it was only applied to error events to better group issues.
You might wonder why there are two separate transaction names and why they're set independently. This is mainly due to Sentry's history and evolution. The error transaction name existed before Sentry offered tracing, and it was used solely to group error events. When tracing was introduced, the root span in a span tree was also called a "transaction," with its own name.

Comment on lines +135 to +137
In the first iteration of Sentry's tracing or performance monitoring product, we decided to call the root span of a span tree within an application a "Transaction", which also had a name.
In the second, now ongoing, tracing iteration, Sentry's new UI features no longer mention "Transactions" for root spans but rather just "spans" and "traces".
However, the two concepts (error transaction name and root span name) are still ambiguous and used so throughout various older parts of the Sentry UI.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the first iteration of Sentry's tracing or performance monitoring product, we decided to call the root span of a span tree within an application a "Transaction", which also had a name.
In the second, now ongoing, tracing iteration, Sentry's new UI features no longer mention "Transactions" for root spans but rather just "spans" and "traces".
However, the two concepts (error transaction name and root span name) are still ambiguous and used so throughout various older parts of the Sentry UI.
In later iterations, Sentry shifted focus in the UI from "transactions" to "spans" and "traces," but the older concepts remain in parts of the UI. The SDKs adapted their APIs, moving away from transaction-based designs. For example, the `setTransactionName` API on the `Scope` refers to error transaction names, not spans. Similarly, a span name doesn’t automatically apply to error events, keeping the two concepts [separate](https://github.com/getsentry/sentry-javascript/issues/10846).

Comment on lines +139 to +141
With this product evolvement in mind, the SDKs also had to adapt their APIs around tracing, specifically moving away from transaction-based APIs in version 8.
Consequently, the SDK exposes the `setTransactionName` API on the `Scope` which—although the name might suggest differently from historic context—has nothing to do with spans.
Likewise, the span name is not automatically applied to error events either, meaning both concepts are completely [decoupled](https://github.com/getsentry/sentry-javascript/issues/10846) from each other.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
With this product evolvement in mind, the SDKs also had to adapt their APIs around tracing, specifically moving away from transaction-based APIs in version 8.
Consequently, the SDK exposes the `setTransactionName` API on the `Scope` which—although the name might suggest differently from historic context—has nothing to do with spans.
Likewise, the span name is not automatically applied to error events either, meaning both concepts are completely [decoupled](https://github.com/getsentry/sentry-javascript/issues/10846) from each other.


Please refer to [the tracing documentation](../../tracing/) for how to start and stop transactions.
We believe that the ambiguity of these APIs will decrease over time as the Sentry product further moves away from associating the "Transaction" term with tracing and spans.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
We believe that the ambiguity of these APIs will decrease over time as the Sentry product further moves away from associating the "Transaction" term with tracing and spans.
As Sentry continues to evolve, the ambiguity between these terms is expected to decrease as the product moves away from associating "transactions" with tracing and spans.

I understand why you added it, but I'm not sure this section is necessary. I think it might add more confusion. But let me know if you disagree :)

@@ -1,4 +1,4 @@
One common use case is parameterizing transaction names. For both `pageload` and `navigation` transactions, the `BrowserTracing` integration uses the browser's `window.location` value to generate a transaction name. Using `beforeStartSpan` lets you modify the transaction name to make it more generic, so that, for example, transactions named `GET /users/12312012` and `GET /users/11212012` can both be renamed to `GET /users/:userid`. That way they'll be grouped together.
One common use case is parameterizing transaction names. For both `pageload` and `navigation` transactions, the `browserTracingIntegration` uses the browser's `window.location` value to generate a transaction name. Using `beforeStartSpan` lets you modify the transaction name to make it more generic, so that, for example, transactions named `GET /users/12312012` and `GET /users/11212012` can both be renamed to `GET /users/:userid`. That way they'll be grouped together.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
One common use case is parameterizing transaction names. For both `pageload` and `navigation` transactions, the `browserTracingIntegration` uses the browser's `window.location` value to generate a transaction name. Using `beforeStartSpan` lets you modify the transaction name to make it more generic, so that, for example, transactions named `GET /users/12312012` and `GET /users/11212012` can both be renamed to `GET /users/:userid`. That way they'll be grouped together.
One common use case is parameterizing transaction names. For both `pageload` and `navigation` transactions, the `browserTracingIntegration` uses the browser's `window.location` value to generate a transaction name. Using `beforeStartSpan` lets you modify the transaction name to make it more generic, so that for example, transactions named `GET /users/12312012` and `GET /users/11212012` can both be renamed to `GET /users/:userid`. That way they'll be grouped together.

Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

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

Very good write-up 🙌


## Setting the Error Transaction Name

There are several ways to set the transaction name for error events sent to Sentry.
Copy link
Member

Choose a reason for hiding this comment

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

In "Setting the Root Span Name", you mention where this name is displayed and used for. You could include this information here as well.


## Setting the Root Span Name

To override the name of the root span name (i.e. the trace name or transaction name in the Sentry UI), you have multiple options:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe specify where in the Sentry UI it is used.

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.

3 participants