fiber

package
v1.35.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fiber provides tracing functions for tracing the fiber package (https://github.com/gofiber/fiber).

Example
// Start the tracer
tracer.Start()
defer tracer.Stop()

// Create a fiber v2 Router
router := fiber.New()

// Use the tracer middleware with the default service name "fiber".
router.Use(fibertrace.Middleware())

// Set up some endpoints.
router.Get("/", func(c *fiber.Ctx) error {
	return c.SendString("test")
})

// And start gathering request traces
router.Listen(":8080")
Output:

Example (WithServiceName)
// Start the tracer
tracer.Start()
defer tracer.Stop()

// Create a fiber v2 Router
router := fiber.New()

// Use the tracer middleware with your desired service name.
router.Use(fibertrace.Middleware(fibertrace.WithServiceName("fiber")))

// Set up some endpoints.
router.Get("/", func(c *fiber.Ctx) error {
	return c.SendString("test")
})

// And start gathering request traces
router.Listen(":8080")
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(opts ...Option) func(c *fiber.Ctx) error

Middleware returns middleware that will trace incoming requests.

Types

type Option

type Option func(*config)

Option represents an option that can be passed to NewRouter.

func WithAnalytics

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate

func WithAnalyticsRate(rate float64) Option

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName

func WithServiceName(name string) Option

WithServiceName sets the given service name for the router.

func WithSpanOptions

func WithSpanOptions(opts ...ddtrace.StartSpanOption) Option

WithSpanOptions applies the given set of options to the spans started by the router.

func WithStatusCheck

func WithStatusCheck(fn func(statusCode int) bool) Option

WithStatusCheck allow setting of a function to tell whether a status code is an error

Jump to

Keyboard shortcuts

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