timing

package
v0.0.0-...-6637ac4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package timing provides a plugin Xavi wires in as the enclosing wrapper for the user specified plugin chain. This plugin creates and puts an EndToEndTimer into the context that downstream components may annotate with the service name and contributors of note. The JSON representation of the timing is logged on completion of the wrapped call chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServiceNameToContext

func AddServiceNameToContext(ctx context.Context, serviceName string) context.Context

AddServiceNameToContext adds the name of the service the backend handler will invoke. This provides a service name in the output timing log to allow the latency of different backend services to be assessed.

func GetServiceNameFromContext

func GetServiceNameFromContext(ctx context.Context) string

GetServiceNameFromContext pulls the service name from the context.

func NewContextWithNamedTimer

func NewContextWithNamedTimer(ctx context.Context, name string) context.Context

NewContextWithNamedTimer adds a new timer to the request context

func NewContextWithTimer

func NewContextWithTimer(ctx context.Context) context.Context

NewContextWithTimer adds a new timer to the request context

func NewTimingWrapper

func NewTimingWrapper(args ...interface{}) plugin.Wrapper

NewTimingWrapper returns a Wrapper that will trace the round trip time of the request. It is possible to specify the initial name of the timer passing a string to this function.

func TimerFromContext

func TimerFromContext(ctx context.Context) *timer.EndToEndTimer

TimerFromContext returns an EndToEndTimer from the given context if one is present, otherwise nil is returned

Types

type TimingWrapper

type TimingWrapper struct {
	// contains filtered or unexported fields
}

func (TimingWrapper) Wrap

func (tw TimingWrapper) Wrap(h http.Handler) http.Handler

Wrap implements the plugin Wrapper interface, and is used to wrap a handler to put a EndToEndTimer instance into the call context

Jump to

Keyboard shortcuts

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