Skip to content

Commit

Permalink
caduceus: change content to content_type
Browse files Browse the repository at this point in the history
  • Loading branch information
githubsands committed May 14, 2019
1 parent 14877f7 commit a242e6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/caduceus/outboundSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess
body := payload
var payloadReader *bytes.Reader

obs.contentTypeCounter.With("content", strings.TrimLeft(msg.ContentType, "application/")).Add(1.0)
obs.contentTypeCounter.With("content_type", strings.TrimLeft(msg.ContentType, "application/")).Add(1.0)

// Use the internal content type unless the accept type is wrp
contentType := msg.ContentType
Expand Down Expand Up @@ -568,7 +568,7 @@ func (obs *CaduceusOutboundSender) queueOverflow() {
}

// record content type, json.
obs.contentTypeCounter.With("content", "json").Add(1.0)
obs.contentTypeCounter.With("content_type", "json").Add(1.0)
resp, err := obs.sender(req)
if nil != err {
// Failure
Expand Down
9 changes: 5 additions & 4 deletions src/caduceus/outboundSender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/go-kit/kit/log"
"github.com/stretchr/testify/assert"

//"github.com/stretchr/testify/mock"
"io"
"io/ioutil"
Expand Down Expand Up @@ -124,10 +125,10 @@ func simpleFactorySetup(trans *transport, cutOffPeriod time.Duration, matcher []

// IncomingContentType cases
fakeContentType := new(mockCounter)
fakeContentType.On("With", []string{"content", "msgpack"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content", "json"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content", "http"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content", "other"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content_type", "msgpack"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content_type", "json"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content_type", "http"}).Return(fakeContentType)
fakeContentType.On("With", []string{"content_type", "other"}).Return(fakeContentType)
fakeContentType.On("Add", 1.0).Return()

// QueueDepth case
Expand Down
8 changes: 4 additions & 4 deletions src/caduceus/senderWrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ func getFakeFactory() *SenderWrapperFactory {
On("With", []string{"event", "test/extra-stuff"}).Return(fakeIgnore).
On("With", []string{"event", "bob/magic/dog"}).Return(fakeIgnore).
On("With", []string{"event", "unknown"}).Return(fakeIgnore).
On("With", []string{"content", "msgpack"}).Return(fakeIgnore).
On("With", []string{"content", "json"}).Return(fakeIgnore).
On("With", []string{"content", "http"}).Return(fakeIgnore).
On("With", []string{"content", "other"}).Return(fakeIgnore)
On("With", []string{"content_type", "msgpack"}).Return(fakeIgnore).
On("With", []string{"content_type", "json"}).Return(fakeIgnore).
On("With", []string{"content_type", "http"}).Return(fakeIgnore).
On("With", []string{"content_type", "other"}).Return(fakeIgnore)

fakeRegistry := new(mockCaduceusMetricsRegistry)
fakeRegistry.On("NewCounter", DropsDueToInvalidPayload).Return(fakeDDTIP)
Expand Down

0 comments on commit a242e6d

Please sign in to comment.