Documentation
¶
Index ¶
- func ClockNow(o model.Options) time.Time
- func IgnoredPath(o model.Options, path string) bool
- func InvalidOption(field string, reason string) error
- func MemoryLimit() uint64
- func NewRateSampler(rate float64) model.Sampler
- func OptionsFromEnv(opts *model.Options) error
- func RemoteAddr(r *http.Request) string
- func RequestID(r *http.Request, opts model.Options) string
- func RoutePattern(r *http.Request, opts model.Options) string
- func SamplerFor(o model.Options) model.Sampler
- func SymbolName(in any) string
- func TraceOptionsFor(o model.Options) model.TraceOptions
- type Broker
- type RateSampler
- type ResponseWriter
- func (w *ResponseWriter) Bytes() int64
- func (w *ResponseWriter) Flush()
- func (w *ResponseWriter) ReadFrom(r io.Reader) (int64, error)
- func (w *ResponseWriter) Release()
- func (w *ResponseWriter) Status() int
- func (w *ResponseWriter) Unwrap() http.ResponseWriter
- func (w *ResponseWriter) Write(p []byte) (int, error)
- func (w *ResponseWriter) WriteHeader(status int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoredPath ¶
IgnoredPath reports whether a request path is excluded from tracing. The debug front end is always excluded so it does not trace itself.
func InvalidOption ¶
InvalidOption formats a field level configuration error, wrapping model.ErrInvalidOptions so a caller can match on it.
func MemoryLimit ¶
func MemoryLimit() uint64
MemoryLimit returns the smallest memory limit the process is subject to, or zero when none can be determined.
func NewRateSampler ¶
NewRateSampler returns a sampler tracing the given percentage of requests. A rate of 100 or more traces everything, a rate of 0 or less traces nothing.
func OptionsFromEnv ¶
OptionsFromEnv applies the OIDA_* environment to opts. A variable applies only where the code left the field at its NewOptions default, so authentication and tuning configured in code win over the environment, and a variable set to nothing leaves the default alone.
The variables and their defaults are the table in docs/guide-configuration.md, which is where a deployment reads them; keeping the list in one place is what keeps it true. Lists are comma separated. OIDA_SAMPLE_RATE out of [0,100] clamps to the nearest bound. OIDA_AUTH holds one username:password pair, hashed here so the options carry a bcrypt hash the way a configured deployment would.
func RemoteAddr ¶
remoteAddr resolves the client IP of a request. It walks the forwarding chain from the Forwarded (RFC 7239) or X-Forwarded-For headers right to left and returns the first address outside the trusted LAN ranges: the hops a proxy appended are trustworthy, anything to their left is client input. When every hop is trusted, all-LAN traffic, the leftmost valid address is the client. Without a usable header the request's own RemoteAddr decides.
func RoutePattern ¶
RoutePattern returns the routed pattern of the request. A configured RouteFunc decides on its own, including when it returns nothing: a service mounting a catch-all knows that pattern is not worth grouping by, and the fallback would put it back. Without one, the pattern the router recorded on the request is used.
func SamplerFor ¶
SamplerFor returns the configured sampler, or a rate sampler for SampleRate.
func SymbolName ¶
SymbolName returns a span name read from a function, a value or a string. The import path is trimmed to its last element, so the result is the package, type and function names joined with a dot: billing.UserStore.GetUsers.
func TraceOptionsFor ¶
func TraceOptionsFor(o model.Options) model.TraceOptions
TraceOptionsFor returns the part of the configuration a recorded trace carries.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker fans out change notifications to live view subscribers. Sends are non blocking: a subscriber that is behind coalesces updates instead of slowing down the request that produced them.
type RateSampler ¶
type RateSampler struct {
// contains filtered or unexported fields
}
RateSampler samples a fixed percentage of requests using a counter rather than randomness, so the decision sequence is deterministic and testable.
type ResponseWriter ¶
type ResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
ResponseWriter records the status and the number of bytes written while preserving the optional interfaces of the wrapped writer.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter, trace *model.Trace) *ResponseWriter
NewResponseWriter wraps w to record what the handler answered with. The trace moves to StateWriting once, when the first byte or the status goes out. The wrapper comes from a pool; the middleware returns it with Release once the handler is done with it.
func (*ResponseWriter) Bytes ¶
func (w *ResponseWriter) Bytes() int64
Bytes returns the number of bytes the handler wrote.
func (*ResponseWriter) Flush ¶
func (w *ResponseWriter) Flush()
Flush forwards a flush to the wrapped writer.
func (*ResponseWriter) ReadFrom ¶
func (w *ResponseWriter) ReadFrom(r io.Reader) (int64, error)
ReadFrom counts a body streamed with io.Copy.
func (*ResponseWriter) Release ¶
func (w *ResponseWriter) Release()
Release returns the wrapper to the pool. After Release the wrapper is recycled memory, the way the http.ResponseWriter it wraps is invalid after the handler returns.
func (*ResponseWriter) Status ¶
func (w *ResponseWriter) Status() int
Status returns the status the handler wrote.
func (*ResponseWriter) Unwrap ¶
func (w *ResponseWriter) Unwrap() http.ResponseWriter
Unwrap lets http.ResponseController reach the optional interfaces implemented by the original response writer.
func (*ResponseWriter) Write ¶
func (w *ResponseWriter) Write(p []byte) (int, error)
Write counts the response body.
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
WriteHeader records the response status once.