Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Safari Metric #1571

Merged
merged 6 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions endpoints/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/golang/glog"
"github.com/julienschmidt/httprouter"
"github.com/mssola/user_agent"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/cache"
"github.com/prebid/prebid-server/config"
Expand Down Expand Up @@ -122,7 +121,6 @@ func (a *auction) auction(w http.ResponseWriter, r *http.Request, _ httprouter.P
RType: labels.RType,
Adapter: getAdapterValue(bidder),
PubID: labels.PubID,
Browser: labels.Browser,
CookieFlag: labels.CookieFlag,
AdapterBids: pbsmetrics.AdapterBidPresent,
}
Expand Down Expand Up @@ -365,22 +363,13 @@ func sortBidsAddKeywordsMobile(bids pbs.PBSBidSlice, pbs_req *pbs.PBSRequest, pr
}

func getDefaultLabels(r *http.Request) pbsmetrics.Labels {
rlabels := pbsmetrics.Labels{
return pbsmetrics.Labels{
Source: pbsmetrics.DemandUnknown,
RType: pbsmetrics.ReqTypeLegacy,
PubID: "",
Browser: pbsmetrics.BrowserOther,
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}

if ua := user_agent.New(r.Header.Get("User-Agent")); ua != nil {
name, _ := ua.Browser()
if name == "Safari" {
rlabels.Browser = pbsmetrics.BrowserSafari
}
}
return rlabels
}

func setLabelSource(labels *pbsmetrics.Labels, req *pbs.PBSRequest, status *string) {
Expand Down
1 change: 0 additions & 1 deletion endpoints/openrtb2/amp_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h
Source: pbsmetrics.DemandWeb,
RType: pbsmetrics.ReqTypeAMP,
PubID: pbsmetrics.PublisherUnknown,
Browser: getBrowserName(r),
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand Down
16 changes: 0 additions & 16 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/gofrs/uuid"
"github.com/golang/glog"
"github.com/julienschmidt/httprouter"
"github.com/mssola/user_agent"
"github.com/mxmCherry/openrtb"
"github.com/mxmCherry/openrtb/native"
nativeRequests "github.com/mxmCherry/openrtb/native/request"
Expand Down Expand Up @@ -115,7 +114,6 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
Source: pbsmetrics.DemandUnknown,
RType: pbsmetrics.ReqTypeORTB2Web,
PubID: pbsmetrics.PublisherUnknown,
Browser: getBrowserName(r),
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand Down Expand Up @@ -1271,20 +1269,6 @@ func parseUserID(cfg *config.Configuration, httpReq *http.Request) (string, bool
}
}

// getBrowserName checks if a request comes from a Safari browser.
// Returns pbsmetrics.BrowserSafari or pbsmetrics.BrowserOther
// depending on the value of the "User-Agent" header of our http.Request
func getBrowserName(r *http.Request) pbsmetrics.Browser {
var browser pbsmetrics.Browser = pbsmetrics.BrowserOther
if ua := user_agent.New(r.Header.Get("User-Agent")); ua != nil {
name, _ := ua.Browser()
if name == "Safari" {
browser = pbsmetrics.BrowserSafari
}
}
return browser
}

// Write(return) errors to the client, if any. Returns true if errors were found.
func writeError(errs []error, w http.ResponseWriter, labels *pbsmetrics.Labels) bool {
var rc bool = false
Expand Down
1 change: 0 additions & 1 deletion endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Re
Source: pbsmetrics.DemandUnknown,
RType: pbsmetrics.ReqTypeVideo,
PubID: pbsmetrics.PublisherUnknown,
Browser: getBrowserName(r),
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand Down
2 changes: 0 additions & 2 deletions endpoints/openrtb2/video_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ func TestHandleError(t *testing.T) {
Source: pbsmetrics.DemandUnknown,
RType: pbsmetrics.ReqTypeVideo,
PubID: pbsmetrics.PublisherUnknown,
Browser: "test browser",
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand Down Expand Up @@ -1028,7 +1027,6 @@ func TestHandleErrorDebugLog(t *testing.T) {
Source: pbsmetrics.DemandUnknown,
RType: pbsmetrics.ReqTypeVideo,
PubID: pbsmetrics.PublisherUnknown,
Browser: "test browser",
CookieFlag: pbsmetrics.CookieFlagUnknown,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand Down
1 change: 0 additions & 1 deletion exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ func TestPanicRecovery(t *testing.T) {
RType: pbsmetrics.ReqTypeORTB2Web,
Adapter: openrtb_ext.BidderAppnexus,
PubID: "test1",
Browser: pbsmetrics.BrowserSafari,
CookieFlag: pbsmetrics.CookieFlagYes,
AdapterBids: pbsmetrics.AdapterBidNone,
}
Expand Down
1 change: 0 additions & 1 deletion exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func splitBidRequest(req *openrtb.BidRequest,
RType: labels.RType,
Adapter: coreBidder,
PubID: labels.PubID,
Browser: labels.Browser,
CookieFlag: labels.CookieFlag,
AdapterBids: pbsmetrics.AdapterBidPresent,
}
Expand Down
7 changes: 0 additions & 7 deletions pbsmetrics/config/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func TestMultiMetricsEngine(t *testing.T) {
Source: pbsmetrics.DemandWeb,
RType: pbsmetrics.ReqTypeORTB2Web,
PubID: "test1",
Browser: pbsmetrics.BrowserSafari,
CookieFlag: pbsmetrics.CookieFlagYes,
RequestStatus: pbsmetrics.RequestStatusOK,
}
Expand All @@ -56,7 +55,6 @@ func TestMultiMetricsEngine(t *testing.T) {
RType: pbsmetrics.ReqTypeORTB2Web,
Adapter: openrtb_ext.BidderAppnexus,
PubID: "test1",
Browser: pbsmetrics.BrowserSafari,
CookieFlag: pbsmetrics.CookieFlagYes,
AdapterBids: pbsmetrics.AdapterBidNone,
}
Expand All @@ -65,7 +63,6 @@ func TestMultiMetricsEngine(t *testing.T) {
RType: pbsmetrics.ReqTypeORTB2Web,
Adapter: openrtb_ext.BidderPubmatic,
PubID: "test1",
Browser: pbsmetrics.BrowserSafari,
CookieFlag: pbsmetrics.CookieFlagYes,
AdapterBids: pbsmetrics.AdapterBidPresent,
}
Expand All @@ -92,15 +89,13 @@ func TestMultiMetricsEngine(t *testing.T) {
Source: pbsmetrics.DemandWeb,
RType: pbsmetrics.ReqTypeAMP,
PubID: "test2",
Browser: pbsmetrics.BrowserOther,
CookieFlag: pbsmetrics.CookieFlagYes,
RequestStatus: pbsmetrics.RequestStatusBlacklisted,
},
{
Source: pbsmetrics.DemandWeb,
RType: pbsmetrics.ReqTypeVideo,
PubID: "test2",
Browser: pbsmetrics.BrowserOther,
CookieFlag: pbsmetrics.CookieFlagYes,
RequestStatus: pbsmetrics.RequestStatusBlacklisted,
},
Expand Down Expand Up @@ -149,8 +144,6 @@ func TestMultiMetricsEngine(t *testing.T) {
VerifyMetrics(t, "ImpMeter", goEngine.ImpMeter.Count(), 8)
VerifyMetrics(t, "LegacyImpMeter", goEngine.LegacyImpMeter.Count(), 10)
VerifyMetrics(t, "NoCookieMeter", goEngine.NoCookieMeter.Count(), 0)
VerifyMetrics(t, "SafariRequestMeter", goEngine.SafariRequestMeter.Count(), 5)
VerifyMetrics(t, "SafariNoCookieMeter", goEngine.SafariNoCookieMeter.Count(), 0)
VerifyMetrics(t, "AdapterMetrics.Pubmatic.GotBidsMeter", goEngine.AdapterMetrics[openrtb_ext.BidderPubmatic].GotBidsMeter.Count(), 5)
VerifyMetrics(t, "AdapterMetrics.Pubmatic.NoBidMeter", goEngine.AdapterMetrics[openrtb_ext.BidderPubmatic].NoBidMeter.Count(), 0)
for _, err := range pbsmetrics.AdapterErrors() {
Expand Down
12 changes: 0 additions & 12 deletions pbsmetrics/go_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type Metrics struct {
LegacyImpMeter metrics.Meter
AppRequestMeter metrics.Meter
NoCookieMeter metrics.Meter
SafariRequestMeter metrics.Meter
SafariNoCookieMeter metrics.Meter
RequestTimer metrics.Timer
RequestsQueueTimer map[RequestType]map[bool]metrics.Timer
PrebidCacheRequestTimerSuccess metrics.Timer
Expand Down Expand Up @@ -127,8 +125,6 @@ func NewBlankMetrics(registry metrics.Registry, exchanges []openrtb_ext.BidderNa
LegacyImpMeter: blankMeter,
AppRequestMeter: blankMeter,
NoCookieMeter: blankMeter,
SafariRequestMeter: blankMeter,
SafariNoCookieMeter: blankMeter,
RequestTimer: blankTimer,
DNSLookupTimer: blankTimer,
RequestsQueueTimer: make(map[RequestType]map[bool]metrics.Timer),
Expand Down Expand Up @@ -227,10 +223,8 @@ func NewMetrics(registry metrics.Registry, exchanges []openrtb_ext.BidderName, d
newMetrics.ImpsTypeAudio = metrics.GetOrRegisterMeter("imp_audio", registry)
newMetrics.ImpsTypeNative = metrics.GetOrRegisterMeter("imp_native", registry)

newMetrics.SafariRequestMeter = metrics.GetOrRegisterMeter("safari_requests", registry)
newMetrics.NoCookieMeter = metrics.GetOrRegisterMeter("no_cookie_requests", registry)
newMetrics.AppRequestMeter = metrics.GetOrRegisterMeter("app_requests", registry)
newMetrics.SafariNoCookieMeter = metrics.GetOrRegisterMeter("safari_no_cookie_requests", registry)
newMetrics.RequestTimer = metrics.GetOrRegisterTimer("request_time", registry)
newMetrics.DNSLookupTimer = metrics.GetOrRegisterTimer("dns_lookup_time", registry)
newMetrics.PrebidCacheRequestTimerSuccess = metrics.GetOrRegisterTimer("prebid_cache_request_time.ok", registry)
Expand Down Expand Up @@ -410,12 +404,6 @@ func (me *Metrics) RecordRequest(labels Labels) {
if labels.Source == DemandApp {
me.AppRequestMeter.Mark(1)
} else {
if labels.Browser == BrowserSafari {
me.SafariRequestMeter.Mark(1)
if labels.CookieFlag == CookieFlagNo {
me.SafariNoCookieMeter.Mark(1)
}
}
if labels.CookieFlag == CookieFlagNo {
// NOTE: Old behavior was log me.AMPNoCookieMeter here for AMP requests.
// AMP is still new and OpenRTB does not do this, so changing to match
Expand Down
2 changes: 0 additions & 2 deletions pbsmetrics/go_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ func TestNewMetrics(t *testing.T) {

ensureContains(t, registry, "app_requests", m.AppRequestMeter)
ensureContains(t, registry, "no_cookie_requests", m.NoCookieMeter)
ensureContains(t, registry, "safari_requests", m.SafariRequestMeter)
ensureContains(t, registry, "safari_no_cookie_requests", m.SafariNoCookieMeter)
ensureContains(t, registry, "request_time", m.RequestTimer)
ensureContains(t, registry, "amp_no_cookie_requests", m.AmpNoCookieMeter)
ensureContainsAdapterMetrics(t, registry, "adapter.appnexus", m.AdapterMetrics["appnexus"])
Expand Down
18 changes: 0 additions & 18 deletions pbsmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Labels struct {
Source DemandSource
RType RequestType
PubID string // exchange specific ID, so we cannot compile in values
Browser Browser
CookieFlag CookieFlag
RequestStatus RequestStatus
}
Expand All @@ -22,7 +21,6 @@ type AdapterLabels struct {
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{}
Expand Down Expand Up @@ -116,9 +114,6 @@ type ImpMediaType string
// RequestType : Request type enumeration
type RequestType string

// Browser type enumeration
type Browser string

// CookieFlag : User ID cookie exists flag
type CookieFlag string

Expand Down Expand Up @@ -188,19 +183,6 @@ func ImpTypes() []ImpMediaType {
}
}

// Browser flag; at this point we only care about identifying Safari
const (
BrowserSafari Browser = "safari"
BrowserOther Browser = "other"
)

func BrowserTypes() []Browser {
return []Browser{
BrowserSafari,
BrowserOther,
}
}

// Cookie flag
const (
CookieFlagYes CookieFlag = "exists"
Expand Down