Connect an SDK
Metric works with official Sentry SDKs. You normally only need to replace the Sentry DSN with the DSN shown by Metric.
To keep installed applications' existing DSNs, follow Move from Sentry without changing client DSNs.
Get the DSN
- Sign in to Metric.
- Select a project.
- Open Connect an SDK.
- Copy an active DSN.
It looks like this:
text
https://PROJECT_KEY@metric.example.com/PROJECT_IDJavaScript in a browser
bash
npm install @sentry/browser@10.66.0javascript
import * as Sentry from "@sentry/browser";
Sentry.init({
dsn: "YOUR_METRIC_DSN",
tracesSampleRate: 0
});
Sentry.captureException(new Error("Metric test event"));Node.js
bash
npm install @sentry/node@10.66.0javascript
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "YOUR_METRIC_DSN",
tracesSampleRate: 0
});
Sentry.captureException(new Error("Metric test event"));Python
bash
pip install sentry-sdk==2.32.0python
import sentry_sdk
sentry_sdk.init(dsn="YOUR_METRIC_DSN", traces_sample_rate=0)
sentry_sdk.capture_message("Metric test event")Java
Use the official sentry-java package version 8.50.1. Its Gradle coordinate is io.sentry:sentry:
kotlin
implementation("io.sentry:sentry:8.50.1")java
import io.sentry.Sentry;
Sentry.init(options -> {
options.setDsn("YOUR_METRIC_DSN");
options.setTracesSampleRate(0.0);
});
Sentry.captureMessage("Metric test event");.NET
Install the tested Sentry package:
bash
dotnet add package Sentry --version 6.7.0csharp
using Sentry;
SentrySdk.Init(options =>
{
options.Dsn = "YOUR_METRIC_DSN";
options.TracesSampleRate = 0;
});
SentrySdk.CaptureMessage("Metric test event");Go
bash
go get github.com/getsentry/sentry-go@v0.48.0go
package main
import (
"time"
"github.com/getsentry/sentry-go"
)
func main() {
if err := sentry.Init(sentry.ClientOptions{
Dsn: "YOUR_METRIC_DSN",
}); err != nil {
panic(err)
}
sentry.CaptureMessage("Metric test event")
sentry.Flush(2 * time.Second)
}Rust
bash
cargo add sentry@0.48.5rust
fn main() {
let _guard = sentry::init("YOUR_METRIC_DSN");
sentry::capture_message("Metric test event", sentry::Level::Error);
}Check the result
Open Issues after sending the test event. Processing is asynchronous, so the first issue may take a short moment to appear.
See SDK compatibility for versions verified by the Metric test suite.