From 941b8ad3922b784389680ccaf006bbfe5b1f919b Mon Sep 17 00:00:00 2001 From: gargidb <46933813+gargidb@users.noreply.github.com> Date: Fri, 17 Apr 2020 13:17:36 -0700 Subject: [PATCH] Caduceus edits (#198) * updated branch with changes * adding dropped events metrics --- CHANGELOG.md | 1 + outboundSender.go | 5 +++-- outboundSender_test.go | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c5a3c5..307b6e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] - pared down logging, especially debugging logs [#196](https://github.com/xmidt-org/caduceus/pull/196) +- added dropped events to metric [#195](https://github.com/xmidt-org/caduceus/issues/195) ## [v0.2.6] - reduced time from when cutoff is sent to when queue is emptied diff --git a/outboundSender.go b/outboundSender.go index a7f7b92b..dafd7f3e 100644 --- a/outboundSender.go +++ b/outboundSender.go @@ -1,5 +1,5 @@ /** - * Copyright 2017 Comcast Cable Communications Management, LLC + * Copyright 2020 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -437,8 +437,9 @@ func (obs *CaduceusOutboundSender) isValidTimeWindow(now, dropUntil, deliverUnti } func (obs *CaduceusOutboundSender) Empty() { - + cutoffMsgs := obs.queue.Load().(chan *wrp.Message) obs.queue.Store(make(chan *wrp.Message, obs.queueSize)) + obs.droppedCutoffCounter.Add(float64(len(cutoffMsgs))) obs.queueDepthGauge.Set(0.0) obs.queueEmpty = true diff --git a/outboundSender_test.go b/outboundSender_test.go index 08db2379..401fec83 100644 --- a/outboundSender_test.go +++ b/outboundSender_test.go @@ -1,5 +1,5 @@ /** - * Copyright 2017 Comcast Cable Communications Management, LLC + * Copyright 2020 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/go-kit/kit/log" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/xmidt-org/webpa-common/webhook" "github.com/xmidt-org/wrp-go/v2" @@ -123,7 +124,7 @@ func simpleFactorySetup(trans *transport, cutOffPeriod time.Duration, matcher [] fakeDroppedSlow.On("With", []string{"url", w.Config.URL, "reason", "expired_before_queueing"}).Return(fakeDroppedSlow) fakeDroppedSlow.On("With", []string{"url", w.Config.URL, "reason", "invalid_config"}).Return(fakeDroppedSlow) fakeDroppedSlow.On("With", []string{"url", w.Config.URL, "reason", "network_err"}).Return(fakeDroppedSlow) - fakeDroppedSlow.On("Add", 1.0).Return() + fakeDroppedSlow.On("Add", mock.Anything).Return() // IncomingContentType cases fakeContentType := new(mockCounter)