diff --git a/internal/loadgen/eventhandler/apm.go b/internal/loadgen/eventhandler/apm.go index fb00072..445e03b 100644 --- a/internal/loadgen/eventhandler/apm.go +++ b/internal/loadgen/eventhandler/apm.go @@ -18,8 +18,8 @@ func NewAPM(config Config) (i.Handler, error) { return New(config, &APMEventCollector{}) } -// APM sends the contents of a reader to a remote APM Server. -type APM struct { +// APMTransport sends the contents of a reader to a remote APMTransport Server. +type APMTransport struct { client *http.Client intakeHeaders http.Header intakeV2URL string @@ -35,7 +35,7 @@ func NewAPMTransport(c *http.Client, srvURL, token, apiKey string, headers map[s for name, header := range headers { intakeHeaders.Set(name, header) } - return &APM{ + return &APMTransport{ client: c, intakeV2URL: srvURL + `/intake/v2/events`, intakeHeaders: intakeHeaders, @@ -43,7 +43,7 @@ func NewAPMTransport(c *http.Client, srvURL, token, apiKey string, headers map[s } // SendEvents sends the reader contents to `/intake/v2/events` as a batch. -func (t *APM) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) error { +func (t *APMTransport) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) error { req, err := http.NewRequestWithContext(ctx, "POST", t.intakeV2URL, r) if err != nil { return err @@ -55,7 +55,7 @@ func (t *APM) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) erro return t.sendEvents(req, r, ignoreErrs) } -func (t *APM) sendEvents(req *http.Request, r io.Reader, ignoreErrs bool) error { +func (t *APMTransport) sendEvents(req *http.Request, r io.Reader, ignoreErrs bool) error { res, err := t.client.Do(req) if err != nil { return err diff --git a/internal/loadgen/eventhandler/handler_test.go b/internal/loadgen/eventhandler/handler_test.go index b8d8256..92b2f0d 100644 --- a/internal/loadgen/eventhandler/handler_test.go +++ b/internal/loadgen/eventhandler/handler_test.go @@ -170,7 +170,7 @@ func TestHandlerNew(t *testing.T) { t.Run("success-matches-files", func(t *testing.T) { h, err := New(Config{ Path: `*.ndjson`, - Transport: &APM{}, + Transport: &APMTransport{}, Storage: storage, Writer: writeAPMEvents, }, &APMEventCollector{}) @@ -180,7 +180,7 @@ func TestHandlerNew(t *testing.T) { t.Run("failure-matches-no-files", func(t *testing.T) { h, err := New(Config{ Path: `go*.ndjson`, - Transport: &APM{}, + Transport: &APMTransport{}, Storage: storage, Writer: writeAPMEvents, }, &APMEventCollector{}) @@ -190,7 +190,7 @@ func TestHandlerNew(t *testing.T) { t.Run("failure-invalid-glob", func(t *testing.T) { h, err := New(Config{ Path: "", - Transport: &APM{}, + Transport: &APMTransport{}, Storage: storage, Writer: writeAPMEvents, }, &APMEventCollector{}) @@ -201,7 +201,7 @@ func TestHandlerNew(t *testing.T) { storage := os.DirFS(filepath.Join("testdata", "intake-v3")) h, err := New(Config{ Path: `*.ndjson`, - Transport: &APM{}, + Transport: &APMTransport{}, Storage: storage, Writer: writeAPMEvents, }, &APMEventCollector{}) diff --git a/internal/loadgen/eventhandler/otlp.go b/internal/loadgen/eventhandler/otlp.go index a3c60e6..7b7a3c8 100644 --- a/internal/loadgen/eventhandler/otlp.go +++ b/internal/loadgen/eventhandler/otlp.go @@ -13,13 +13,13 @@ import ( "github.com/elastic/apm-perf/internal/loadgen/i" ) -type OTLP struct { +type OTLPTransport struct { client *http.Client headers http.Header url string } -func (o *OTLP) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) error { +func (o *OTLPTransport) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) error { req, err := http.NewRequestWithContext(ctx, "POST", o.url, r) if err != nil { return err @@ -44,7 +44,7 @@ func (o *OTLP) SendEvents(ctx context.Context, r io.Reader, ignoreErrs bool) err return nil } -func newOTLPTransport(c *http.Client, srvURL, u, apiKey string, headers map[string]string) *OTLP { +func newOTLPTransport(c *http.Client, srvURL, u, apiKey string, headers map[string]string) *OTLPTransport { h := make(http.Header) h.Set("Content-Encoding", "deflate") h.Set("Content-Type", "application/x-ndjson") @@ -55,7 +55,7 @@ func newOTLPTransport(c *http.Client, srvURL, u, apiKey string, headers map[stri h.Set(name, header) } - return &OTLP{ + return &OTLPTransport{ client: c, url: srvURL + u, headers: h,