Skip to content

Commit

Permalink
Merge "[FAB-12804] reorder labels in statsd format"
Browse files Browse the repository at this point in the history
  • Loading branch information
sykesm authored and Gerrit Code Review committed Nov 30, 2018
2 parents 9e87079 + 84b9d6c commit 9039499
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions core/ledger/util/couchdb/couchdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ func (couchInstance *CouchInstance) handleRequest(method, dbName, functionName s
var resp *http.Response
var errResp error
couchDBReturn := &DBReturn{}
defer couchInstance.recordMetric(time.Now(), dbName, couchDBReturn, functionName)
defer couchInstance.recordMetric(time.Now(), dbName, functionName, couchDBReturn)

//set initial wait duration for retries
waitDuration := retryWaitTime * time.Millisecond
Expand Down Expand Up @@ -1834,8 +1834,8 @@ func (couchInstance *CouchInstance) handleRequest(method, dbName, functionName s
return resp, couchDBReturn, nil
}

func (ci *CouchInstance) recordMetric(startTime time.Time, connectURL string, couchDBReturn *DBReturn, api string) {
ci.stats.observeProcessingTime(startTime, connectURL, strconv.Itoa(couchDBReturn.StatusCode), api)
func (ci *CouchInstance) recordMetric(startTime time.Time, dbName, api string, couchDBReturn *DBReturn) {
ci.stats.observeProcessingTime(startTime, dbName, api, strconv.Itoa(couchDBReturn.StatusCode))
}

//invalidCouchDBResponse checks to make sure either a valid response or error is returned
Expand Down
8 changes: 4 additions & 4 deletions core/ledger/util/couchdb/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var (
Namespace: "couchdb",
Subsystem: "",
Name: "processing_time",
LabelNames: []string{"database", "result", "function_name"},
StatsdFormat: "%{#fqname}.%{database}.%{result}.%{function_name}",
LabelNames: []string{"database", "function_name", "result"},
StatsdFormat: "%{#fqname}.%{database}.%{function_name}.%{result}",
}
)

Expand All @@ -31,10 +31,10 @@ func newStats(metricsProvider metrics.Provider) *stats {
}
}

func (s *stats) observeProcessingTime(startTime time.Time, dbName, result, functionName string) {
func (s *stats) observeProcessingTime(startTime time.Time, dbName, functionName, result string) {
s.apiProcessingTime.With(
"database", dbName,
"result", result,
"function_name", functionName,
"result", result,
).Observe(time.Since(startTime).Seconds())
}
2 changes: 1 addition & 1 deletion core/ledger/util/couchdb/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAPIProcessTimeMetric(t *testing.T) {
gt.Expect(fakeHistogram.ObserveArgsForCall(0)).NotTo(BeZero())
gt.Expect(fakeHistogram.WithArgsForCall(0)).To(Equal([]string{
"database", "db_name",
"result", "0",
"function_name", "function_name",
"result", "0",
}))
}

0 comments on commit 9039499

Please sign in to comment.