Skip to content

Commit

Permalink
removed the use of certain logging package functions (#199)
Browse files Browse the repository at this point in the history
* removed the use of certain logging package functions

* bumped webpa-common

* updated changelog, preparing for release
  • Loading branch information
kristinapathak authored Apr 20, 2020
1 parent 941b8ad commit 00ce0db
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.2.7]
- 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)
- removed all calls to logging.Debug(), logging.Info(), and logging.Error() [#199](https://github.com/xmidt-org/caduceus/pull/199)
- bumped webpa-common version to use a webhooks page without those logging calls [#199](https://github.com/xmidt-org/caduceus/pull/199)
- bumped webpa-common version includes a fix to authorization logging issue [#192](https://github.com/xmidt-org/caduceus/issues/192)

## [v0.2.6]
- reduced time from when cutoff is sent to when queue is emptied
Expand Down Expand Up @@ -84,7 +89,8 @@ fixed build upload
### Added
- Initial creation

[Unreleased]: https://github.com/Comcast/caduceus/compare/v0.2.6...HEAD
[Unreleased]: https://github.com/Comcast/caduceus/compare/v0.2.7...HEAD
[v0.2.7]: https://github.com/Comcast/caduceus/compare/v0.2.6...v0.2.7
[v0.2.6]: https://github.com/Comcast/caduceus/compare/v0.2.5...v0.2.6
[v0.2.5]: https://github.com/Comcast/caduceus/compare/v0.2.4...v0.2.5
[v0.2.4]: https://github.com/Comcast/caduceus/compare/v0.2.3...v0.2.4
Expand Down
3 changes: 2 additions & 1 deletion caduceus_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/kit/metrics"
"github.com/xmidt-org/webpa-common/logging"
"github.com/xmidt-org/wrp-go/v2"
Expand Down Expand Up @@ -62,7 +63,7 @@ type CaduceusHandler struct {
}

func (ch *CaduceusHandler) HandleRequest(workerID int, msg *wrp.Message) {
logging.Info(ch).Log("workerID", workerID, logging.MessageKey(), "Worker received a request, now passing"+
ch.Log(level.Key(), level.InfoValue(), "workerID", workerID, logging.MessageKey(), "Worker received a request, now passing"+
" to sender")

ch.senderWrapper.Queue(msg)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.6.1
github.com/stretchr/testify v1.3.0
github.com/xmidt-org/webpa-common v1.6.3
github.com/xmidt-org/webpa-common v1.8.1
github.com/xmidt-org/wrp-go/v2 v2.0.0
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
Expand Down
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/goph/emperror v0.17.1/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic=
github.com/goph/emperror v0.17.3-0.20190703203600-60a8d9faa17b/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
Expand Down Expand Up @@ -119,6 +120,7 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jtacoma/uritemplates v1.0.0 h1:xwx5sBF7pPAb0Uj8lDC1Q/aBPpOFyQza7OC705ZlLCo=
github.com/jtacoma/uritemplates v1.0.0/go.mod h1:IhIICdE9OcvgUnGwTtJxgBQ+VrTrti5PcbLVSJianO8=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=
Expand Down Expand Up @@ -192,6 +194,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
Expand Down Expand Up @@ -230,14 +233,13 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xmidt-org/bascule v0.8.0/go.mod h1:dPxlbNT3lCwYAtOq2zbzyzTEKgM+azLSbKKcVmgSHBY=
github.com/xmidt-org/webpa-common v1.1.0/go.mod h1:oCpKzOC+9h2vYHVzAU/06tDTQuBN4RZz+rhgIXptpOI=
github.com/xmidt-org/webpa-common v1.3.1/go.mod h1:oCpKzOC+9h2vYHVzAU/06tDTQuBN4RZz+rhgIXptpOI=
github.com/xmidt-org/webpa-common v1.3.2/go.mod h1:oCpKzOC+9h2vYHVzAU/06tDTQuBN4RZz+rhgIXptpOI=
github.com/xmidt-org/webpa-common v1.6.3 h1:sylHxzKvaJCFGEfEmpC0R+1w6DvkxZEraF/ywF+tElY=
github.com/xmidt-org/webpa-common v1.6.3/go.mod h1:PV4+42cjvL2hCj17Jb+Rnik9DszDG/DjHz8IT8e52ww=
github.com/xmidt-org/wrp-go v1.3.3 h1:WvODdrtxPwHEUqwfwHpu+kNUfBzLBfAIdrKCQjoCblc=
github.com/xmidt-org/wrp-go v1.3.3/go.mod h1:VOKYeeVWc2cyYmGWJksqUCV/lGzReRl0EP74y3mcWp0=
github.com/xmidt-org/webpa-common v1.8.1 h1:S4zHgLRqLmnZTHNKhYdtMDjAU0VP/3xjDYafxPtaOZk=
github.com/xmidt-org/webpa-common v1.8.1/go.mod h1:GADXfjZbfxZXYpGhV+VY2CaCxBVVn0KGxcnDgeSq48w=
github.com/xmidt-org/wrp-go/v2 v2.0.0 h1:5qWc3uZDQNxjunUqK9HMrWZcdCaTtUVCtR+SSYWSK6I=
github.com/xmidt-org/wrp-go/v2 v2.0.0/go.mod h1:v0HK0go/7OSVDvKbnXsUn6c+M987p0yyxWEs8/Fmf60=
github.com/xmidt-org/wrp-go/v3 v3.0.1 h1:E1FrFwWi21pFDL3c6M4ufqA4ykXWPops9BMnadChUH8=
github.com/xmidt-org/wrp-go/v3 v3.0.1/go.mod h1:08zAEevd+fM81/asCgsMJdgO8sfKLvqclqJGX1pphnE=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
Expand Down
7 changes: 4 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync/atomic"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/kit/metrics"
uuid "github.com/satori/go.uuid"
"github.com/xmidt-org/webpa-common/logging"
Expand All @@ -41,9 +42,9 @@ type ServerHandler struct {
}

func (sh *ServerHandler) ServeHTTP(response http.ResponseWriter, request *http.Request) {
debugLog := logging.Debug(sh.Logger)
infoLog := logging.Info(sh.Logger)
errorLog := logging.Error(sh.Logger)
debugLog := log.WithPrefix(sh.Logger, level.Key(), level.DebugValue())
infoLog := log.WithPrefix(sh.Logger, level.Key(), level.InfoValue())
errorLog := log.WithPrefix(sh.Logger, level.Key(), level.ErrorValue())
messageKey := logging.MessageKey()
errorKey := logging.ErrorKey()

Expand Down
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"runtime"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/xmidt-org/webpa-common/service/servicecfg"

Expand Down Expand Up @@ -68,9 +69,9 @@ func caduceus(arguments []string) int {
// if we're done, we're exiting no matter what
if parseErr != nil {
friendlyError := fmt.Sprintf("failed to parse arguments. detailed error: %s", parseErr)
logging.Error(logger).Log(
logging.ErrorKey(),
friendlyError)
logger.Log(
level.Key(), level.ErrorValue(),
logging.ErrorKey(), friendlyError)
os.Exit(1)
}
os.Exit(0)
Expand All @@ -82,9 +83,9 @@ func caduceus(arguments []string) int {
}

var (
infoLog = logging.Info(logger)
errorLog = logging.Error(logger)
debugLog = logging.Debug(logger)
infoLog = log.WithPrefix(logger, level.Key(), level.InfoValue())
errorLog = log.WithPrefix(logger, level.Key(), level.ErrorValue())
debugLog = log.WithPrefix(logger, level.Key(), level.DebugValue())
)

infoLog.Log("configurationFile", v.ConfigFileUsed())
Expand Down
13 changes: 7 additions & 6 deletions outboundSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/kit/metrics"
"github.com/xmidt-org/webpa-common/device"
"github.com/xmidt-org/webpa-common/logging"
Expand Down Expand Up @@ -267,7 +268,7 @@ func (obs *CaduceusOutboundSender) Update(wh webhook.W) (err error) {
for i := 0; i < urlCount; i++ {
_, err = url.Parse(wh.Config.AlternativeURLs[i])
if err != nil {
logging.Error(obs.logger).Log(logging.MessageKey(), "failed to update url",
obs.logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "failed to update url",
"url", wh.Config.AlternativeURLs[i], logging.ErrorKey(), err)
return
}
Expand Down Expand Up @@ -501,7 +502,7 @@ func (obs *CaduceusOutboundSender) send(urls *ring.Ring, secret, acceptType stri
defer func() {
if r := recover(); nil != r {
obs.droppedPanic.Add(1.0)
logging.Error(obs.logger).Log(logging.MessageKey(), "goroutine send() panicked",
obs.logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "goroutine send() panicked",
"id", obs.id, "panic", r)
}
obs.workers.Release()
Expand Down Expand Up @@ -532,7 +533,7 @@ func (obs *CaduceusOutboundSender) send(urls *ring.Ring, secret, acceptType stri
if nil != err {
// Report drop
obs.droppedInvalidConfig.Add(1.0)
logging.Error(obs.logger).Log(logging.MessageKey(), "Invalid URL",
obs.logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "Invalid URL",
"url", urls.Value.(string), "id", obs.id, logging.ErrorKey(), err)
return
}
Expand Down Expand Up @@ -580,7 +581,7 @@ func (obs *CaduceusOutboundSender) send(urls *ring.Ring, secret, acceptType stri
urls = urls.Next()
tmp, err := url.Parse(urls.Value.(string))
if err != nil {
logging.Error(obs.logger).Log(logging.MessageKey(), "failed to update url",
obs.logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "failed to update url",
"url", urls.Value.(string), logging.ErrorKey(), err)
return
}
Expand Down Expand Up @@ -623,7 +624,7 @@ func (obs *CaduceusOutboundSender) queueOverflow() {
obs.mutex.Unlock()

var (
errorLog = logging.Error(obs.logger)
errorLog = log.WithPrefix(obs.logger, level.Key(), level.ErrorValue())
)

obs.cutOffCounter.Add(1.0)
Expand All @@ -632,7 +633,7 @@ func (obs *CaduceusOutboundSender) queueOverflow() {

msg, err := json.Marshal(failureMsg)
if nil != err {
errorLog.Log(logging.MessageKey(), "Cut-off notification json.Marshall failed", "failureMessage", obs.failureMsg,
errorLog.Log(logging.MessageKey(), "Cut-off notification json.Marshal failed", "failureMessage", obs.failureMsg,
"for", obs.id, logging.ErrorKey(), err)
return
}
Expand Down

0 comments on commit 00ce0db

Please sign in to comment.