datadog

package
v3.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

Datadog Tracing

This package enables Datadog tracing in go-restful apps.

The Trace() filter function will automatically detect the trace in HTTP request header, if any, and generate trace for that request.

Usage

Importing
import "github.com/AccelByte/go-restful-plugins/pkg/apm/datadog"
Start the tracer

Important, Datadog tracer will not send any trace if not started. You only need to call this once.

datadog.Start("localhost:8126", "example-service", false)
Trace all endpoints
ws := new(restful.WebService)
ws.Filter(datadog.Trace)
Trace specific endpoint
ws := new(restful.WebService)
ws.Route(ws.GET("/user/{id}").
    Filter(datadog.Trace).
    To(func(request *restful.Request, response *restful.Response) {
}))
Inject trace header to outgoing request

To propagate trace into other services, instrument the request by injecting Datadog trace to the request.

outReq := httptest.NewRequest("GET", "localhost/example", nil)
Inject(outReq, request)
http.DefaultClient.Do(outReq)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inject

func Inject(outRequest *http.Request, restfulRequest *restful.Request) error

Inject adds tracer header to a HTTP request

func Start

func Start(addr string, serviceName string, environment string, debugMode bool)

Start initiates the tracer

func Trace

func Trace(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)

Trace is a filter that will trace incoming request

Types

This section is empty.

Jump to

Keyboard shortcuts

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