The Sentry featured in this issue is a developer-first error tracking and performance monitoring platform.
Sentry is a developer-first error tracking and performance monitoring platform that helps developers understand what really matters, resolve issues faster, and keep abreast of their applications.
Sentry characteristic
- Source code, error filters, stack local variables – Sentry enhances application performance monitoring with stack tracing.
- Quickly identify performance issues before downtime. View the entire end-to-end distributed trace to see accurate, poorly performing API calls and show any associated errors.
- Breadcrumbs make application development a little easier by showing you the trail of events that led to the error.
- Whether you’re using JavaScript, PHP, or anything in between, Release lets you know which bugs have been fixed and which bugs were introduced for the first time.
- The software development cycle can be fraught with ambiguity. The problem owner gives control back to the developer to fix the problem in their code.
- Real-time application monitoring means real-time data. Use Sentry’s query builder Discover to query raw event data for the entire organization.
- The dashboard adds a visual element to our application monitoring.
Sentry use
The Sentry Java SDK can be used with Kotlin, Scala and other JVM languages. Code examples are typically provided in Java and Kotlin.
Sentry captures data by using the SDK during application runtime.
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>6.2.1</version>
</dependency>
If you use multiple Sentry dependencies, you can add a bill of materials to avoid specifying a version of each dependency.
This should be configured as early as possible in the life cycle of the application.
import io.sentry.Sentry;
Sentry.init(options -> {
options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");
});
This snippet contains a deliberate error, so you can test that everything works right after setting it up:
import io.sentry.Sentry;
try {
throw new Exception("This is a test.");
} catch (Exception e) {
Sentry.captureException(e);
}
On this page, we have you up and running with Sentry’s SDK so that it will automatically report errors and exceptions in your application.
Sentry captures data by using the SDK during application runtime.
# Using yarn
yarn add @sentry/node @sentry/tracing
# Using npm
npm install --save @sentry/node @sentry/tracing
When this is done, Sentry’s Node SDK catches all transactions and unhandled exceptions.
import * as Sentry from "@sentry/node";
import "@sentry/tracing";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
tracesSampleRate: 1.0,
});
This code snippet contains a deliberate error, so you can test that everything works right after setting it up
const transaction = Sentry.startTransaction({
op: "test",
name: "My First Test Transaction",
});
setTimeout(() => {
try {
foo();
} catch (e) {
Sentry.captureException(e);
} finally {
transaction.finish();
}
}, 99);
To install the Android SDK, add it to your build.gradle file:
// Make sure mavenCentral is there.
repositories {
mavenCentral()
}
// Enable Java 1.8 source compatibility if you haven't yet.
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
// Add Sentry's SDK as a dependency.
dependencies {
implementation 'io.sentry:sentry-android:6.2.1'
}
Configuration via AndroidManifest.xml:
<application>
<meta-data android:name="io.sentry.dsn" android:value="https://examplePublicKey@o0.ingest.sentry.io/0" />
</application>
This snippet contains a deliberate error, so you can test that everything works right after setting it up:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import java.lang.Exception;
import io.sentry.Sentry;
public class MyActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
throw new Exception("This is a test.");
} catch (Exception e) {
Sentry.captureException(e);
}
}
}
verify
Authentication token
The authentication token is passed using the auth header and is used to authenticate as a user or organization account through the API. In our documentation, we have several placeholders that appear between braces or V-shaped, such as {API_KEY}or <auth_token>, which you need to replace with one of your authentication tokens to effectively use the API call.
curl -H 'Authorization: Bearer {TOKEN}' https://sentry.io/api/0/projects/
If your authentication token is 1a2b3c, then the command should be:
curl -H 'Authorization: Bearer 1a2b3c' https://sentry.io/api/0/projects/
DSN authentication
Some API endpoints may allow DSN-based authentication. This is usually very limited, and the endpoint will describe whether it is supported or not. This is similar to bearer token authentication, but using your DSN (client key).
curl -H 'Authorization: DSN {DSN}' https://sentry.io/api/0/projects/
Paging result
Paging in the API is handled by the Link header standard:
curl -i https://sentry.io/api/0/projects/1/groups/
When supported, the cursor is always returned for the previous and next pages, even if there are no results on those pages. This allows you to query the API for results that have not yet been discovered. An example is when you implement polling behavior and you want to see if there is any new data. We return a results=”[true|false]” indicator to determine if you really need paging.
Paging example
Here is an example of paging using this API endpoint:
https://docs.sentry.io/api/events/list-an-issues-events/
The HTTP request in this example returns 100 events for the problem and includes the following link header in the response:
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="false"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>; rel="next"; results="true"; cursor="0:100:0"
A URL in the linked response has rel=next, which indicates the next result page. It also has results=true, which means there are more results.
Based on this, the next request is a GET < https://sentry.io/api/0/issues/123456/events/? &cursor=0:100:0>.
This request will again return the next 100 events for the issue with the following link header:
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="true"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:200:0>; rel="next"; results="true"; cursor="0:200:0"
Repeat the process until the URL has a flag indicating the last page rel=next. results=false
The three values of cursor are the cursor identifier (an integer, usually 0), the row offset, and is_prev (1 or 0).
图示
—END—
Open source protocol: View license