grpc_sentry

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

README

Go gRPC Middleware for Sentry

gRPC Go middleware for Sentry: server and client interceptors

Middleware

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

    grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
    grpc_sentry "github.com/johnbellone/grpc-middleware-sentry"
)

func main() {
	err = sentry.Init(sentry.ClientOptions{
		Dsn: "https://897a3ef46125472da3ab8766deb302fe7fc7ade3@ingest.sentry.io/42",
		Debug: false,
		Environment: "development",
		Release: "my-project@0.1.0",
		IgnoreErrors: []string{},
	})
	defer sentry.Flush(2 * time.Second)
	if err != nil {
		logger.Fatal(err.Error())
	}

	s := grpc.NewServer(
		grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
			grpc_sentry.StreamServerInterceptor(),
		)),
		grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
			grpc_sentry.UnaryServerInterceptor(),
		)),
	)
}

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0 `grpc_sentry` provides client and server interceptors to report to Sentry.

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContinueFromGrpcMetadata added in v0.2.0

func ContinueFromGrpcMetadata(md metadata.MD) sentry.SpanOption

ContinueFromGrpcMetadata returns a span option that updates the span to continue an existing trace. If it cannot detect an existing trace in the request, the span will be left unchanged.

func ReportAlways

func ReportAlways(error) bool

func ReportOnCodes

func ReportOnCodes(cc ...codes.Code) reporter

func StreamClientInterceptor

func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor

func StreamServerInterceptor

func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor

func UnaryClientInterceptor

func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor

Types

type Option added in v0.1.0

type Option interface {
	Apply(*options)
}

func WithCaptureRequestBody added in v0.4.0

func WithCaptureRequestBody(b bool) Option

func WithOperationNameOverride added in v0.4.0

func WithOperationNameOverride(s string) Option

func WithRepanicOption added in v0.1.0

func WithRepanicOption(b bool) Option

func WithReportOn added in v0.1.0

func WithReportOn(r reporter) Option

func WithTimeout added in v0.1.0

func WithTimeout(t time.Duration) Option

func WithWaitForDelivery added in v0.1.0

func WithWaitForDelivery(b bool) Option

Jump to

Keyboard shortcuts

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