sentry

package module
v0.1.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 3 Imported by: 0

README

eventsourced Sentry trace handler

GoReportCard GoDoc Build Status coverage report

Package sentry provides a Sentry implementation of eventsourced.TraceHandler for distributed tracing.

Install

go get gitlab.com/unboundsoftware/eventsourced/sentry

Prerequisites

  • The sentry-go SDK
  • A configured Sentry project

Getting Started

Initialize the Sentry SDK, then pass sentry.Tracing to any component that accepts a TraceHandler:

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

    "gitlab.com/unboundsoftware/eventsourced/eventsourced"
    "gitlab.com/unboundsoftware/eventsourced/sentry"
    "gitlab.com/unboundsoftware/eventsourced/pg"
)

// Initialize Sentry
sentrygo.Init(sentrygo.ClientOptions{
    Dsn:              "your-dsn",
    TracesSampleRate: 1.0,
})

// Use with command handler
handler, err := eventsourced.NewHandler(ctx, aggregate, store,
    eventsourced.WithTraceHandler(sentry.Tracing),
)

// Use with PostgreSQL event store
store, err := pg.New(ctx, db,
    pg.WithEventTypes(&MyEvent{}),
    pg.WithTraceHandler(sentry.Tracing),
)

// Use with AMQP publisher
publisher, err := amqp.New(goamqpPublisher,
    amqp.WithTraceHandler(sentry.Tracing),
)

How It Works

sentry.Tracing is a pre-configured eventsourced.TraceHandler that wraps each traced operation in a Sentry span using sentry.StartSpan. The operation name is used as the span description. Spans are automatically finished when the deferred cleanup function is called.

API

Symbol Type Description
Tracing eventsourced.TraceHandler Ready-to-use trace handler for Sentry

Documentation

Overview

Package sentry provides a [Sentry](https://sentry.io) implementation of eventsourced.TraceHandler for distributed tracing.

The package exposes a single variable, Tracing, which is a ready-to-use trace handler that wraps operations in Sentry spans.

Usage

import (
    sentry "gitlab.com/unboundsoftware/eventsourced/sentry"
)

// Use with command handler
handler, err := eventsourced.NewHandler(ctx, aggregate, store,
    eventsourced.WithTraceHandler(sentry.Tracing),
)

// Use with PostgreSQL event store
store, err := pg.New(ctx, db,
    pg.WithEventTypes(&MyEvent{}),
    pg.WithTraceHandler(sentry.Tracing),
)

Ensure the Sentry SDK is initialized before using this package:

sentry.Init(sentry.ClientOptions{
    Dsn: "your-dsn",
    TracesSampleRate: 1.0,
})

Index

Constants

This section is empty.

Variables

Tracing is a ready-to-use eventsourced.TraceHandler that creates Sentry spans for traced operations. Pass it to eventsourced.WithTraceHandler or pg.WithTraceHandler to enable Sentry distributed tracing.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL