Connect an SDK
Metric works with official Sentry SDKs. You normally only need to replace the Sentry DSN with the DSN shown by Metric.
The automated Error Event gates also verify PHP sentry/sentry 4.34.0 on PHP 8.3 and Ruby sentry-ruby 7.1.0 on Ruby 3.1. Their exact fixture versions and tested features are listed in SDK compatibility. Framework samples below may use a separately verified SDK version.
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:
https://PROJECT_KEY@metric.example.com/PROJECT_IDJavaScript in a browser
npm install @sentry/browser@10.66.0import * as Sentry from "@sentry/browser";
Sentry.init({
dsn: "YOUR_METRIC_DSN",
tracesSampleRate: 0
});
Sentry.captureException(new Error("Metric test event"));Node.js
npm install @sentry/node@10.66.0import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "YOUR_METRIC_DSN",
tracesSampleRate: 0
});
Sentry.captureException(new Error("Metric test event"));Python
pip install sentry-sdk==2.32.0import 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:
implementation("io.sentry:sentry:8.50.1")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:
dotnet add package Sentry --version 6.7.0using Sentry;
SentrySdk.Init(options =>
{
options.Dsn = "YOUR_METRIC_DSN";
options.TracesSampleRate = 0;
});
SentrySdk.CaptureMessage("Metric test event");Go
go get github.com/getsentry/sentry-go@v0.48.0package 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
cargo add sentry@0.48.5fn 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.