Documentation
¶
Index ¶
- Constants
- Variables
- func BackendFactory(bf proxy.BackendFactory) proxy.BackendFactory
- func GetAggregatedPathForBackendMetrics(cfg *config.Backend, r *http.Request) string
- func GetAggregatedPathForMetrics(cfg *config.EndpointConfig, r *http.Request) string
- func HTTPRequestExecutor(clientFactory transport.HTTPClientFactory, cfg *config.Backend) transport.HTTPRequestExecutor
- func IsBackendEnabled() bool
- func IsPipeEnabled() bool
- func IsRouterEnabled() bool
- func Middleware(name string) proxy.Middleware
- func NewHTTPClient(ctx context.Context) *http.Client
- func ProxyFactory(pf proxy.Factory) proxy.FactoryFunc
- func Register(ctx context.Context, srvCfg config.ServiceConfig, vs ...*view.View) error
- func RegisterExporterFactories(ef ExporterFactory)
- func RequestAttrs(r *http.Request) []trace.Attribute
- func ResponseAttrs(resp *http.Response) []trace.Attribute
- func SpanNameFromURL(req *http.Request) string
- func TraceStatus(httpStatusCode int, statusLine string) trace.Status
- type Config
- type EnabledLayers
- type EndpointExtraConfig
- type ExporterFactory
- type Transport
Constants ¶
const ( ContextKey = "opencensus-request-span" Namespace = "github_com/philippheuer/krakend-opencensus" )
Variables ¶
var ( DefaultViews = []*view.View{ ochttp.ClientSentBytesDistribution, ochttp.ClientReceivedBytesDistribution, ochttp.ClientRoundtripLatencyDistribution, ochttp.ClientCompletedCount, ochttp.ServerRequestCountView, ochttp.ServerRequestBytesView, ochttp.ServerResponseBytesView, ochttp.ServerLatencyView, ochttp.ServerRequestCountByMethod, ochttp.ServerResponseCountByStatusCode, } )
Functions ¶
func BackendFactory ¶
func BackendFactory(bf proxy.BackendFactory) proxy.BackendFactory
func GetAggregatedPathForBackendMetrics ¶
GetAggregatedPathForBackendMetrics does path aggregation to reduce path cardinality in the metrics
func GetAggregatedPathForMetrics ¶
func GetAggregatedPathForMetrics(cfg *config.EndpointConfig, r *http.Request) string
GetAggregatedPathForMetrics does path aggregation to reduce path cardinality in the metrics
func HTTPRequestExecutor ¶
func HTTPRequestExecutor(clientFactory transport.HTTPClientFactory, cfg *config.Backend) transport.HTTPRequestExecutor
func IsBackendEnabled ¶
func IsBackendEnabled() bool
func IsPipeEnabled ¶
func IsPipeEnabled() bool
func IsRouterEnabled ¶
func IsRouterEnabled() bool
func Middleware ¶
func Middleware(name string) proxy.Middleware
func ProxyFactory ¶
func ProxyFactory(pf proxy.Factory) proxy.FactoryFunc
func RegisterExporterFactories ¶
func RegisterExporterFactories(ef ExporterFactory)
func SpanNameFromURL ¶
Types ¶
type Config ¶
type Config struct {
SampleRate int `json:"sample_rate"`
ReportingPeriod int `json:"reporting_period"`
EnabledLayers *EnabledLayers `json:"enabled_layers"`
Exporters struct {
InfluxDB *struct {
Address string `json:"address"`
Username string `json:"username"`
Password string `json:"password"`
Timeout string `json:"timeout"`
PingEnabled bool `json:"ping"`
Database string `json:"db"`
InstanceName string `json:"service_name"`
BufferSize int `json:"buffer_size"`
} `json:"influxdb"`
Zipkin *struct {
CollectorURL string `json:"collector_url"`
ServiceName string `json:"service_name"`
IP string `json:"ip"`
Port int `json:"port"`
} `json:"zipkin"`
Jaeger *struct {
Endpoint string `json:"endpoint"`
ServiceName string `json:"service_name"`
} `json:"jaeger"`
Prometheus *struct {
Namespace string `json:"namespace"`
Port int `json:"port"`
HostTag bool `json:"tag_host"`
PathTag bool `json:"tag_path"`
MethodTag bool `json:"tag_method"`
StatusCodeTag bool `json:"tag_statuscode"`
} `json:"prometheus"`
Logger *struct{} `json:"logger"`
Xray *struct {
UseEnv bool `json:"use_env"`
Region string `json:"region"`
AccessKey string `json:"access_key_id"`
SecretKey string `json:"secret_access_key"`
Version string `json:"version"`
} `json:"xray"`
Stackdriver *struct {
ProjectID string `json:"project_id"`
MetricPrefix string `json:"metric_prefix"`
DefaultLabels map[string]string `json:"default_labels"`
} `json:"stackdriver"`
} `json:"exporters"`
}
type EnabledLayers ¶
type EndpointExtraConfig ¶
type EndpointExtraConfig struct {
PathAggregation string `json:"path_aggregation"`
}
type Transport ¶
type Transport struct {
// Base may be set to wrap another http.RoundTripper that does the actual
// requests. By default http.DefaultTransport is used.
//
// If base HTTP roundtripper implements CancelRequest,
// the returned round tripper will be cancelable.
Base http.RoundTripper
// Propagation defines how traces are propagated. If unspecified, a default
// (currently B3 format) will be used.
Propagation propagation.HTTPFormat
// StartOptions are applied to the span started by this Transport around each
// request.
//
// StartOptions.SpanKind will always be set to trace.SpanKindClient
// for spans started by this transport.
StartOptions trace.StartOptions
// GetStartOptions allows to set start options per request. If set,
// StartOptions is going to be ignored.
GetStartOptions func(*http.Request) trace.StartOptions
// NameFromRequest holds the function to use for generating the span name
// from the information found in the outgoing HTTP Request. By default the
// name equals the URL Path.
FormatSpanName func(*http.Request) string
// NewClientTrace may be set to a function allowing the current *trace.Span
// to be annotated with HTTP request event information emitted by the
// httptrace package.
NewClientTrace func(*http.Request, *trace.Span) *httptrace.ClientTrace
// contains filtered or unexported fields
}
Transport is an http.RoundTripper that instruments all outgoing requests with OpenCensus stats and tracing.
The zero value is intended to be a useful default, but for now it's recommended that you explicitly set Propagation, since the default for this may change.
func (*Transport) CancelRequest ¶
CancelRequest cancels an in-flight request by closing its connection.