-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FABC-785] Add metrics for server APIs
Added rate, error, and duration metrics for server APIs Change-Id: Ia7ec7860ac4b8b177d49f84e1290000b53a67813 Signed-off-by: Saad Karim <skarim@us.ibm.com>
- Loading branch information
Saad Karim
committed
Jan 16, 2019
1 parent
6fc2cf5
commit 3e4b58b
Showing
18 changed files
with
1,834 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package metrics | ||
|
||
import "github.com/hyperledger/fabric/common/metrics" | ||
|
||
var ( | ||
// APICounterOpts define the counter opts for server APIs | ||
APICounterOpts = metrics.CounterOpts{ | ||
Namespace: "api_request", | ||
Subsystem: "", | ||
Name: "count", | ||
Help: "Number of requests made to an API", | ||
LabelNames: []string{"ca_name", "api_name", "status_code"}, | ||
StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}", | ||
} | ||
|
||
// APIDurationOpts define the duration opts for server APIs | ||
APIDurationOpts = metrics.HistogramOpts{ | ||
Namespace: "api_request", | ||
Subsystem: "", | ||
Name: "duration", | ||
Help: "Time taken in seconds for the request to an API to be completed", | ||
LabelNames: []string{"ca_name", "api_name", "status_code"}, | ||
StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}", | ||
} | ||
) | ||
|
||
// Metrics are the metrics tracked by server | ||
type Metrics struct { | ||
// APICounter keeps track of number of times an API endpoint is called | ||
APICounter metrics.Counter | ||
// APIDuration keeps track of time taken for request to complete for an API | ||
APIDuration metrics.Histogram | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.