openlatency

package
v0.0.0-...-3e353e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

HTTP headers

@link https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

In HTTP protocol exists special time header marks with the time of the message was originated and lifetime.

Date - The date and time that the message was originated (in "HTTP-date" format as defined by [https://tools.ietf.org/html/rfc7231#section-7.1.1.1](RFC 7231 Date/Time Formats)). ```Date: Tue, 15 Nov 1994 08:12:31 GMT```. Expires - Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by [https://tools.ietf.org/html/rfc7231](RFC 7231)). ```Expires: Thu, 01 Dec 1994 16:00:00 GMT```

However, all this time marks restricted in seconds what is not acceptable in RTB integration because of time counting in Milliseconds, and maximal execute time usually in Milliseconds as well. That's why we have to create new custom HTTP header with the message oridinate time in Milliseconds.

X-Request-Ts: 1549107735603 X-Response-Accepted-Ts: 1549108715201 X-Response-Ts: 1549108715201

Index

Constants

View Source
const (
	HTTPHeaderRequestTimemark = "X-Request-Ts" // In milliseconds
	HTTPHeaderRequestNode     = "X-Request-Node"
)

Variables

This section is empty.

Functions

func RequestInitTime

func RequestInitTime(t time.Time) int64

RequestInitTime converts UnixNano into Milliseconds

Types

type MetricErrorRate

type MetricErrorRate struct {
	Type MetricErrorType `json:"type"`
	Code string          `json:"code"`
	Rate float64         `json:"rate"`
}

type MetricErrorType

type MetricErrorType string

MetricErrorType values

const (
	MetricErrorHTTP    MetricErrorType = "http"
	MetricErrorNetwork MetricErrorType = "network"
)

Error type list...

type MetricsCounter

type MetricsCounter struct {
	// contains filtered or unexported fields
}

MetricsCounter implements several counters of request metrics

func NewMetricsCounter

func NewMetricsCounter() *MetricsCounter

NewMetricsCounter object

func (*MetricsCounter) BeginQuery

func (cnt *MetricsCounter) BeginQuery() int32

BeginQuery new query counter

func (*MetricsCounter) FillMetrics

func (cnt *MetricsCounter) FillMetrics(info *MetricsInfo)

FillMetrics info object

func (*MetricsCounter) IncError

func (cnt *MetricsCounter) IncError(etype MetricErrorType, code string)

IncError counter

func (*MetricsCounter) IncNobid

func (cnt *MetricsCounter) IncNobid() int32

IncNobid counter

func (*MetricsCounter) IncSkip

func (cnt *MetricsCounter) IncSkip() int32

IncSkip counter

func (*MetricsCounter) IncSuccess

func (cnt *MetricsCounter) IncSuccess() int32

IncSuccess counter

func (*MetricsCounter) IncTimeout

func (cnt *MetricsCounter) IncTimeout() int32

IncTimeout counter

func (*MetricsCounter) UpdateQueryLatency

func (cnt *MetricsCounter) UpdateQueryLatency(latency time.Duration)

UpdateQueryLatency of request

type MetricsGeoRate

type MetricsGeoRate struct {
	Country string  `json:"country"`
	Rate    float64 `json:"rate"`
}

type MetricsInfo

type MetricsInfo struct {
	ID         uint64            `json:"id"`
	Protocol   string            `json:"protocol"`
	Codename   string            `json:"codename,omitempty"`
	Traceroute string            `json:"traceroute,omitempty"`
	MinLatency int64             `json:"min_latency_ms"` // Minimal request delay in Millisecond
	MaxLatency int64             `json:"max_latency_ms"` // Maximal request delay in Millisecond
	AvgLatency int64             `json:"avg_latency_ms"` // Average request delay in Millisecond
	QPSLimit   int               `json:"qps_limit,omitempty"`
	QPS        float64           `json:"qps"`
	Skips      float64           `json:"skips_qps"`
	Success    float64           `json:"success_qps"`
	Timeouts   float64           `json:"timeouts_qps"`
	NoBids     float64           `json:"no_bids_qps"`
	Errors     float64           `json:"errors_qps"`
	ErrorRates []MetricErrorRate `json:"error_rates,omitempty"`
	GeoRates   []MetricsGeoRate  `json:"geo_rates,omitempty"`
}

MetricsInfo describes basic metric information of AdNetworks integration All counters it's numbers per second

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL