tracing

package
v2.26.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 8 Imported by: 0

README

Tracing

[!WARNING] Deprecated: This package is deprecated and will not be maintained.

Please use go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin instead.


This middleware provides tracing capabilities for your application.

It is based on the OpenTelmetry specification and can be used with any OpenTelemetry compatible tracing backend.

Usage Example

package main

import (
	"context"

	"github.com/gin-gonic/gin"

	"github.com/go-kratos-ecosystem/components/v2/gin/middleware/tracing"
)

func main() {
	router := gin.Default()
	router.Use(tracing.New())
	router.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})

	if err := router.Run(":8000"); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) gin.HandlerFunc

New returns a new tracing middleware.

Types

type Option

type Option func(*options)

func WithSpanHandlers

func WithSpanHandlers(handlers ...SpanHandler) Option

func WithTracerName

func WithTracerName(tracerName string) Option

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

type SpanHandler

type SpanHandler interface {
	StartSpan(ctx context.Context, span trace.Span, c *gin.Context)
	EndSpan(ctx context.Context, span trace.Span, c *gin.Context)
}

Jump to

Keyboard shortcuts

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