pbsmetrics

package
v0.0.0-...-97a8816 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterBid

type AdapterBid string

AdapterBid : Whether or not the adapter returned bids

const (
	AdapterBidPresent AdapterBid = "bid"
	AdapterBidNone    AdapterBid = "nobid"
)

Adapter bid repsonse status.

func AdapterBids

func AdapterBids() []AdapterBid

type AdapterError

type AdapterError string

AdapterError : Errors which may have occurred during the adapter's execution

const (
	AdapterErrorBadInput            AdapterError = "badinput"
	AdapterErrorBadServerResponse   AdapterError = "badserverresponse"
	AdapterErrorTimeout             AdapterError = "timeout"
	AdapterErrorFailedToRequestBids AdapterError = "failedtorequestbid"
	AdapterErrorUnknown             AdapterError = "unknown_error"
)

Adapter execution status

func AdapterErrors

func AdapterErrors() []AdapterError

type AdapterLabels

type AdapterLabels struct {
	Source        DemandSource
	RType         RequestType
	Adapter       openrtb_ext.BidderName
	PubID         string // exchange specific ID, so we cannot compile in values
	Browser       Browser
	CookieFlag    CookieFlag
	AdapterBids   AdapterBid
	AdapterErrors map[AdapterError]struct{}
}

AdapterLabels defines the labels that can be attached to the adapter metrics.

type AdapterMetrics

type AdapterMetrics struct {
	NoCookieMeter     metrics.Meter
	ErrorMeters       map[AdapterError]metrics.Meter
	NoBidMeter        metrics.Meter
	GotBidsMeter      metrics.Meter
	RequestTimer      metrics.Timer
	PriceHistogram    metrics.Histogram
	BidsReceivedMeter metrics.Meter
	MarkupMetrics     map[openrtb_ext.BidType]*MarkupDeliveryMetrics
}

AdapterMetrics houses the metrics for a particular adapter

type Browser

type Browser string

Browser type enumeration

const (
	BrowserSafari Browser = "safari"
	BrowserOther  Browser = "other"
)

Browser flag; at this point we only care about identifying Safari

func BrowserTypes

func BrowserTypes() []Browser

type CookieFlag

type CookieFlag string

CookieFlag : User ID cookie exists flag

const (
	CookieFlagYes     CookieFlag = "exists"
	CookieFlagNo      CookieFlag = "no"
	CookieFlagUnknown CookieFlag = "unknown"
)

Cookie flag

func CookieTypes

func CookieTypes() []CookieFlag

type DemandSource

type DemandSource string

DemandSource : Demand source enumeration

const (
	DemandWeb     DemandSource = "web"
	DemandApp     DemandSource = "app"
	DemandUnknown DemandSource = "unknown"
)

The demand sources

func DemandTypes

func DemandTypes() []DemandSource

type Labels

type Labels struct {
	Source        DemandSource
	RType         RequestType
	PubID         string // exchange specific ID, so we cannot compile in values
	Browser       Browser
	CookieFlag    CookieFlag
	RequestStatus RequestStatus
}

Labels defines the labels that can be attached to the metrics.

type MarkupDeliveryMetrics

type MarkupDeliveryMetrics struct {
	AdmMeter  metrics.Meter
	NurlMeter metrics.Meter
}

type Metrics

type Metrics struct {
	MetricsRegistry            metrics.Registry
	ConnectionCounter          metrics.Counter
	ConnectionAcceptErrorMeter metrics.Meter
	ConnectionCloseErrorMeter  metrics.Meter
	ImpMeter                   metrics.Meter
	AppRequestMeter            metrics.Meter
	NoCookieMeter              metrics.Meter
	SafariRequestMeter         metrics.Meter
	SafariNoCookieMeter        metrics.Meter
	RequestTimer               metrics.Timer
	// Metrics for OpenRTB requests specifically. So we can track what % of RequestsMeter are OpenRTB
	// and know when legacy requests have been abandoned.
	RequestStatuses  map[RequestType]map[RequestStatus]metrics.Meter
	AmpNoCookieMeter metrics.Meter
	CookieSyncMeter  metrics.Meter

	AdapterMetrics map[openrtb_ext.BidderName]*AdapterMetrics
	// contains filtered or unexported fields
}

Metrics is the legacy Metrics object (go-metrics) expanded to also satisfy the MetricsEngine interface

func NewBlankMetrics

func NewBlankMetrics(registry metrics.Registry, exchanges []openrtb_ext.BidderName) *Metrics

NewBlankMetrics creates a new Metrics object with all blank metrics object. This may also be useful for testing routines to ensure that no metrics are written anywhere.

This will be useful when removing endpoints, we can just run will the blank metrics function rather than loading legacy metrics that never get filled. This will also eventually let us configure metrics, such as setting a limited set of metrics for a production instance, and then expanding again when we need more debugging.

func NewMetrics

func NewMetrics(registry metrics.Registry, exchanges []openrtb_ext.BidderName) *Metrics

