dd-trace-go.v1: gopkg.in/DataDog/dd-trace-go.v1/contrib/twitchtv/twirp Index | Examples | Files

package twirp

import "gopkg.in/DataDog/dd-trace-go.v1/contrib/twitchtv/twirp"

Package twirp provides tracing functions for tracing clients and servers generated by the twirp framework (https://github.com/twitchtv/twirp).



Package Files

option.go twirp.go

func NewServerHooks Uses

func NewServerHooks(opts ...Option) *twirp.ServerHooks

NewServerHooks creates the callback hooks for a twirp server to perform tracing. It is used in conjunction with WrapServer.

func WrapServer Uses

func WrapServer(h http.Handler, opts ...Option) http.Handler

WrapServer wraps an http.Handler to add distributed tracing to a Twirp server.


defer tracer.Stop()

server := example.NewHaberdasherServer(hatmaker{}, twirptrace.NewServerHooks())
traced := twirptrace.WrapServer(server)
http.ListenAndServe(":8080", traced)

type HTTPClient Uses

type HTTPClient interface {
    Do(req *http.Request) (*http.Response, error)

HTTPClient is duplicated from twirp's generated service code. It is declared in this package so that the client can be wrapped to initiate traces.

func WrapClient Uses

func WrapClient(c HTTPClient, opts ...Option) HTTPClient

WrapClient wraps an HTTPClient to add distributed tracing to its requests.


defer tracer.Stop()

client := example.NewHaberdasherJSONClient("http://localhost:8080", twirptrace.WrapClient(&http.Client{}))
for i := 0; i < 10; i++ {
    hat, err := client.MakeHat(context.Background(), &example.Size{Inches: 6})
    if err != nil {
        fmt.Println("error making hat:", err)
    fmt.Println("made hat:", hat)

type Option Uses

type Option func(*config)

Option represents an option that can be passed to Dial.

func WithAnalytics Uses

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) Option

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

func WithServiceName Uses

func WithServiceName(name string) Option

WithServiceName sets the given service name for the dialled connection. When the service name is not explicitly set, it will be inferred based on the request to the twirp service.

Package twirp imports 11 packages (graph). Updated 2020-08-06. Refresh now. Tools for package owners.