You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
16
+
Choose the features you want to configure, and this guide will show you how:
16
17
17
-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
Sentry captures data by using an SDK within your application's runtime.
24
+
### Install the SDK
25
+
26
+
Use the Bun package manager to add the Sentry SDK to your application:
22
27
23
28
```bash {tabTitle:Bun}
24
29
bun add @sentry/bun
25
30
```
26
31
27
-
## Configure
28
-
29
-
Configuration should happen as early as possible in your application's lifecycle.
32
+
## Step 2: Configure
30
33
31
-
Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application—otherwise, auto-instrumentation of these modules will _not_ work.
34
+
### Initialize the Sentry SDK
32
35
33
-
Once this is done, Sentry's Bun SDK captures unhandled exceptions as well as tracing data for your application.
34
-
35
-
You need to create a file named `instrument.js` that imports and initializes Sentry:
36
+
Sentry should be initialized as early in your app as possible.
37
+
To import and initialize Sentry, create a file named `instrument.js` in the root directory of your project and add the following code:
Once you set a `tracesSampleRate`, performance instrumentation is automatically enabled for you. See <PlatformLinkto="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
60
-
61
-
You can also manually capture performance data - see <PlatformLinkto="/tracing/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details.
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.
87
+
88
+
### Issues
84
89
85
-
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
90
+
First, let's verify that Sentry captures errors and creates issues in your Sentry project. Add the following code snippet to your main application file, which will call an undefined function, triggering an error that Sentry will capture:
86
91
87
92
```javascript
88
-
// ___PRODUCT_OPTION_START___ performance
89
-
Sentry.startSpan({
90
-
op:"test",
91
-
name:"My First Test Transaction",
92
-
// ___PRODUCT_OPTION_END___ performance
93
-
}, () => {
94
-
setTimeout(() => {
95
-
try {
96
-
foo();
97
-
} catch (e) {
98
-
Sentry.captureException(e);
99
-
}
100
-
}, 99);
101
-
// ___PRODUCT_OPTION_START___ performance
102
-
});
103
-
// ___PRODUCT_OPTION_END___ performance
93
+
setTimeout(() => {
94
+
try {
95
+
foo();
96
+
} catch (e) {
97
+
Sentry.captureException(e);
98
+
}
99
+
}, 99);
100
+
```
101
+
102
+
<OnboardingOptionoptionId="performance">
103
+
### Tracing
104
+
To test your tracing configuration, update the previous code snippet by starting a trace to measure the time it takes for the execution of your code:
105
+
106
+
```javascript
107
+
Sentry.startSpan(
108
+
{
109
+
op:"test",
110
+
name:"My First Test Transaction",
111
+
},
112
+
() => {
113
+
setTimeout(() => {
114
+
try {
115
+
foo();
116
+
} catch (e) {
117
+
Sentry.captureException(e);
118
+
}
119
+
}, 99);
120
+
}
121
+
);
104
122
```
105
123
106
-
<Alert>
124
+
</OnboardingOption>
125
+
126
+
### View Captured Data in Sentry
127
+
128
+
Finally, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear).
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
<Expandabletitle="Need help locating the captured errors in your Sentry project?">
2
+
3
+
1. Open the [**Issues**](https://sentry.io/issues) page and select an error from the issues list to view the full details and context of this error. For more details, see this [interactive walkthrough](/product/sentry-basics/integrate-frontend/generate-first-error/#ui-walkthrough).
4
+
2. Open the [**Traces**](https://sentry.io/explore/traces) page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click [here](/product/sentry-basics/distributed-tracing/generate-first-error/#ui-walkthrough).
5
+
3. Open the [**Logs**](https://sentry.io/explore/logs) page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click [here](/product/explore/logs/#overview).
0 commit comments