Documentation ¶
Overview ¶
Package ops wraps github.com/getlantern/ops with convenience methods for flashlight
Index ¶
- func Go(fn func())
- func InitGlobalContext(appName, applicationVersion, revisionDate, deviceID string, isPro func() bool, ...)
- func ProxyNameAndDC(name string) (proxyName string, dc string)
- func RegisterReporter(reporter ops.Reporter)
- func SetGlobal(key string, value interface{})
- func SetGlobalDynamic(key string, valueFN func() interface{})
- func WithOp(ctx context.Context, op *Op) context.Context
- type InstrumentedResponseWriter
- func (w *InstrumentedResponseWriter) FailIf(err error)
- func (w *InstrumentedResponseWriter) Finish()
- func (w *InstrumentedResponseWriter) Set(key string, value interface{})
- func (w *InstrumentedResponseWriter) Write(p []byte) (n int, err error)
- func (w *InstrumentedResponseWriter) WriteHeader(statusCode int)
- type Op
- func (op *Op) BalancerDialTime(elapsed time.Duration, err error) *Op
- func (op *Op) Begin(name string) *Op
- func (op *Op) Cancel()
- func (op *Op) ChainedProxy(name string, addr string, protocol string, network string, multiplexed bool) *Op
- func (op *Op) CoreDialTime(elapsed time.Duration, err error) *Op
- func (op *Op) DialTime(elapsed time.Duration, err error) *Op
- func (op *Op) End()
- func (op *Op) FailIf(err error) error
- func (op *Op) Go(fn func())
- func (op *Op) HTTPStatusCode(code int) *Op
- func (op *Op) OriginFromRequest(req *http.Request) *Op
- func (op *Op) OriginPort(origin string, defaultPort string) *Op
- func (op *Op) ProxyAddr(v string) *Op
- func (op *Op) ProxyMultiplexed(v bool) *Op
- func (op *Op) ProxyName(name string) *Op
- func (op *Op) ProxyNetwork(v string) *Op
- func (op *Op) ProxyProtocol(v string) *Op
- func (op *Op) ProxyType(v ProxyType) *Op
- func (op *Op) Request(req *http.Request) *Op
- func (op *Op) Response(r *http.Response) *Op
- func (op *Op) Set(key string, value interface{}) *Op
- func (op *Op) SetDynamic(key string, valueFN func() interface{}) *Op
- func (op *Op) SetMetric(name string, value borda.Val) *Op
- func (op *Op) SetMetricAvg(name string, value float64) *Op
- func (op *Op) SetMetricMax(name string, value float64) *Op
- func (op *Op) SetMetricMin(name string, value float64) *Op
- func (op *Op) SetMetricPercentile(name string, value float64) *Op
- func (op *Op) SetMetricSum(name string, value float64) *Op
- func (op *Op) UserAgent(v string) *Op
- func (op *Op) Wrapped() ops.Op
- type ProxyType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitGlobalContext ¶
func InitGlobalContext(appName, applicationVersion, revisionDate, deviceID string, isPro func() bool, getCountry func() string)
InitGlobalContext configures global context info
func ProxyNameAndDC ¶
ProxyNameAndDC extracts the canonical proxy name and datacenter from a given full proxy name.
func RegisterReporter ¶
RegisterReporter mimics the similar method from ops
func SetGlobal ¶
func SetGlobal(key string, value interface{})
SetGlobal mimics the similar method from ops
func SetGlobalDynamic ¶
func SetGlobalDynamic(key string, valueFN func() interface{})
SetGlobalDynamic mimics the similar method from ops
Types ¶
type InstrumentedResponseWriter ¶
type InstrumentedResponseWriter struct { http.ResponseWriter Op *Op // contains filtered or unexported fields }
func InitInstrumentedResponseWriter ¶
func InitInstrumentedResponseWriter(w http.ResponseWriter, label string) *InstrumentedResponseWriter
func (*InstrumentedResponseWriter) FailIf ¶
func (w *InstrumentedResponseWriter) FailIf(err error)
func (*InstrumentedResponseWriter) Finish ¶
func (w *InstrumentedResponseWriter) Finish()
func (*InstrumentedResponseWriter) Set ¶
func (w *InstrumentedResponseWriter) Set(key string, value interface{})
func (*InstrumentedResponseWriter) Write ¶
func (w *InstrumentedResponseWriter) Write(p []byte) (n int, err error)
func (*InstrumentedResponseWriter) WriteHeader ¶
func (w *InstrumentedResponseWriter) WriteHeader(statusCode int)
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op decorates an ops.Op with convenience methods.
func FromContext ¶
FromContext extracts an Op from the context, or nil if doesn't exist
func (*Op) BalancerDialTime ¶
BalancerDialTime records a balancer dial time relative to a given start time (in milliseconds) if and only if there is no error.
func (*Op) ChainedProxy ¶
func (op *Op) ChainedProxy(name string, addr string, protocol string, network string, multiplexed bool) *Op
ChainedProxy attaches chained proxy information to the Context
func (*Op) CoreDialTime ¶
CoreDialTime records a core dial time relative to a given start time (in milliseconds) if and only if there is no error.
func (*Op) DialTime ¶
DialTime records a dial time relative to a given start time (in milliseconds) if and only if there is no error.
func (*Op) HTTPStatusCode ¶
func (*Op) OriginFromRequest ¶
OriginFromRequest attaches the origin to the Context based on the request's Host property.
func (*Op) OriginPort ¶
Origin attaches the origin to the Context
func (*Op) ProxyMultiplexed ¶
func (*Op) ProxyName ¶
ProxyName attaches the name of the proxy and the inferred datacenter to the Context
func (*Op) ProxyNetwork ¶
ProxyNetwork attaches proxy server's network (tcp or kcp) to the Context
func (*Op) ProxyProtocol ¶
ProxyProtocol attaches proxy server's protocol (http, https or obfs4) to the Context
func (*Op) Response ¶
Response attaches key information of an `http.Response` to the Context. If the response has corresponding Request it will call Request internally.
func (*Op) SetDynamic ¶
SetDynamic mimics the similar method from ops.Op
func (*Op) SetMetric ¶
SetMetric sets a named metric. Metrics will be reported as borda values rather than dimensions.
type ProxyType ¶
type ProxyType string
ProxyType is the type of various proxy channel
const ( // ProxyNone means direct access, not proxying at all ProxyNone ProxyType = "none" // ProxyChained means access through Lantern hosted chained server ProxyChained ProxyType = "chained" // ProxyFronted means access through domain fronting ProxyFronted ProxyType = "fronted" // NB - a beam is like a tracing ID and has nothing to do with the application named "beam" CtxKeyBeam = contextKey("beam") )