Documentation
¶
Overview ¶
Package fiber provides tracing functions for tracing the fiber package (https://github.com/gofiber/fiber).
Example ¶
package main
import (
fibertrace "git.proto.group/protoobp/pobp-trace-go/contrib/gofiber/fiber.v2"
"git.proto.group/protoobp/pobp-trace-go/pobptrace/tracer"
"github.com/gofiber/fiber/v2"
)
func main() {
// 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) ¶
package main
import (
fibertrace "git.proto.group/protoobp/pobp-trace-go/contrib/gofiber/fiber.v2"
"git.proto.group/protoobp/pobp-trace-go/pobptrace/tracer"
"github.com/gofiber/fiber/v2"
)
func main() {
// 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 ¶
Types ¶
type Option ¶
type Option func(*config)
Option represents an option that can be passed to NewRouter.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithResourceNamer ¶
WithResourceNamer specifies a function which will be used to obtain the resource name for a given request taking the go-fiber context as input
func WithServiceName ¶
WithServiceName sets the given service name for the router.
func WithSpanOptions ¶
func WithSpanOptions(opts ...pobptrace.StartSpanOption) Option
WithSpanOptions applies the given set of options to the spans started by the router.
func WithStatusCheck ¶
WithStatusCheck allow setting of a function to tell whether a status code is an error