Skip to main content
Help improve this documentation

This documentation is still new and evolving. If you spot any mistakes, unclear explanations, or missing details, please open an issue.

Your feedback helps us improve!

Logger/Sentry operatorsโ€‹

This page lists all operators available in the observability/sentry sub-package of ro.

Installโ€‹

First, import the sub-package in your project:

go get -u github.com/samber/ro/plugins/observability/sentry
  • Logs events to Sentry.

    import (
    "github.com/samber/ro"
    rosentry "github.com/samber/ro/plugins/observability/sentry"
    "github.com/getsentry/sentry-go"
    )

    hub := sentry.NewHub(sentry.CurrentClient(), sentry.NewScope())
    obs := ro.Pipe[string, string](
    ro.Just("user login", "data processing", "error occurred"),
    rosentry.Log[string](hub, sentry.LevelInfo),
    )

    sub := obs.Subscribe(ro.PrintObserver[string]())
    defer sub.Unsubscribe()

    // Sentry events captured for: user login, data processing, error occurred
    // Next: user login
    // Next: data processing
    // Next: error occurred
    // Completed
    Prototype:
    func Log[T any](logger *sentry.Hub, level sentry.Level)
  • LogWithNotificationโ€‹

    Logs events to Sentry with structured data and notifications.

    import (
    "github.com/getsentry/sentry-go"
    "github.com/samber/ro"
    rosentry "github.com/samber/ro/plugins/observability/sentry"
    )

    hub := sentry.NewHub(sentry.CurrentClient(), sentry.NewScope())
    obs := ro.Pipe[string, string](
    ro.Just("user login", "data processing", "error occurred"),
    rosentry.LogWithNotification[string](hub, sentry.LevelInfo),
    )

    sub := obs.Subscribe(ro.PrintObserver[string]())
    defer sub.Unsubscribe()

    // Sentry events captured with structured data for: user login, data processing, error occurred
    // Next: user login
    // Next: data processing
    // Next: error occurred
    // Completed
    Variant:
    Similar:
    Prototype:
    func LogWithNotification[T any](logger *sentry.Hub, level sentry.Level)