Skip to content

Commit acf429c

Browse files
committed
Add Error Tracking + Sentry SDK documentation
1 parent f1c0ab3 commit acf429c

File tree

2 files changed

+262
-3
lines changed

2 files changed

+262
-3
lines changed

config/_default/menus/main.en.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -2235,21 +2235,26 @@ menu:
22352235
parent: error_tracking_backend
22362236
identifier: error_tracking_be_logs
22372237
weight: 104
2238+
- name: Sentry SDK
2239+
url: error_tracking/sentry_sdk
2240+
parent: error_tracking
2241+
identifier: error_tracking_sentry_sdk
2242+
weight: 11
22382243
- name: Manage Data Collection
22392244
url: error_tracking/manage_data_collection
22402245
parent: error_tracking
22412246
identifier: error_tracking_manage_data
2242-
weight: 11
2247+
weight: 12
22432248
- name: Troubleshooting
22442249
url: error_tracking/troubleshooting
22452250
parent: error_tracking
22462251
identifier: error_tracking_troubleshooting
2247-
weight: 12
2252+
weight: 13
22482253
- name: Guides
22492254
url: error_tracking/guides
22502255
parent: error_tracking
22512256
identifier: error_tracking_guides
2252-
weight: 13
2257+
weight: 14
22532258
- name: Change Tracking
22542259
url: change_tracking/
22552260
pre: graph-3
+254
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
---
2+
title: Sentry SDK
3+
description: Use the Sentry SDK to send errors to Error Tracking.
4+
further_reading:
5+
- link: "/error_tracking/manage_data_collection"
6+
tag: "Documentation"
7+
text: "Manage Data Collection"
8+
---
9+
{{< callout url="#" btn_hidden="true" >}}
10+
Using the Sentry SDK with Error Tracking is in Preview.
11+
{{< /callout >}}
12+
13+
<div class="alert alert-warning">
14+
Using the Sentry SDK with Error Tracking helps you migrate to Datadog. However, to get the most out of Error Tracking, it is recommended to use the regular setup. See <a href="/error_tracking/frontend">Frontend Error Tracking</a> and <a href="/error_tracking/backend">Backend Error Tracking</a>.
15+
</div>
16+
17+
## Overview
18+
You can use [Sentry SDKs][1] to send your events to Datadog. This offers you a way to start using Error Tracking on existing applications that are instrumented using Sentry SDKs.
19+
20+
Setting up the Sentry SDK with Datadog requires a minimal code change to point the SDK to a Datadog Data Source Name (DSN).
21+
22+
[Events][6] are sent to Datadog as logs. Non-error events (messages) also show up as logs. Other item types (traces, attachments, sessions, ...) are not supported.
23+
24+
## Setup
25+
### Prerequisites
26+
- Sentry SDK events are sent into Datadog as **logs**. You must have [Error Tracking for Logs][2] enabled for errors to show up in Error Tracking.
27+
28+
### Service configuration
29+
To configure the Sentry SDK to send events into Datadog:
30+
- Configure a Datadog Data Source Name (DSN). Follow the [in-app instructions][3] to generate your unique DSN.
31+
- Set a `service` tag on all events. This is used to separate errors and is shown in the Datadog UI.
32+
33+
{{< tabs >}}
34+
35+
{{% tab "JavaScript" %}}
36+
{{< code-block lang="javascript" >}}
37+
Sentry.init({
38+
dsn: 'https://<TOKEN>@sentry-intake.<DD_SITE>/1',
39+
initialScope: {
40+
tags: {
41+
service: 'my-app'
42+
}
43+
}
44+
});
45+
{{< /code-block >}}
46+
{{% /tab %}}
47+
48+
{{% tab "Python" %}}
49+
{{< code-block lang="python" >}}
50+
sentry_sdk.init(
51+
dsn="https://<TOKEN>@sentry-intake.<DD_SITE>/1",
52+
)
53+
sentry_sdk.set_tag("service", "my-app")
54+
{{< /code-block >}}
55+
{{% /tab %}}
56+
57+
{{% tab "Java" %}}
58+
{{< code-block lang="java" >}}
59+
Sentry.init(options -> {
60+
options.setDsn("https://<TOKEN>@sentry-intake.<DD_SITE>/1");
61+
});
62+
Sentry.configureScope(scope -> {
63+
scope.setTag("service", "my-app");
64+
});
65+
{{< /code-block >}}
66+
{{% /tab %}}
67+
68+
{{% tab "C#" %}}
69+
{{< code-block lang="csharp">}}
70+
SentrySdk.Init(options =>
71+
{
72+
options.Dsn = "https://<TOKEN>@sentry-intake.<DD_SITE>/1";
73+
options.SetBeforeSend((sentryEvent, hint) => {
74+
sentryEvent.SetTag("service", "my-app");
75+
return sentryEvent;
76+
});
77+
});
78+
{{< /code-block >}}
79+
{{% /tab %}}
80+
81+
{{% tab "Go" %}}
82+
{{< code-block lang="go">}}
83+
sentry.Init(sentry.ClientOptions{
84+
Dsn: "https://<TOKEN>@sentry-intake.<DD_SITE>/1",
85+
})
86+
sentry.ConfigureScope(func(scope *sentry.Scope) {
87+
scope.SetTag("service", "my-app");
88+
})
89+
{{< /code-block >}}
90+
{{% /tab %}}
91+
92+
{{% tab "Ruby" %}}
93+
{{< code-block lang="ruby">}}
94+
Sentry.init do |config|
95+
config.dsn = https://<TOKEN>@sentry-intake.<DD_SITE>/1'
96+
end
97+
Sentry.set_tags('service': 'my-app')
98+
{{< /code-block >}}
99+
{{% /tab %}}
100+
101+
{{< /tabs >}}
102+
103+
### Upload JavaScript source maps
104+
105+
If your frontend JavaScript source code is minified, you can upload source maps to Datadog to deobfuscate stack traces in Error Tracking.
106+
107+
See [Upload JavaScript Source Maps][4].
108+
109+
Set a `version` tag on your events to match them to the correct source maps:
110+
111+
{{< tabs >}}
112+
113+
{{% tab "JavaScript" %}}
114+
{{< code-block lang="javascript" >}}
115+
Sentry.setTag("version", "v35.2395005");
116+
{{< /code-block >}}
117+
{{% /tab %}}
118+
119+
{{% tab "Python" %}}
120+
{{< code-block lang="python" >}}
121+
sentry_sdk.set_tag("version", "v35.2395005")
122+
{{< /code-block >}}
123+
{{% /tab %}}
124+
125+
{{% tab "Java" %}}
126+
{{< code-block lang="java" >}}
127+
Sentry.configureScope(scope -> {
128+
scope.setTag("version", "v35.2395005");
129+
});
130+
{{< /code-block >}}
131+
{{% /tab %}}
132+
133+
{{% tab "C#" %}}
134+
{{< code-block lang="csharp" >}}
135+
SentrySdk.ConfigureScope(scope =>
136+
{
137+
scope.SetTag("version", "v35.2395005");
138+
});
139+
{{< /code-block >}}
140+
{{% /tab %}}
141+
142+
{{% tab "Go" %}}
143+
{{< code-block lang="go" >}}
144+
sentry.ConfigureScope(func(scope *sentry.Scope) {
145+
scope.SetTag("version", "v35.2395005");
146+
})
147+
{{< /code-block >}}
148+
{{% /tab %}}
149+
150+
{{% tab "Ruby" %}}
151+
{{< code-block lang="ruby" >}}
152+
Sentry.set_tags('version', 'v35.2395005')
153+
{{< /code-block >}}
154+
{{% /tab %}}
155+
156+
{{< /tabs >}}
157+
158+
### Source code integration
159+
160+
[Datadog Source Code Integration][5] allows you to connect your telemetry with your Git repositories.
161+
162+
Source Code Integration works with Sentry SDKs by configuring telemetry tags:
163+
164+
{{< tabs >}}
165+
166+
{{% tab "JavaScript" %}}
167+
{{< code-block lang="javascript" >}}
168+
Sentry.setTag("git.commit.sha", "<commitSha>");
169+
Sentry.setTag("git.repository_url", "<git-provider.example/me/my-repo>");
170+
{{< /code-block >}}
171+
{{% /tab %}}
172+
173+
{{% tab "Python" %}}
174+
{{< code-block lang="python" >}}
175+
sentry_sdk.set_tag("git.commit.sha", "<commitSha>")
176+
sentry_sdk.set_tag("git.repository_url", "<git-provider.example/me/my-repo>")
177+
{{< /code-block >}}
178+
{{% /tab %}}
179+
180+
{{% tab "Java" %}}
181+
{{< code-block lang="java" >}}
182+
Sentry.configureScope(scope -> {
183+
scope.setTag("git.commit.sha", "<commitSha>");
184+
scope.setTag("git.repository_url", "<git-provider.example/me/my-repo>");
185+
});
186+
{{< /code-block >}}
187+
{{% /tab %}}
188+
189+
{{% tab "C#" %}}
190+
{{< code-block lang="csharp" >}}
191+
SentrySdk.ConfigureScope(scope =>
192+
{
193+
scope.SetTag("git.commit.sha", "<commitSha>");
194+
scope.SetTag("git.repository_url", "<git-provider.example/me/my-repo>");
195+
});
196+
{{< /code-block >}}
197+
{{% /tab %}}
198+
199+
{{% tab "Go" %}}
200+
{{< code-block lang="go" >}}
201+
sentry.ConfigureScope(func(scope *sentry.Scope) {
202+
scope.SetTag("git.commit.sha", "<commitSha>");
203+
scope.SetTag("git.repository_url", "<git-provider.example/me/my-repo>");
204+
})
205+
{{< /code-block >}}
206+
{{% /tab %}}
207+
208+
{{% tab "Ruby" %}}
209+
{{< code-block lang="ruby" >}}
210+
Sentry.set_tags('git.commit.sha', '<commitSha>')
211+
Sentry.set_tags('git.repository_url', '<git-provider.example/me/my-repo>')
212+
{{< /code-block >}}
213+
{{% /tab %}}
214+
215+
{{< /tabs >}}
216+
217+
## Supported SDKs
218+
219+
The following Sentry SDKs are verified to work with Error Tracking:
220+
221+
<!-- TODO: test all latest versions -->
222+
223+
| Platform | Tested version |
224+
| ---------- | -------------- |
225+
| JavaScript | |
226+
| Python | |
227+
| Java | |
228+
| .NET | |
229+
| Go | |
230+
| Ruby | |
231+
232+
## Migrate to recommended setup
233+
234+
To get the most out of Error Tracking, it is recommended to eventually migrate to the Datadog SDK and/or Agent-based setups. See [Backend Error Tracking][7] and [Frontend Error Tracking][8] on how to configure this.
235+
236+
The setup using the Sentry SDK can be used simultaneously with the recommended setup, but errors will be reported twice.
237+
238+
## Send events to both Sentry and Datadog
239+
240+
<!-- TODO: code snippets -->
241+
<!-- TODO: move to other page? -->
242+
243+
## Further Reading
244+
245+
{{< partial name="whats-next/whats-next.html" >}}
246+
247+
[1]: https://docs.sentry.io/
248+
[2]: https://app.datadoghq.com/error-tracking/settings
249+
[3]: https://app.datadoghq.com/error-tracking/settings/setup/sentry
250+
[4]: /real_user_monitoring/guide/upload-javascript-source-maps
251+
[5]: /integrations/guide/source-code-integration/
252+
[6]: https://develop.sentry.dev/sdk/data-model/envelope-items/#event
253+
[7]: /error_tracking/backend
254+
[8]: /error_tracking/frontend

0 commit comments

Comments
 (0)