web

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package web provides functions to trace the zenazn/goji/web package (https://github.com/zenazn/goji).

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(opts ...Option) func(*web.C, http.Handler) http.Handler

Middleware returns a goji middleware function that will trace incoming requests. If goji's Router middleware is also installed, the tracer will be able to determine the original route name (e.g. "/user/:id"), and include it as part of the traces' resource names.

Example
package main

import (
	"fmt"
	"net/http"

	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web"

	webtrace "gopkg.in/flocasts/dd-trace-go.v1/contrib/zenazn/goji.v1/web"
)

func main() {
	// Using the Router middleware lets the tracer determine routes for
	// use in a trace's resource name ("GET /user/:id")
	// Otherwise the resource is only the method ("GET", "POST", etc.)
	goji.Use(goji.DefaultMux.Router)
	goji.Use(webtrace.Middleware())
	goji.Get("/hello", func(c web.C, w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Why hello there!")
	})
	goji.Serve()
}
Output:

Types

type Option

type Option func(*config)

Option represents an option that can be passed to New.

func NoDebugStack

func NoDebugStack() Option

NoDebugStack prevents stack traces from being attached to spans finishing with an error. This is useful in situations where errors are frequent and performance is critical.

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 returned mux.

func WithSpanOptions

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

WithSpanOptions applies the given set of options to the span started by the mux.

Jump to

Keyboard shortcuts

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