Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const (
OtelTraceContextKey = "opentelemetry.gin"
)
Variables ¶
This section is empty.
Functions ¶
func CaptureException ¶
func CaptureException(repanic bool) gin.HandlerFunc
CaptureException captures error and panic to open-telemetry.
Example ¶
package main import ( "github.com/gin-gonic/gin" tracinggin2 "github.com/yeqown/opentelemetry-quake/contrib/gin" ) func main() { r := gin.Default() r.Use( tracinggin2.CaptureException(false), ) }
Output:
func SentryCarrierAdaptor ¶
func SentryCarrierAdaptor(h http.Header) tracing.TraceContextCarrier
SentryCarrierAdaptor is an adapter that let sentry trace is valid for open-telemetry.
func Tracing ¶
func Tracing(opts ...TracingOption) gin.HandlerFunc
Tracing creates a new otel.Tracer if never created and returns a gin.HandlerFunc. You only need to specify a CarrierFactory if your frontend doesn't obey TraceContext specification https://www.w3.org/TR/trace-context, otherwise you can leave it nil.
Example ¶
package main import ( "github.com/gin-gonic/gin" tracinggin2 "github.com/yeqown/opentelemetry-quake/contrib/gin" ) func main() { r := gin.Default() r.Use( tracinggin2.Tracing(), ) // sentry trace header r.Use(tracinggin2.Tracing( tracinggin2.WithCarrierFactory(tracinggin2.SentryCarrierAdaptor), tracinggin2.WithRecordPayloads(), )) }
Output:
Types ¶
type TracingOption ¶
type TracingOption interface {
// contains filtered or unexported methods
}
func WithCarrierFactory ¶
func WithCarrierFactory(adaptor func(h http.Header) tracing.TraceContextCarrier) TracingOption
func WithRecordPayloads ¶
func WithRecordPayloads() TracingOption
Click to show internal directories.
Click to hide internal directories.