NewMetrics creates a new Metrics object with needed metrics defined. In time we may develop to the point where Metrics contains all the metrics we might want to record, and then we build the actual metrics object to contain only the metrics we are interested in. This would allow for debug mode metrics. The code would allways try to record the metrics, but effectively noop if we are using a blank meter/timer.

func (*Metrics) RecordAdapterBidReceived

func (me *Metrics) RecordAdapterBidReceived(labels AdapterLabels, bidType openrtb_ext.BidType, hasAdm bool)

RecordAdapterBidReceived implements a part of the MetricsEngine interface. This tracks how many bids from each Bidder use `adm` vs. `nurl.

func (*Metrics) RecordAdapterPrice

func (me *Metrics) RecordAdapterPrice(labels AdapterLabels, cpm float64)

RecordAdapterPrice implements a part of the MetricsEngine interface. Generates a histogram of winning bid prices

func (*Metrics) RecordAdapterRequest

func (me *Metrics) RecordAdapterRequest(labels AdapterLabels)

RecordAdapterRequest implements a part of the MetricsEngine interface

func (*Metrics) RecordAdapterTime

func (me *Metrics) RecordAdapterTime(labels AdapterLabels, length time.Duration)

RecordAdapterTime implements a part of the MetricsEngine interface. Records the adapter response time

func (*Metrics) RecordConnectionAccept

func (me *Metrics) RecordConnectionAccept(success bool)

func (*Metrics) RecordConnectionClose

func (me *Metrics) RecordConnectionClose(success bool)

func (*Metrics) RecordCookieSync

func (me *Metrics) RecordCookieSync(labels Labels)

RecordCookieSync implements a part of the MetricsEngine interface. Records a cookie sync request

func (*Metrics) RecordImps

func (me *Metrics) RecordImps(labels Labels, numImps int)

func (*Metrics) RecordRequest

func (me *Metrics) RecordRequest(labels Labels)

RecordRequest implements a part of the MetricsEngine interface

func (*Metrics) RecordRequestTime

func (me *Metrics) RecordRequestTime(labels Labels, length time.Duration)

RecordRequestTime implements a part of the MetricsEngine interface. The calling code is responsible for determining the call duration.

func (*Metrics) RecordUserIDSet

func (me *Metrics) RecordUserIDSet(userLabels UserLabels)

RecordUserIDSet implements a part of the MetricsEngine interface. Records a cookie setuid request

type MetricsEngine

type MetricsEngine interface {
	RecordConnectionAccept(success bool)
	RecordConnectionClose(success bool)
	RecordRequest(labels Labels)                           // ignores adapter. only statusOk and statusErr fom status
	RecordImps(labels Labels, numImps int)                 // ignores adapter. only statusOk and statusErr fom status
	RecordRequestTime(labels Labels, length time.Duration) // ignores adapter. only statusOk and statusErr fom status
	RecordAdapterRequest(labels AdapterLabels)
	// This records whether or not a bid of a particular type uses `adm` or `nurl`.
	// Since the legacy endpoints don't have a bid type, it can only count bids from OpenRTB and AMP.
	RecordAdapterBidReceived(labels AdapterLabels, bidType openrtb_ext.BidType, hasAdm bool)
	RecordAdapterPrice(labels AdapterLabels, cpm float64)
	RecordAdapterTime(labels AdapterLabels, length time.Duration)
	RecordCookieSync(labels Labels)        // May ignore all labels
	RecordUserIDSet(userLabels UserLabels) // Function should verify bidder values
}

MetricsEngine is a generic interface to record PBS metrics into the desired backend The first three metrics function fire off once per incoming request, so total metrics will equal the total numer of incoming requests. The remaining 5 fire off per outgoing request to a bidder adapter, so will record a number of hits per incoming request. The two groups should be consistent within themselves, but comparing numbers between groups is generally not useful.

type RequestAction

type RequestAction string

RequestAction : The setuid request result

const (
	RequestActionSet    RequestAction = "set"
	RequestActionOptOut RequestAction = "opt_out"
	RequestActionGDPR   RequestAction = "gdpr"
	RequestActionErr    RequestAction = "err"
)

/setuid action labels

type RequestStatus

type RequestStatus string

RequestStatus : The request return status

const (
	RequestStatusOK         RequestStatus = "ok"
	RequestStatusBadInput   RequestStatus = "badinput"
	RequestStatusErr        RequestStatus = "err"
	RequestStatusNetworkErr RequestStatus = "networkerr"
)

Request/return status

func RequestStatuses

func RequestStatuses() []RequestStatus

type RequestType

type RequestType string

RequestType : Request type enumeration

const (
	ReqTypeLegacy   RequestType = "legacy"
	ReqTypeORTB2Web RequestType = "openrtb2-web"
	ReqTypeORTB2App RequestType = "openrtb2-app"
	ReqTypeAMP      RequestType = "amp"
)

The request types (endpoints)

func RequestTypes

func RequestTypes() []RequestType

type UserLabels

type UserLabels struct {
	Action RequestAction
	Bidder openrtb_ext.BidderName
}

UserLabels : Labels for /setuid endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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