getsentry/sentry-go-sdk

Configuration complète du SDK Sentry pour Go. À utiliser lorsque l'utilisateur demande "ajouter Sentry à Go", "installer sentry-go", "configurer Sentry dans Go", ou configurer la surveillance des erreurs, le tracing, la journalisation, les métriques ou les crons pour des applications Go. Prend en charge net/http, Gin, Echo, Fiber, FastHTTP, Iris, Negroni et gRPC.

Qu'est-ce que sentry-go-sdk ?

Cette compétence configure l'intégration complète du SDK Sentry (sentry-go) dans des applications Go. Elle automatise l'installation du package, l'initialisation du client Sentry avec le DSN et les options de configuration, ainsi que l'intégration avec les frameworks et bibliothèques Go populaires. Elle est utile pour les développeurs qui souhaitent rapidement ajouter une surveillance des erreurs (error monitoring), du tracing distribué (tracing), de la journalisation structurée (logging), des métriques personnalisées (metrics) et des tâches cron (crons) à leurs applications Go. La compétence prend en charge les frameworks net/http natif, Gin, Echo, Fiber, FastHTTP, Iris, Negroni, et gRPC, et offre des instructions claires pour chaque cas d'utilisation. Elle inclut également des exemples de code pour configurer les middlewares, l'initialisation du SDK, et les rapports d'erreurs, facilitant ainsi une adoption rapide sans erreurs de configuration.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/getsentry/sentry-for-ai/tree/main/skills/sentry-go-sdk

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Que fait sentry-go-sdk ?

Configuration complète du SDK Sentry pour Go. À utiliser lorsque l'utilisateur demande "ajouter Sentry à Go", "installer sentry-go", "configurer Sentry dans Go", ou configurer la surveillance des erreurs, le tracing, la journalisation, les métriques ou les crons pour des applications Go. Prend en charge net/http, Gin, Echo, Fiber, FastHTTP, Iris, Negroni et gRPC.

Installation

go get github.com/getsentry/sentry-go

Configuration de base

Initialisez le client Sentry au démarrage de votre application (dans main.go) :

package main

import (
	"log"
	"github.com/getsentry/sentry-go"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
		// Définir le taux d'échantillonnage de tracing, entre 0.0 et 1.0
		TracesSampleRate: 1.0,
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}
	// Utilisez defer pour vider les événements avant l'arrêt de l'application
	defer sentry.Flush(2 * time.Second)
}

Surveillance des erreurs

Signalez manuellement les erreurs :

import "github.com/getsentry/sentry-go"

func maFonction() {
	err := operationRisquee()
	if err != nil {
		sentry.CaptureException(err)
	}
}

Intégration avec net/http

Utilisez le middleware sentryhttp :

import (
	"net/http"
	"github.com/getsentry/sentry-go"
	sentryhttp "github.com/getsentry/sentry-go/http"
)

func main() {
	sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})

	handler := sentryhttp.New(sentryhttp.Options{})
	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		// Votre logique
	})
	// Utilisez le middleware
	http.Handle("/", handler.Handle(mux))
	http.ListenAndServe(":8080", nil)
}

Intégration avec Gin

import (
	"github.com/getsentry/sentry-go"
	sentrygin "github.com/getsentry/sentry-go/gin"
	"github.com/gin-gonic/gin"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	app := gin.Default()
	app.Use(sentrygin.New(sentrygin.Options{}))
	app.GET("/", func(c *gin.Context) {
		// Votre logique
	})
	app.Run()
}

Intégration avec Echo

import (
	"github.com/getsentry/sentry-go"
	sentryecho "github.com/getsentry/sentry-go/echo"
	"github.com/labstack/echo/v4"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	e := echo.New()
	e.Use(sentryecho.New(sentryecho.Options{}))
	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "Bonjour, Monde!")
	})
	e.Logger.Fatal(e.Start(":1323"))
}

Intégration avec Fiber

import (
	"github.com/gofiber/fiber/v2"
	"github.com/getsentry/sentry-go"
	sentryfiber "github.com/getsentry/sentry-go/fiber"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	app := fiber.New()
	app.Use(sentryfiber.New(sentryfiber.Options{}))
	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Bonjour, Monde!")
	})
	app.Listen(":3000")
}

Intégration avec FastHTTP

import (
	"github.com/getsentry/sentry-go"
	sentryfasthttp "github.com/getsentry/sentry-go/fasthttp"
	"github.com/valyala/fasthttp"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	handler := sentryfasthttp.New(sentryfasthttp.Options{})
	fastHandler := func(ctx *fasthttp.RequestCtx) {
		// Votre logique
	}
	fasthttp.ListenAndServe(":8080", handler.Handler(fastHandler))
}

