Documentation ¶
Overview ¶
Package traceserver is a mocked APM trace server that calls a handler for each spanlists payload it gets.
It can be used as a standalone server (see: sdk/cmd/traces) or in integration tests.
Index ¶
Constants ¶
const ( // HeaderTraceCount is a header containing the number of traces in the payload HeaderTraceCount = "X-Datadog-Trace-Count" HeaderContainerID = "Datadog-Container-ID" )
Headers
const (
ContentTypeApplicationMessagePack = "application/msgpack"
)
ContentTypes
Variables ¶
This section is empty.
Functions ¶
func FormatContentLength ¶
FormatContentLength returns a string representation of a file size in bytes.
Types ¶
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter StatusCode int ContentLength int }
ResponseWriter a better response writer
func (*ResponseWriter) Close ¶
func (rw *ResponseWriter) Close() error
Close calls close on the inner response if it supports it.
func (*ResponseWriter) Flush ¶
func (rw *ResponseWriter) Flush()
Flush calls flush on the inner response writer if it is supported.
func (*ResponseWriter) Hijack ¶
func (rw *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack wraps response writer's Hijack function.
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(b []byte) (int, error)
Write writes the data to the response.
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(code int)
WriteHeader writes the status code (it is a somewhat poorly chosen method name from the standard library).
type Server ¶
type Server struct { Addr string Log *log.Logger Listener net.Listener Server *http.Server Handler func(context.Context, ...*Span) }
Server is a server for handling traces.
type Span ¶
type Span struct { Name string `json:"name" msg:"name"` // operation name Service string `json:"service" msg:"service"` // service name (i.e. "grpc.server", "http.request") Resource string `json:"resource" msg:"resource"` // resource name (i.e. "/user?id=123", "SELECT * FROM users") Type string `json:"type" msg:"type"` // protocol associated with the span (i.e. "web", "db", "cache") Start int64 `json:"start" msg:"start"` // span start time expressed in nanoseconds since epoch Duration int64 `json:"duration" msg:"duration"` // duration of the span expressed in nanoseconds Meta map[string]string `json:"meta,omitempty" msg:"meta,omitempty"` // arbitrary map of metadata Metrics map[string]float64 `json:"metrics,omitempty" msg:"metrics,omitempty"` // arbitrary map of numeric metrics SpanID uint64 `json:"span_id" msg:"span_id"` // identifier of this span TraceID uint64 `json:"trace_id" msg:"trace_id"` // identifier of the root span ParentID uint64 `json:"parent_id" msg:"parent_id"` // identifier of the span's direct parent Error int32 `json:"error" msg:"error"` // error status of the span; 0 means no errors }
Span represents a computation. Callers must call Finish when a span is complete to ensure it's submitted.
type SpanList ¶
type SpanList []*Span
SpanList implements msgp.Encodable on top of a slice of spans.