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 Average
- type Float
- type Max
- type Min
- 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 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
- type Ptile
- type Sum
- type Val
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 Average ¶ added in v7.6.23
type Average [2]float64
Average holds the total plus a count in order to calculate the arithmatic mean
func (Average) MarshalJSON ¶ added in v7.6.23
Average is marshalled to JSON as its final float64 value.
type Float ¶ added in v7.6.23
type Float Sum
Float is an alias for Sum, it is deprecated, using Sum instead
type Max ¶ added in v7.6.23
type Max float64
Max is a float value that gets reduced by taking the highest value.
type Min ¶ added in v7.6.23
type Min float64
Min is a float value that gets reduced by taking the lowest value.
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") )
type Sum ¶ added in v7.6.23
type Sum float64
Sum is float value that gets reduced by plain addition.
type Val ¶ added in v7.6.23
type Val interface { // Get gets the final value (either a float64 or []float64) Get() interface{} // Merges merges another value with this one, using logic specific to the type // of value. Merge(b Val) Val }
Val represents a value that can be reduced by a reducing submitter.
func Avg ¶ added in v7.6.23
Avg creates a value that gets reduced by taking the arithmetic mean of the values.
func Percentile ¶ added in v7.6.23
Percentile stores individual values so that they can be used in a percentile in the DB
func WeightedAvg ¶ added in v7.6.23
WeightedAvg is like Avg but the value is weighted by a given weight.