Skip to content
Snippets Groups Projects
Commit 7eef76f2 authored by flycash's avatar flycash
Browse files

Add protocol.Result into Report method

parent f61c32d4
No related branches found
No related tags found
No related merge requests found
...@@ -42,5 +42,5 @@ func TestGetMetricReporter(t *testing.T) { ...@@ -42,5 +42,5 @@ func TestGetMetricReporter(t *testing.T) {
type mockReporter struct { type mockReporter struct {
} }
func (m mockReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration) { func (m mockReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) {
} }
...@@ -61,7 +61,7 @@ func (p *metricsFilter) Invoke(ctx context.Context, invoker protocol.Invoker, in ...@@ -61,7 +61,7 @@ func (p *metricsFilter) Invoke(ctx context.Context, invoker protocol.Invoker, in
duration := end.Sub(start) duration := end.Sub(start)
go func() { go func() {
for _, reporter := range p.reporters { for _, reporter := range p.reporters {
reporter.Report(ctx, invoker, invocation, duration) reporter.Report(ctx, invoker, invocation, duration, nil)
} }
}() }()
return res return res
......
...@@ -75,7 +75,7 @@ type mockReporter struct { ...@@ -75,7 +75,7 @@ type mockReporter struct {
wg sync.WaitGroup wg sync.WaitGroup
} }
func (m *mockReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration) { func (m *mockReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) {
m.Called(ctx, invoker, invocation) m.Called(ctx, invoker, invocation)
m.wg.Done() m.wg.Done()
} }
...@@ -73,7 +73,7 @@ type PrometheusReporter struct { ...@@ -73,7 +73,7 @@ type PrometheusReporter struct {
} }
// report the duration to Prometheus // report the duration to Prometheus
func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration) { func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) {
url := invoker.GetUrl() url := invoker.GetUrl()
var sumVec *prometheus.SummaryVec var sumVec *prometheus.SummaryVec
if isProvider(url) { if isProvider(url) {
......
...@@ -44,5 +44,5 @@ func TestPrometheusReporter_Report(t *testing.T) { ...@@ -44,5 +44,5 @@ func TestPrometheusReporter_Report(t *testing.T) {
inv := invocation.NewRPCInvocation("MethodName", []interface{}{"OK", "Hello"}, attach) inv := invocation.NewRPCInvocation("MethodName", []interface{}{"OK", "Hello"}, attach)
ctx := context.Background() ctx := context.Background()
reporter.Report(ctx, invoker, inv, 100*time.Millisecond) reporter.Report(ctx, invoker, inv, 100*time.Millisecond, nil)
} }
...@@ -31,5 +31,6 @@ const ( ...@@ -31,5 +31,6 @@ const (
// it will be use to report the invocation's duration // it will be use to report the invocation's duration
type Reporter interface { type Reporter interface {
// report the duration of an invocation // report the duration of an invocation
Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation,
cost time.Duration, res protocol.Result)
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment