Skip to content

Commit

Permalink
Moved the constants to interceptor package
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <[email protected]>
  • Loading branch information
yashrsharma44 committed Jan 15, 2021
1 parent 60b2d64 commit d476f2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
7 changes: 7 additions & 0 deletions interceptors/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func (tm *DefaultTimer) ObserveDuration() time.Duration {

var EmptyTimer = &noOpTimer{}

type RPCMethod string

const (
Send RPCMethod = "send"
Receive RPCMethod = "recv"
)

const (
Unary GRPCType = "unary"
ClientStream GRPCType = "client_stream"
Expand Down
7 changes: 0 additions & 7 deletions providers/prometheus/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@ const (
KindClient Kind = "client"
KindServer Kind = "server"
)

type RPCMethod string

const (
Send RPCMethod = "send"
Receive RPCMethod = "recv"
)
4 changes: 2 additions & 2 deletions providers/prometheus/interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ func (r *reporter) StartTimeCall(startTime time.Time, callType string) intercept
switch r.kind {
case KindClient:
switch callType {
case string(Send):
case string(interceptors.Send):
if r.clientMetrics.clientStreamSendHistogramEnabled {
hist := r.clientMetrics.clientStreamSendHistogram.WithLabelValues(string(r.typ), r.service, r.method)
return prometheus.NewTimer(hist)
}
case string(Receive):
case string(interceptors.Receive):
if r.clientMetrics.clientStreamRecvHistogramEnabled {
hist := r.clientMetrics.clientStreamRecvHistogram.WithLabelValues(string(r.typ), r.service, r.method)
return prometheus.NewTimer(hist)
Expand Down
2 changes: 1 addition & 1 deletion providers/prometheus/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func FromError(err error) (s *status.Status, ok bool) {
return status.FromError(err)

// TODO: @yashrsharma - discuss if we require more error handling from the previous package
// TODO: @yashrsharma44 - discuss if we require more error handling from the previous package
}

// A CounterOption lets you add options to Counter metrics using With* funcs.
Expand Down

0 comments on commit d476f2f

Please sign in to comment.