-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Distrubited Tracing Tutorial #11518
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
Distrubited Tracing Tutorial #11518
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2f54648
First stab at creating an outline and some structure for tracing walk…
c9e15ae
Content updates to tracing walkthrough
4c0abf8
Start scaffolding first tracing error
965009d
Flesh out generating first error doc
89f6999
Add arcade and more progress on generating first error
3ac26c8
Clean up language and objectives on index page of tracing tutorial
ac96a19
Update links and make minor copy edits
e38baec
Update urls for github sample projects
4817500
Fix Sentry code for frontend
9036d8f
Update frontend terminal success message sample
3d19ebf
Fix some formatting errors
2402ed6
Make error log in initialize-sentry-sdk-backend more descriptive
511036a
Update docs/product/sentry-basics/distributed-tracing/create-new-proj…
coolguyzone 7305011
Update docs/product/sentry-basics/distributed-tracing/create-new-proj…
coolguyzone 02232bf
Update docs/product/sentry-basics/distributed-tracing/index.mdx
coolguyzone fbdde8f
Update docs/product/sentry-basics/distributed-tracing/index.mdx
coolguyzone fc13c60
Update docs/product/sentry-basics/distributed-tracing/index.mdx
coolguyzone 3366d7a
Update docs/product/sentry-basics/distributed-tracing/index.mdx
coolguyzone b68a75e
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 4f5a5f1
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 1793816
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 20611b6
Add minor copy edits
105f765
Add code highlighting where needed
ce32e81
Add frontend screenshot to initialize-sentry-frontend
7906063
Update arcade in tracing create-new-project
a116b12
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 107e2ff
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 953ed34
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 9256368
Update docs/product/sentry-basics/distributed-tracing/initialize-sent…
coolguyzone 47dc42e
Update docs/product/sentry-basics/distributed-tracing/generate-first-…
coolguyzone e3ba5db
Update docs/product/sentry-basics/distributed-tracing/generate-first-…
coolguyzone a9dda9f
Update docs/product/sentry-basics/distributed-tracing/generate-first-…
coolguyzone 51153c4
Update docs/product/sentry-basics/distributed-tracing/generate-first-…
coolguyzone 011830f
Update docs/product/sentry-basics/distributed-tracing/generate-first-…
coolguyzone 0a3c284
Suggested edits for tracing tutorial (#11660)
whitep4nth3r 46f9d0d
Update todos and various small copy changes, format w/ prettier
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
docs/product/sentry-basics/distributed-tracing/create-new-project.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| --- | ||
| title: Create Frontend and Backend Sentry Projects | ||
| sidebar_order: 2 | ||
| description: "Learn how to create your Sentry projects, which will scope events to distinct pieces of your application landscape." | ||
| --- | ||
|
|
||
| In order to capture errors and other events, you need to have a project set up in Sentry. In this walkthrough we'll be creating a frontend project in React and a separate backend project in Express. | ||
|
|
||
| Because you can create a Sentry Project for _each_ language or framework used in your application (for example, you might have separate projects for your API server and frontend client), a single application might have multiple projects associated with it. Once you've set up all the projects that correspond to different parts of your application in Sentry, you'll be able to scope events to a distinct application in your organization and assign responsibility to specific users and teams. For more information, see [best practices for creating projects](/organization/getting-started/#4-create-projects). | ||
|
|
||
| ## Create a Frontend Project | ||
|
|
||
| Follow the steps below to create a new Sentry project for a sample React application: | ||
|
|
||
| 1. Log in to your [Sentry organization](https://sentry.io). | ||
|
|
||
| 1. Select **Projects** from the left side navigation menu. | ||
|
|
||
| 1. Click "Create Project" and configure it as appropriate for your application: | ||
|
|
||
| - **Choose your platform**: Select the language or framework for your project based on the code you wish to monitor. In this case, choose **React**. | ||
|
|
||
| - **Set your alert frequency**: For the purpose of this tutorial, select **Alert me on high priority issues**. | ||
|
|
||
| > If you're wary of alert fatigue, learn more about how to set up your alerts in [Alerts Best Practices](/product/alerts/best-practices/). | ||
|
|
||
| - **Name your project and assign it a team**: Name your project in the **Project name** field and assign a team by selecting one in the **Team** dropdown (or click **+** to create a new team). | ||
|
|
||
| - Click **Create Project**. This takes you to the quick Configure React SDK guide, which provides an overview of how to configure the SDK. This tutorial covers the SDK setup in more detail. | ||
|
|
||
| - You'll notice that the Sentry React SDK setup code has come pre-populated with the project's unique DSN (Data Source Name). The DSN tells the SDK where to send events, so events are associated with the right project. You'll need to paste the DSN key into the SDK configuration code later in the tutorial. You can make a note of it now, or you can also find a project's DSN anytime in **[Project] > Settings > Client Keys (DSN)** | ||
|
|
||
| 1. Click **Take me to Issues** to go to your new project's **Issues** page. | ||
|
|
||
| ### UI Walkthrough | ||
|
|
||
| The interactive demo below walks through how to create a new project in the UI. | ||
|
|
||
| <div | ||
| style={{ | ||
| height: "0px", | ||
| paddingBottom: "calc(56.88524590163935% + 41px)", | ||
| position: "relative", | ||
| width: "100%", | ||
| }} | ||
| > | ||
| <iframe | ||
| src="https://demo.arcade.software/4z9l5xNZfpXFGAFc03az?embed" | ||
| frameborder="0" | ||
| loading="lazy" | ||
| webkitallowfullscreen | ||
| mozallowfullscreen | ||
| allowfullscreen | ||
| allow="fullscreen;" | ||
| style={{ | ||
| colorScheme: "light", | ||
| height: "100%", | ||
| left: "0px", | ||
| position: "absolute", | ||
| top: "0px", | ||
| width: "100%", | ||
| }} | ||
| title="FE Tutorial -> Create Project" | ||
| ></iframe> | ||
| </div> | ||
|
|
||
| ## Create a Backend Project | ||
|
|
||
| Next, follow the steps below to create a new Sentry project for a sample Backend application: | ||
|
|
||
| 1. Log in to your [Sentry organization](https://sentry.io). | ||
|
|
||
| 1. Select **Projects** from the left side navigation menu to display the list of all your projects. | ||
|
|
||
| 1. Click "Create Project" and configure it as appropriate for your application: | ||
|
|
||
| - **Choose your platform**: In this case, choose **Express**. | ||
|
|
||
| - **Set your alert frequency**: Once again, select **Alert me on high priority issues**. | ||
|
|
||
| - **Name your project and assign it a team**: Make sure to give it a different project name than your frontend application. | ||
|
|
||
| - Click **Create Project**. This takes you to the quick Configure Express SDK guide, which provides an overview of how to configure the SDK. | ||
|
|
||
| 1. Copy the DSN key and keep it handy. | ||
|
|
||
| > You can also find a project's DSN anytime in **[Project] > Settings > Client Keys (DSN)**. | ||
|
|
||
| 1. Click **Take me to Issues** to go to your new project's **Issues** page. | ||
|
|
||
| ### UI Walkthrough | ||
|
|
||
| <div | ||
| style={{ | ||
| height: "0px", | ||
| paddingBottom: "calc(56.88524590163935% + 41px)", | ||
| position: "relative", | ||
| width: "100%", | ||
| }} | ||
| > | ||
| <iframe | ||
| src="https://demo.arcade.software/YXX8LAOHGSP4mWWBMMtM?embed" | ||
| frameborder="0" | ||
| loading="lazy" | ||
| webkitallowfullscreen | ||
| mozallowfullscreen | ||
| allowfullscreen | ||
| allow="fullscreen;" | ||
| style={{ | ||
| colorScheme: "light", | ||
| height: "100%", | ||
| left: "0px", | ||
| position: "absolute", | ||
| top: "0px", | ||
| width: "100%", | ||
| }} | ||
| title="Tracing Tutorial -> Create Express Project" | ||
| ></iframe> | ||
| </div> | ||
|
|
||
| ## Next | ||
|
|
||
| Now that you have your Sentry projects set up, you can [Add the Sentry SDK to Your Frontend Project](/product/sentry-basics/distributed-tracing/initialize-sentry-sdk-frontend/). |
98 changes: 98 additions & 0 deletions
98
docs/product/sentry-basics/distributed-tracing/generate-first-error.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| --- | ||
| title: Capture Your First Distributed Tracing Error | ||
| sidebar_order: 5 | ||
| description: "Learn how to capture your first error and view it in Sentry." | ||
| --- | ||
|
|
||
| Now that the sample apps are up and running on your local environment and integrated with the Sentry SDKs, you're ready to generate the first error. Please ensure you have BOTH apps running (on http://localhost:3000 and http://localhost:3001). | ||
|
|
||
| You should see the 'One-Stop Shop' site running on http://localhost:3000. Clicking on any of the product buttons will trigger a call to the backend for product info. As long as your Express server is running, you should see titles, images, and descriptions for each product. | ||
|
|
||
| ## 1. Trigger an Error | ||
|
|
||
| To start using Sentry's error monitoring feature, you need some errors first. Let's add in an obvious error that will be easy to see in Sentry. | ||
|
|
||
| If you're using your own source code, skip this step. Instead, select your [platform](/platforms/) and follow its **Verify** step inside the **Getting Started** guide to introduce an error. | ||
|
|
||
| 1. In the `tracing-tutorial-frontend` repo, open `src/App.js` and update the `onClick` handler by replacing the string passed to the `getProduct()` function from `nonfat-water` to `debug-sentry`. | ||
|
|
||
| ```jsx diff {filename:App.js} | ||
| <div className="btn-parent"> | ||
| <button className="btn" onClick={() => getProduct("clown-shoes")}> | ||
| Clown Shoes | ||
| </button> | ||
| </div> | ||
| <div className="btn-parent"> | ||
| - <button className="btn" onClick={() => getProduct("nonfat-water")}> | ||
| + <button className="btn" onClick={() => getProduct("debug-sentry")}> | ||
| Nonfat Water | ||
| </button> | ||
| </div> | ||
| ``` | ||
|
|
||
| There's a middleware function handling the `/products/debug-sentry` route in the `server.js` file of the `tracing-tutorial-backend` repo that throws a sample error: | ||
|
|
||
| ```javascript {filename:server.js} | ||
| app.get("/products/debug-sentry", (req, res) => { | ||
| console.log("Sentry Error thrown!"); | ||
| throw new Error("My first Sentry error!"); | ||
| }); | ||
| ``` | ||
|
|
||
| 1. Save the file. | ||
|
|
||
| 1. Go back to the browser window and try clicking on the **Nonfat Water** button again, you will no longer see the expected product information. Instead, you'll see a `500 error` message displayed. | ||
|
|
||
| 1. Open the terminal window that's running the `tracing-tutorial-backend` server. Here, you'll see a log letting you know that an error has occurred: | ||
|
|
||
| ```bash | ||
| Sentry Error thrown! | ||
| ``` | ||
|
|
||
| This confirms that the error we just produced on the frontend has triggered a corresponding error on the backend. | ||
|
|
||
| ## 2. View the Error in Sentry | ||
|
|
||
| Now that you've triggered an error, let's see what it looks like in Sentry. | ||
|
|
||
| 1. Open the [**Traces**](https://sentry.io/orgredirect/organizations/:orgslug/traces/) page in Sentry.io. Make sure one (or both) of the projects you're using for this tutorial is selected in the projects dropdown. | ||
|
|
||
| 2. You should see a trace that shows both the React and Express icons, indicating that this trace traverses both projects. Click on the blue trace ID on the left to see the Trace View. | ||
|
|
||
| 3. On the [Trace View](/concepts/key-terms/tracing/trace-view/) page, you can see every span that happened within this trace. You can see the error on the React app that directly triggered the error on the Express app. | ||
|
|
||
| ### UI Walkthrough | ||
|
|
||
| The interactive demo below walks through how to view a distributed trace in Sentry. | ||
|
|
||
| <div | ||
| style={{ | ||
| height: "0px", | ||
| paddingBottom: "calc(52.1021021021021% + 41px)", | ||
| position: "relative", | ||
| width: "100%", | ||
| }} | ||
| > | ||
| <iframe | ||
| src="https://demo.arcade.software/xPc1a1WUYTnQqPvBQGnQ?embed" | ||
| frameborder="0" | ||
| loading="lazy" | ||
| webkitallowfullscreen | ||
| mozallowfullscreen | ||
| allowfullscreen | ||
| allow="fullscreen;" | ||
| style={{ | ||
| colorScheme: "light", | ||
| height: "100%", | ||
| left: "0px", | ||
| position: "absolute", | ||
| top: "0px", | ||
| width: "100%", | ||
| }} | ||
| title="FE Tutorial - View First Error" | ||
| ></iframe> | ||
| </div> | ||
|
|
||
| ## Next | ||
|
|
||
| Congrats, you're done! You've verified that Sentry is providing distributed tracing across your projects. You can now dig in to issues to find the original source of the issue that's causing a problem so you can diagnose and fix it in less time. | ||
Binary file added
BIN
+217 KB
docs/product/sentry-basics/distributed-tracing/img/frontend-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| title: Distributed Tracing Tutorial | ||
| sidebar_order: 1 | ||
| description: "Follow this tutorial to set up Sentry error monitoring and distributed tracing for a sample fullstack JavaScript application. By the end, you'll be able to trigger an error and a trace and see it in Sentry.io." | ||
| --- | ||
|
|
||
| This step-by-step tutorial walks you through setting up Sentry in both a frontend (React) and backend (Express) sample application. After completing this tutorial you'll be able to trace the source and impact of your issues across projects and platforms. As part of this tutorial, you will: | ||
|
|
||
| - Configure the Sentry SDK on a sample React and Node/Express app. | ||
| - Trigger a sample front-end error that in turn triggers a sample back-end error. | ||
| - Go to the [Traces](https://sentry.io/orgredirect/organizations/:orgslug/traces/) page in Sentry and see a detailed view of your entire trace. | ||
|
|
||
| This tutorial uses a [sample React application](https://github.com/getsentry/tracing-tutorial-frontend) on the frontend as well as a sample [Express API](https://github.com/getsentry/tracing-tutorial-backend) on the backend. Some familiarity with JavaScript will help you follow along. If you'd prefer, you can also apply the same steps to your own project, assuming you're running React on the frontend and Express on the backend. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - A [Sentry](https://sentry.io) account, or [sign up](https://sentry.io/signup/) for one | ||
| - A [GitHub](https://github.com/) account, or [sign up](https://github.com/join) for one | ||
| - [Node 18+](https://nodejs.org/en/download/) | ||
|
|
||
| ## Next | ||
|
|
||
| [Create your Sentry Projects](/product/sentry-basics/distributed-tracing/create-new-project/) |
Oops, something went wrong.
Oops, something went wrong.
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.
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.