gin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package gin provides functions to trace the gin-gonic/gin package (https://github.com/gin-gonic/gin).

Example

To start tracing requests, add the trace middleware to your Gin router.

Output:

Example (SpanFromContext)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(c *gin.Context, code int, name string, obj interface{})

HTML will trace the rendering of the template as a child of the span in the given context.

Example
Output:

func Middleware

func Middleware(service string, opts ...Option) gin.HandlerFunc

Middleware returns middleware that will trace incoming requests. If service is empty then the default service name will be used.

Types

type Option

type Option func(*config)

Option specifies instrumentation configuration options.

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 WithHeaderTags

func WithHeaderTags(headers []string) Option

WithHeaderTags enables the integration to attach HTTP request headers as span tags. Warning: Using this feature can risk exposing sensitive data such as authorization tokens to Datadog. Special headers can not be sub-selected. E.g., an entire Cookie header would be transmitted, without the ability to choose specific Cookies.

func WithIgnoreRequest

func WithIgnoreRequest(f func(c *gin.Context) bool) Option

WithIgnoreRequest specifies a function to use for determining if the incoming HTTP request tracing should be skipped.

func WithResourceNamer

func WithResourceNamer(namer func(c *gin.Context) string) Option

WithResourceNamer specifies a function which will be used to obtain a resource name for a given gin request, using the request's context.

Jump to

Keyboard shortcuts

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