Skip to content

Commit bd50623

Browse files
committed
Add Error Tracking + Sentry SDK documentation
1 parent 2afd2ca commit bd50623

File tree

1 file changed

+209
-0
lines changed

1 file changed

+209
-0
lines changed
+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
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+
15+
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 [Frontend Error Tracking][1] and [Backend Error Tracking][2].
16+
17+
</div>
18+
19+
## Overview
20+
You can use [Sentry SDKs][3] to send your events to Datadog. This offers you a way to start using Error Tracking on existing applications that are monitored using Sentry SDKs.
21+
22+
Setting up the Sentry SDK with Datadog requires a minimal code change to point the SDK to a Datadog Data Source Name (DSN).
23+
24+
[Events][8] are sent to Datadog as logs. Non-error events (messages) also show up as logs. Other item types (traces, attachments, sessions, ...) are not supported.
25+
26+
## Setup
27+
### Prerequisites
28+
- Sentry SDK events are sent into Datadog as **logs**. You must have [Error Tracking for Logs][4] enabled for errors to show up in Error Tracking.
29+
30+
### Service configuration
31+
To configure the Sentry SDK to send events into Datadog:
32+
- Configure a Datadog Data Source Name (DSN). Follow the [in-app instructions][5] to generate your unique DSN.
33+
- Set a `service` tag on all events. This is used to separate errors and is shown in the Datadog UI.
34+
35+
{{< tabs >}}
36+
37+
{{% tab "JavaScript" %}}
38+
{{< code-block lang="javascript" >}}
39+
Sentry.init({
40+
dsn: 'https://[email protected]/1',
41+
initialScope: {
42+
tags: {
43+
service: 'my-app'
44+
}
45+
}
46+
});
47+
{{< /code-block >}}
48+
{{% /tab %}}
49+
50+
{{% tab "Python" %}}
51+
{{< code-block lang="python" >}}
52+
sentry_sdk.init(
53+
dsn="https://[email protected]/1",
54+
)
55+
sentry_sdk.set_tag("service", "my-app")
56+
{{< /code-block >}}
57+
{{% /tab %}}
58+
59+
{{% tab "Java" %}}
60+
{{< code-block lang="java" >}}
61+
Sentry.init(options -> {
62+
options.setDsn("https://[email protected]/1");
63+
});
64+
Sentry.configureScope(scope -> {
65+
scope.setTag("service", "my-app");
66+
});
67+
{{< /code-block >}}
68+
{{% /tab %}}
69+
70+
{{% tab "C#" %}}
71+
{{< code-block lang="csharp">}}
72+
SentrySdk.Init(options =>
73+
{
74+
options.Dsn = "https://[email protected]/1";
75+
options.SetBeforeSend((sentryEvent, hint) => {
76+
sentryEvent.SetTag("service", "my-app");
77+
return sentryEvent;
78+
});
79+
});
80+
{{< /code-block >}}
81+
{{% /tab %}}
82+
83+
{{% tab "Go" %}}
84+
{{< code-block lang="go">}}
85+
sentry.Init(sentry.ClientOptions{
86+
Dsn: "https://[email protected]/1",
87+
})
88+
sentry.ConfigureScope(func(scope *sentry.Scope) {
89+
scope.SetTag("service", "my-app");
90+
})
91+
{{< /code-block >}}
92+
{{% /tab %}}
93+
94+
{{% tab "Ruby" %}}
95+
{{< code-block lang="ruby">}}
96+
Sentry.init do |config|
97+
config.dsn = https://[email protected]/1'
98+
end
99+
Sentry.set_tags('service': 'my-app')
100+
{{< /code-block >}}
101+
{{% /tab %}}
102+
103+
{{< /tabs >}}
104+
105+
### Upload JavaScript source maps
106+
107+
If your frontend JavaScript source code is minified, you can upload source maps to Datadog to deobfuscate stack traces in Error Tracking.
108+
109+
See [Upload JavaScript Source Maps][6].
110+
111+
Set a `version` tag on your events to match them to the correct source maps:
112+
113+
{{< code-block lang="javascript" >}}
114+
Sentry.setTag("version", "v35.2395005");
115+
{{< /code-block >}}
116+
117+
### Source code integration
118+
119+
[Datadog Source Code Integration][7] allows you to connect your telemetry with your Git repositories.
120+
121+
Source Code Integration works with Sentry SDKs by configuring telemetry tags:
122+
123+
{{< tabs >}}
124+
125+
{{% tab "JavaScript" %}}
126+
{{< code-block lang="javascript" >}}
127+
Sentry.setTag("git.commit.sha", "<commitSha>");
128+
Sentry.setTag("git.repository_url", "<git-provider.example/me/my-repo>");
129+
{{< /code-block >}}
130+
{{% /tab %}}
131+
132+
{{ tab "Python" }}
133+
{{< code-block lang="python" >}}
134+
sentry_sdk.set_tag("git.commit.sha", "<commitSha>")
135+
sentry_sdk.set_tag("git.repository_url", "<git-provider.example/me/my-repo>")
136+
{{< /code-block >}}
137+
{{% /tab %}}
138+
139+
{{% tab "Java" %}}
140+
{{< code-block lang="java" >}}
141+
Sentry.configureScope(scope -> {
142+
scope.setTag("git.commit.sha", "<commitSha>");
143+
scope.setTag("git.repository_url", "<git-provider.example/me/my-repo>");
144+
});
145+
{{< /code-block >}}
146+
{{% /tab %}}
147+
148+
{{% tab "C#" %}}
149+
{{< code-block lang="csharp" >}}
150+
SentrySdk.ConfigureScope(scope =>
151+
{
152+
scope.SetTag("git.commit.sha", "<commitSha>");
153+
scope.SetTag("git.repository_url", "<git-provider.example/me/my-repo>");
154+
});
155+
{{< /code-block >}}
156+
{{% /tab %}}
157+
158+
{{% tab "Go" %}}
159+
{{< code-block lang="go" >}}
160+
sentry.ConfigureScope(func(scope *sentry.Scope) {
161+
scope.SetTag("git.commit.sha", "<commitSha>");
162+
scope.SetTag("git.repository_url", "<git-provider.example/me/my-repo>");
163+
})
164+
{{< /code-block >}}
165+
{{% /tab %}}
166+
167+
{{% tab "Ruby" %}}
168+
{{< code-block lang="ruby" >}}
169+
Sentry.set_tags('git.commit.sha', '<commitSha>')
170+
Sentry.set_tags('git.repository_url', '<git-provider.example/me/my-repo>')
171+
{{< /code-block >}}
172+
{{% /tab %}}
173+
174+
{{< /tabs >}}
175+
176+
## Supported SDKs
177+
178+
The following Sentry SDKs are verified to work with Error Tracking:
179+
180+
<!-- TODO: test all latest versions -->
181+
182+
| Platform | Tested version |
183+
| ---------- | -------------- |
184+
| JavaScript | |
185+
| Python | |
186+
| Java | |
187+
| .NET | |
188+
| Go | |
189+
| Ruby | |
190+
191+
## Migrate to Datadog SDKs or Agent
192+
193+
## Send events to both Sentry and Datadog
194+
195+
<!-- TODO: code snippets -->
196+
<!-- TODO: move to other page? -->
197+
198+
## Further Reading
199+
200+
{{< partial name="whats-next/whats-next.html" >}}
201+
202+
[1]: /error_tracking/frontend
203+
[2]: /error_tracking/backend
204+
[3]: https://docs.sentry.io/
205+
[4]: https://app.datadoghq.com/error-tracking/settings
206+
[5]: https://app.datadoghq.com/error-tracking/settings/setup/sentry
207+
[6]: /real_user_monitoring/guide/upload-javascript-source-maps
208+
[7]: /integrations/guide/source-code-integration/
209+
[8]: https://develop.sentry.dev/sdk/data-model/envelope-items/#event

0 commit comments

Comments
 (0)