Skip to content

Commit

Permalink
Use directly reporters
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Oct 11, 2018
1 parent 104054e commit af4f24f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions cmd/agent/app/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type Builder struct {
HTTPServer HTTPServerConfiguration `yaml:"httpServer"`
Metrics jmetrics.Builder `yaml:"metrics"`

collectorProxy []CollectorProxy
reporters []reporter.Reporter
}

// ProcessorConfiguration holds config for a processor that receives spans from Server
Expand All @@ -97,9 +97,9 @@ type HTTPServerConfiguration struct {
HostPort string `yaml:"hostPort" validate:"nonzero"`
}

// WithCollectorProxy adds auxiliary reporters.
func (b *Builder) WithCollectorProxy(r ...CollectorProxy) *Builder {
b.collectorProxy = append(b.collectorProxy, r...)
// WithReporter adds auxiliary reporters.
func (b *Builder) WithReporter(r ...reporter.Reporter) *Builder {
b.reporters = append(b.reporters, r...)
return b
}

Expand All @@ -115,13 +115,13 @@ func (b *Builder) CreateAgent(primaryProxy CollectorProxy, logger *zap.Logger, m
}

func (b *Builder) getReporter(primaryProxy CollectorProxy) reporter.Reporter {
if len(b.collectorProxy) == 0 {
if len(b.reporters) == 0 {
return primaryProxy.GetReporter()
}
rep := make([]reporter.Reporter, len(b.collectorProxy)+1)
rep := make([]reporter.Reporter, len(b.reporters)+1)
rep[0] = primaryProxy.GetReporter()
for i, p := range b.collectorProxy {
rep[i+1] = p.GetReporter()
for i, r := range b.reporters {
rep[i+1] = r
}
return reporter.NewMultiReporter(rep...)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestMultipleCollectorProxies(t *testing.T) {
b := Builder{}
ra := fakeCollectorProxy{}
rb := fakeCollectorProxy{}
b.WithCollectorProxy(ra)
b.WithReporter(ra)
r := b.getReporter(rb)
mr, ok := r.(reporter.MultiReporter)
require.True(t, ok)
Expand Down

0 comments on commit af4f24f

Please sign in to comment.