Intégration avec Iris

import (
	"github.com/kataras/iris/v12"
	"github.com/getsentry/sentry-go"
	sentryiris "github.com/getsentry/sentry-go/iris"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	app := iris.New()
	app.Use(sentryiris.New(sentryiris.Options{}))
	app.Get("/", func(ctx iris.Context) {
		ctx.WriteString("Bonjour, Iris!")
	})
	app.Listen(":8080")
}

Intégration avec Negroni

import (
	"github.com/getsentry/sentry-go"
	sentrynegroni "github.com/getsentry/sentry-go/negroni"
	"github.com/urfave/negroni"
	"net/http"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	n := negroni.Classic()
	n.Use(negroni.HandlerFunc(sentrynegroni.Handler))
	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Bonjour, Monde!"))
	})
	n.UseHandler(mux)
	n.Run(":8080")
}

Intégration avec gRPC

import (
	"github.com/getsentry/sentry-go"
	sentrygrpc "github.com/getsentry/sentry-go/grpc"
	"google.golang.org/grpc"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	server := grpc.NewServer(
		grpc.UnaryInterceptor(sentrygrpc.UnaryServerInterceptor()),
		grpc.StreamInterceptor(sentrygrpc.StreamServerInterceptor()),
	)
	// Enregistrez vos services gRPC ici
}

Tracing

Activez le tracing en définissant TracesSampleRate dans l'initialisation :

sentry.Init(sentry.ClientOptions{
	Dsn: "https://[email protected]/0",
	TracesSampleRate: 0.25, // 25% des transactions sont tracées
})

Journalisation

Utilisez les niveaux de journalisation pour les événements :

sentry.WithScope(func(scope *sentry.Scope) {
	scope.SetLevel(sentry.LevelWarning)
	sentry.CaptureException(err)
})

Métriques

Envoyez des métriques personnalisées :

sentry.CaptureMessage("métrique personnalisée", func(hint *sentry.EventHint) {
	hint.Event.Tags = map[string]string{"type": "exemple"}
})

Crons

Surveillez les tâches cron avec Sentry Cron Monitoring :

func main() {
	// Initialisez Sentry
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://[email protected]/0",
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}

	// Créez un monitor de cron
	monitor := sentry.NewCheckIn(
		&sentry.CheckIn{
			ID:         "mon-cron",
			Status:     sentry.CheckInStatusInProgress,
			MonitorSlug: "mon-slug-cron",
		},
	)
	defer monitor.Finish()

	// Votre logique cron ici
}

Variables d'environnement

  • SENTRY_DSN : Définit le DSN pour l'initialisation automatique.
  • SENTRY_ENVIRONMENT : Définit l'environnement (par exemple, production, staging).
  • SENTRY_RELEASE : Définit la version de la release.
  • SENTRY_TRACES_SAMPLE_RATE : Définit le taux d'échantillonnage de tracing.

Documentation supplémentaire

Consultez la documentation officielle de Sentry pour Go pour plus d'informations sur les fonctionnalités avancées, y compris les profils de performance et les alertes personnalisées.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

getsentry/sentry-android-sdk

Full Sentry SDK setup for Android. Use when asked to "add Sentry to Android", "install sentry-android", "setup Sentry in Android", or configure error monitoring, tracing, profiling, session replay, or logging for Android applications. Supports Kotlin and Java codebases.

getsentry/sentry-browser-sdk

Full Sentry SDK setup for browser JavaScript. Use when asked to "add Sentry to a website", "install @sentry/browser", or configure error monitoring, tracing, session replay, or logging for vanilla JavaScript, jQuery, static sites, or WordPress.

getsentry/sentry-cloudflare-sdk

Full Sentry SDK setup for Cloudflare Workers and Pages. Use when asked to "add Sentry to Cloudflare Workers", "install @sentry/cloudflare", or configure error monitoring, tracing, logging, crons, or AI monitoring for Cloudflare Workers, Pages, Durable Objects, Queues, Workflows, or Hono on Cloudflare.

getsentry/sentry-cocoa-sdk

Full Sentry SDK setup for Apple platforms (iOS, macOS, tvOS, watchOS, visionOS). Use when asked to "add Sentry to iOS", "add Sentry to Swift", "install sentry-cocoa", or configure error monitoring, tracing, profiling, session replay, logging, or metrics for Apple applications. Supports SwiftUI and UIKit.

getsentry/sentry-code-review

Analyze and resolve Sentry comments on GitHub Pull Requests. Use this when asked to review or fix issues identified by Sentry in PR comments. Can review specific PRs by number or automatically find recent PRs with Sentry feedback.

getsentry/sentry-create-alert

Create Sentry alerts using the workflow engine API. Use when asked to create alerts, set up notifications, configure issue priority alerts, or build workflow automations. Supports email, Slack, PagerDuty, Discord, and other notification actions.

getsentry/sentry-dotnet-sdk

Full Sentry SDK setup for .NET. Use when asked to "add Sentry to .NET", "install Sentry for C#", or configure error monitoring, tracing, profiling, logging, or crons for ASP.NET Core, MAUI, WPF, WinForms, Blazor, Azure Functions, or any other .NET application.

getsentry/sentry-elixir-sdk

Full Sentry SDK setup for Elixir. Use when asked to "add Sentry to Elixir", "install sentry for Elixir", or configure error monitoring, tracing, logging, or crons for Elixir, Phoenix, or Plug applications. Supports Phoenix, Plug, LiveView, Oban, and Quantum.

getsentry/sentry-feature-setup

Configure specific Sentry features beyond basic SDK setup. Use when asked to monitor AI/LLM calls, set up OpenTelemetry pipelines, create alerts and notifications, or enable span streaming.

getsentry/sentry-fix-issues

Find and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sentry. Methodically analyzes stack traces, breadcrumbs, traces, and context to identify root causes.

getsentry/sentry-flutter-sdk

Full Sentry SDK setup for Flutter and Dart. Use when asked to "add Sentry to Flutter", "install sentry_flutter", "setup Sentry in Dart", or configure error monitoring, tracing, profiling, session replay, or logging for Flutter applications. Supports Android, iOS, macOS, Linux, Windows, and Web.

getsentry/sentry-nestjs-sdk

Full Sentry SDK setup for NestJS. Use when asked to "add Sentry to NestJS", "install @sentry/nestjs", "setup Sentry in NestJS", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for NestJS applications. Supports Express and Fastify adapters, GraphQL, microservices, WebSockets, and background jobs.

getsentry/sentry-nextjs-sdk

Full Sentry SDK setup for Next.js. Use when asked to "add Sentry to Next.js", "install @sentry/nextjs", or configure error monitoring, tracing, session replay, logging, profiling, AI monitoring, or crons for Next.js applications. Supports Next.js 13+ with App Router and Pages Router.

getsentry/sentry-node-sdk

Full Sentry SDK setup for Node.js, Bun, and Deno. Use when asked to "add Sentry to Node.js", "add Sentry to Bun", "add Sentry to Deno", "install @sentry/node", "@sentry/bun", or "@sentry/deno", or configure error monitoring, tracing, logging, profiling, metrics, crons, or AI monitoring for server-side JavaScript/TypeScript runtimes.

getsentry/sentry-otel-exporter-setup

Configure the OpenTelemetry Collector with Sentry Exporter for multi-project routing and automatic project creation. Use when setting up OTel with Sentry, configuring collector pipelines for traces and logs, or routing telemetry from multiple services to Sentry projects.

getsentry/sentry-php-sdk

Full Sentry SDK setup for PHP. Use when asked to "add Sentry to PHP", "install sentry/sentry", "setup Sentry in PHP", or configure error monitoring, tracing, profiling, logging, metrics, or crons for PHP applications. Supports plain PHP, Laravel, and Symfony.

getsentry/sentry-pr-code-review

Review a project's PRs to check for issues detected in code review by Seer Bug Prediction. Use when asked to review or fix issues identified by Sentry in PR comments, or to find recent PRs with Sentry feedback.

getsentry/sentry-python-sdk

Full Sentry SDK setup for Python. Use when asked to "add Sentry to Python", "install sentry-sdk", "setup Sentry in Python", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for Python applications. Supports Django, Flask, FastAPI, Celery, Starlette, AIOHTTP, Tornado, and more.

getsentry/sentry-react-native-sdk

Full Sentry SDK setup for React Native and Expo. Use when asked to "add Sentry to React Native", "install @sentry/react-native", "setup Sentry in Expo", or configure error monitoring, tracing, profiling, session replay, or logging for React Native applications. Supports Expo managed, Expo bare, and vanilla React Native.

getsentry/sentry-react-sdk

Full Sentry SDK setup for React. Use when asked to "add Sentry to React", "install @sentry/react", or configure error monitoring, tracing, session replay, profiling, or logging for React applications. Supports React 16+, React Router v5-v7 non-framework mode, TanStack Router, Redux, Vite, and webpack.

Skills associés