From 36c913ff779a217af1dcee870bc2eda65774226d Mon Sep 17 00:00:00 2001 From: Juan A Date: Fri, 13 Oct 2017 12:26:58 +0200 Subject: [PATCH 1/2] add config switch to enable/disable frontend endpoints --- Makefile | 1 - beater/beater_test.go | 3 - beater/handlers.go | 57 +++++++++++++------ beater/server_test.go | 10 ++-- include/list.go | 13 ----- main.go | 2 - processor/error/benchmark_test.go | 4 +- processor/error/package_tests/fields_test.go | 4 +- .../error/package_tests/processor_test.go | 4 +- processor/error/processor.go | 24 ++------ processor/error/processor_test.go | 21 ++----- processor/healthcheck/processor.go | 9 --- processor/healthcheck/processor_test.go | 6 -- processor/processor.go | 1 - processor/registry.go | 34 ----------- processor/transaction/benchmark_test.go | 4 +- .../transaction/package_tests/fields_test.go | 2 +- .../package_tests/processor_test.go | 4 +- processor/transaction/processor.go | 28 ++------- processor/transaction/processor_test.go | 21 ++----- script/generate_imports.py | 45 --------------- script/output_data/output_data.go | 11 ++-- 22 files changed, 75 insertions(+), 233 deletions(-) delete mode 100644 include/list.go delete mode 100644 processor/registry.go delete mode 100644 script/generate_imports.py diff --git a/Makefile b/Makefile index 7ef2bfd7c24..f641cedb773 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,6 @@ collect: imports fields go-generate create-docs notice imports: @mkdir -p include @mkdir -p processor - @python ${GOPATH}/src/${BEAT_PATH}/script/generate_imports.py ${BEAT_PATH} > include/list.go .PHONY: fields fields: diff --git a/beater/beater_test.go b/beater/beater_test.go index fec5310a452..6557bc6c8b1 100644 --- a/beater/beater_test.go +++ b/beater/beater_test.go @@ -8,9 +8,6 @@ import ( "net/http/httptest" "testing" - // make sure processors are loaded - _ "github.com/elastic/apm-server/include" - "github.com/elastic/apm-server/tests" "github.com/elastic/beats/libbeat/beat" "github.com/elastic/beats/libbeat/monitoring" diff --git a/beater/handlers.go b/beater/handlers.go index d7c85792a3e..15ba0363dc4 100644 --- a/beater/handlers.go +++ b/beater/handlers.go @@ -17,10 +17,28 @@ import ( "crypto/subtle" + err "github.com/elastic/apm-server/processor/error" + "github.com/elastic/apm-server/processor/healthcheck" + "github.com/elastic/apm-server/processor/transaction" "github.com/elastic/beats/libbeat/monitoring" ) -type processorHandler func(processor.Processor, Config, reporter) http.Handler +const ( + BackendTransactionsURL = "/v1/transactions" + FrontendTransactionsURL = "/v1/client-side/transactions" + BackendErrorsURL = "/v1/errors" + FrontendErrorsURL = "/v1/client-side/errors" + HealthCheckURL = "/healthcheck" +) + +type ProcessorFactory func() processor.Processor + +type ProcessorHandler func(ProcessorFactory, Config, reporter) http.Handler + +type routeMapping struct { + ProcessorHandler + ProcessorFactory +} var ( serverMetrics = monitoring.Default.NewRegistry("apm-server.server") @@ -32,38 +50,39 @@ var ( errForbidden = errors.New("forbidden request") errPOSTRequestOnly = errors.New("only POST requests are supported") - handlerMap = map[int]processorHandler{ - processor.Backend: backendHandler, - processor.Frontend: frontendHandler, - processor.HealthCheck: healthCheckHandler, + Routes = map[string]routeMapping{ + BackendTransactionsURL: {backendHandler, transaction.NewProcessor}, + FrontendTransactionsURL: {frontendHandler, transaction.NewProcessor}, + BackendErrorsURL: {backendHandler, err.NewProcessor}, + FrontendErrorsURL: {frontendHandler, err.NewProcessor}, + HealthCheckURL: {healthCheckHandler, healthcheck.NewProcessor}, } ) func newMuxer(config Config, report reporter) *http.ServeMux { mux := http.NewServeMux() - for path, p := range processor.Registry.Processors() { - handler := handlerMap[p.Type()] + for path, mapping := range Routes { logp.Info("Path %s added to request handler", path) - mux.Handle(path, handler(p, config, report)) + mux.Handle(path, mapping.ProcessorHandler(mapping.ProcessorFactory, config, report)) } return mux } -func backendHandler(p processor.Processor, config Config, report reporter) http.Handler { +func backendHandler(pf ProcessorFactory, config Config, report reporter) http.Handler { return logHandler( authHandler(config.SecretToken, - processRequestHandler(p, config, report))) + processRequestHandler(pf, config, report))) } -func frontendHandler(p processor.Processor, config Config, report reporter) http.Handler { +func frontendHandler(pf ProcessorFactory, config Config, report reporter) http.Handler { return logHandler( frontendSwitchHandler(config.EnableFrontend, - processRequestHandler(p, config, report))) + processRequestHandler(pf, config, report))) } -func healthCheckHandler(_ processor.Processor, _ Config, _ reporter) http.Handler { +func healthCheckHandler(_ ProcessorFactory, _ Config, _ reporter) http.Handler { return logHandler( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { sendStatus(w, r, 200, nil) @@ -114,14 +133,16 @@ func isAuthorized(req *http.Request, secretToken string) bool { return subtle.ConstantTimeCompare([]byte(parts[1]), []byte(secretToken)) == 1 } -func processRequestHandler(p processor.Processor, config Config, report reporter) http.Handler { +func processRequestHandler(pf ProcessorFactory, config Config, report reporter) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - code, err := processRequest(r, p, config.MaxUnzippedSize, report) + code, err := processRequest(r, pf, config.MaxUnzippedSize, report) sendStatus(w, r, code, err) }) } -func processRequest(r *http.Request, p processor.Processor, maxSize int64, report reporter) (int, error) { +func processRequest(r *http.Request, pf ProcessorFactory, maxSize int64, report reporter) (int, error) { + + processor := pf() if r.Method != "POST" { return 405, errPOSTRequestOnly @@ -142,11 +163,11 @@ func processRequest(r *http.Request, p processor.Processor, maxSize int64, repor } - if err = p.Validate(buf); err != nil { + if err = processor.Validate(buf); err != nil { return 400, err } - list, err := p.Transform(buf) + list, err := processor.Transform(buf) if err != nil { return 400, err } diff --git a/beater/server_test.go b/beater/server_test.go index b4553fe4f65..6d3787c4968 100644 --- a/beater/server_test.go +++ b/beater/server_test.go @@ -16,8 +16,6 @@ import ( "github.com/kabukky/httpscerts" "github.com/stretchr/testify/assert" - "github.com/elastic/apm-server/processor/healthcheck" - "github.com/elastic/apm-server/processor/transaction" "github.com/elastic/apm-server/tests" "github.com/elastic/beats/libbeat/beat" ) @@ -56,7 +54,7 @@ func TestServerHealth(t *testing.T) { apm, teardown := setupServer(t, noSSL) defer teardown() - req, err := http.NewRequest("GET", healthcheck.Endpoint, nil) + req, err := http.NewRequest("GET", HealthCheckURL, nil) if err != nil { t.Fatalf("Failed to create test request object: %v", err) } @@ -70,7 +68,7 @@ func TestServerFrontendSwitch(t *testing.T) { apm, teardown := setupServer(t, noSSL) defer teardown() - req, _ := http.NewRequest("POST", transaction.FrontendEndpoint, bytes.NewReader(testData)) + req, _ := http.NewRequest("POST", FrontendTransactionsURL, bytes.NewReader(testData)) rec := httptest.NewRecorder() apm.Handler.ServeHTTP(rec, req) @@ -182,7 +180,7 @@ func withSSL(t *testing.T, domain string) *SSLConfig { } func makeTestRequest(t *testing.T) *http.Request { - req, err := http.NewRequest("POST", transaction.BackendEndpoint, bytes.NewReader(testData)) + req, err := http.NewRequest("POST", BackendTransactionsURL, bytes.NewReader(testData)) if err != nil { t.Fatalf("Failed to create test request object: %v", err) } @@ -195,7 +193,7 @@ func postTestRequest(t *testing.T, apm *http.Server, client *http.Client, schema client = http.DefaultClient } - addr := fmt.Sprintf("%s://%s%s", schema, apm.Addr, transaction.BackendEndpoint) + addr := fmt.Sprintf("%s://%s%s", schema, apm.Addr, BackendTransactionsURL) return client.Post(addr, "application/json", bytes.NewReader(testData)) } diff --git a/include/list.go b/include/list.go deleted file mode 100644 index a15f974c9df..00000000000 --- a/include/list.go +++ /dev/null @@ -1,13 +0,0 @@ -/* -Package include imports all processor packages so that they register with the global -registry. This package can be imported in the main package to automatically register -all of the standard supported apm-server processors. -*/ -package include - -import ( - // This list is automatically generated by `make imports` - _ "github.com/elastic/apm-server/processor/error" - _ "github.com/elastic/apm-server/processor/healthcheck" - _ "github.com/elastic/apm-server/processor/transaction" -) diff --git a/main.go b/main.go index 8d7502ec848..145d49e94ed 100644 --- a/main.go +++ b/main.go @@ -7,8 +7,6 @@ import ( "os" "github.com/elastic/apm-server/cmd" - - _ "github.com/elastic/apm-server/include" ) func main() { diff --git a/processor/error/benchmark_test.go b/processor/error/benchmark_test.go index 9e49b2a659c..0716b68e0f4 100644 --- a/processor/error/benchmark_test.go +++ b/processor/error/benchmark_test.go @@ -7,7 +7,7 @@ import ( ) func BenchmarkEventWithFileLoading(b *testing.B) { - processor := NewBackendProcessor() + processor := NewProcessor() for i := 0; i < b.N; i++ { data, _ := tests.LoadValidData("error") err := processor.Validate(data) @@ -20,7 +20,7 @@ func BenchmarkEventWithFileLoading(b *testing.B) { } func BenchmarkEventFileLoadingOnce(b *testing.B) { - processor := NewBackendProcessor() + processor := NewProcessor() data, _ := tests.LoadValidData("error") for i := 0; i < b.N; i++ { err := processor.Validate(data) diff --git a/processor/error/package_tests/fields_test.go b/processor/error/package_tests/fields_test.go index 2d5070863a2..8c87164ab92 100644 --- a/processor/error/package_tests/fields_test.go +++ b/processor/error/package_tests/fields_test.go @@ -14,7 +14,7 @@ func TestFields(t *testing.T) { "./../../../_meta/fields.common.yml", "./../_meta/fields.yml", } - tests.TestEventAttrsDocumentedInFields(t, fieldsPaths, er.NewBackendProcessor) + tests.TestEventAttrsDocumentedInFields(t, fieldsPaths, er.NewProcessor) notInEvent := set.New( "context.db.instance", @@ -26,5 +26,5 @@ func TestFields(t *testing.T) { "error id icon", "view errors", ) - tests.TestDocumentedFieldsInEvent(t, fieldsPaths, er.NewBackendProcessor, notInEvent) + tests.TestDocumentedFieldsInEvent(t, fieldsPaths, er.NewProcessor, notInEvent) } diff --git a/processor/error/package_tests/processor_test.go b/processor/error/package_tests/processor_test.go index 16b3fb049b8..de20d9fc37c 100644 --- a/processor/error/package_tests/processor_test.go +++ b/processor/error/package_tests/processor_test.go @@ -16,13 +16,13 @@ func TestProcessorOK(t *testing.T) { {Name: "TestProcessErrorMininmalPayloadLog", Path: "tests/data/valid/error/minimal_payload_log.json"}, {Name: "TestProcessErrorFull", Path: "tests/data/valid/error/payload.json"}, } - tests.TestProcessRequests(t, er.NewBackendProcessor(), requestInfo) + tests.TestProcessRequests(t, er.NewProcessor(), requestInfo) } // ensure invalid documents fail the json schema validation already func TestProcessorFailedValidation(t *testing.T) { data, err := tests.LoadInvalidData("error") assert.Nil(t, err) - err = er.NewBackendProcessor().Validate(data) + err = er.NewProcessor().Validate(data) assert.NotNil(t, err) } diff --git a/processor/error/processor.go b/processor/error/processor.go index 0ace84fe66f..89e163b96e9 100644 --- a/processor/error/processor.go +++ b/processor/error/processor.go @@ -10,11 +10,6 @@ import ( "github.com/elastic/beats/libbeat/monitoring" ) -func init() { - pr.Registry.AddProcessor(BackendEndpoint, NewBackendProcessor()) - pr.Registry.AddProcessor(FrontendEndpoint, NewFrontendProcessor()) -} - var ( errorMetrics = monitoring.Default.NewRegistry("apm-server.processor.error") validationCount = monitoring.NewInt(errorMetrics, "validation.count") @@ -23,24 +18,17 @@ var ( ) const ( - BackendEndpoint = "/v1/errors" - FrontendEndpoint = "/v1/client-side/errors" - processorName = "error" + processorName = "error" ) -func NewBackendProcessor() pr.Processor { - schema := pr.CreateSchema(errorSchema, processorName) - return &processor{schema, pr.Backend} -} +var schema = pr.CreateSchema(errorSchema, processorName) -func NewFrontendProcessor() pr.Processor { - schema := pr.CreateSchema(errorSchema, processorName) - return &processor{schema, pr.Frontend} +func NewProcessor() pr.Processor { + return &processor{schema} } type processor struct { schema *jsonschema.Schema - typ int } func (p *processor) Validate(buf []byte) error { @@ -66,7 +54,3 @@ func (p *processor) Transform(buf []byte) ([]beat.Event, error) { func (p *processor) Name() string { return processorName } - -func (p *processor) Type() int { - return p.typ -} diff --git a/processor/error/processor_test.go b/processor/error/processor_test.go index 8f6ca26f46d..20708db9a04 100644 --- a/processor/error/processor_test.go +++ b/processor/error/processor_test.go @@ -9,22 +9,9 @@ import ( ) func TestImplementProcessorInterface(t *testing.T) { - constructors := []func() pr.Processor{NewFrontendProcessor, NewBackendProcessor} - for _, constructor := range constructors { - p := constructor() - assert.NotNil(t, p) - _, ok := p.(pr.Processor) - assert.True(t, ok) - assert.IsType(t, &processor{}, p) - } -} - -func TestAddProcessorToRegistryOnInit(t *testing.T) { - p := pr.Registry.Processor(BackendEndpoint) + p := NewProcessor() assert.NotNil(t, p) - assert.Equal(t, pr.Backend, p.Type()) - - p2 := pr.Registry.Processor(FrontendEndpoint) - assert.NotNil(t, p2) - assert.Equal(t, pr.Frontend, p2.Type()) + _, ok := p.(pr.Processor) + assert.True(t, ok) + assert.IsType(t, &processor{}, p) } diff --git a/processor/healthcheck/processor.go b/processor/healthcheck/processor.go index a04854707e4..b2aea0bdce7 100644 --- a/processor/healthcheck/processor.go +++ b/processor/healthcheck/processor.go @@ -5,12 +5,7 @@ import ( "github.com/elastic/beats/libbeat/beat" ) -func init() { - pr.Registry.AddProcessor(Endpoint, NewProcessor()) -} - const ( - Endpoint = "/healthcheck" processorName = "healthcheck" ) @@ -31,7 +26,3 @@ func (p *processor) Transform(buf []byte) ([]beat.Event, error) { func (p *processor) Name() string { return processorName } - -func (p *processor) Type() int { - return pr.HealthCheck -} diff --git a/processor/healthcheck/processor_test.go b/processor/healthcheck/processor_test.go index 4bde1a4ee6f..108aede3ed0 100644 --- a/processor/healthcheck/processor_test.go +++ b/processor/healthcheck/processor_test.go @@ -15,9 +15,3 @@ func TestImplementProcessorInterface(t *testing.T) { assert.True(t, ok) assert.IsType(t, &processor{}, p) } - -func TestAddProcessorToRegistryOnInit(t *testing.T) { - p := pr.Registry.Processor(Endpoint) - assert.NotNil(t, p) - assert.Equal(t, pr.HealthCheck, p.Type()) -} diff --git a/processor/processor.go b/processor/processor.go index 16270334b74..90dad9bb4be 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -20,7 +20,6 @@ type Processor interface { Validate([]byte) error Transform([]byte) ([]beat.Event, error) Name() string - Type() int } func CreateDoc(timestamp time.Time, docMappings []m.DocMapping) beat.Event { diff --git a/processor/registry.go b/processor/registry.go deleted file mode 100644 index d09d2d25b06..00000000000 --- a/processor/registry.go +++ /dev/null @@ -1,34 +0,0 @@ -package processor - -import ( - "github.com/elastic/beats/libbeat/logp" -) - -type Register struct { - processors map[string]Processor -} - -// Registry is a global registry that contains all processors -var Registry = newRegister() - -// NewRegister creates a new register for the processors -func newRegister() *Register { - return &Register{ - processors: map[string]Processor{}, - } -} - -// AddProcessor adds a processor listening on the given path -func (r *Register) AddProcessor(path string, p Processor) { - logp.Info("Processor for path registered: %s", path) - r.processors[path] = p -} - -// GetProcessors returns a list of all currently registered processors -func (r *Register) Processors() map[string]Processor { - return r.processors -} - -func (r *Register) Processor(name string) Processor { - return r.processors[name] -} diff --git a/processor/transaction/benchmark_test.go b/processor/transaction/benchmark_test.go index baa5e5400d2..499b35e75d4 100644 --- a/processor/transaction/benchmark_test.go +++ b/processor/transaction/benchmark_test.go @@ -7,7 +7,7 @@ import ( ) func BenchmarkWithFileLoading(b *testing.B) { - processor := NewBackendProcessor() + processor := NewProcessor() for i := 0; i < b.N; i++ { data, _ := tests.LoadValidData("transaction") err := processor.Validate(data) @@ -19,7 +19,7 @@ func BenchmarkWithFileLoading(b *testing.B) { } func BenchmarkTransactionFileLoadingOnce(b *testing.B) { - processor := NewBackendProcessor() + processor := NewProcessor() data, _ := tests.LoadValidData("transaction") for i := 0; i < b.N; i++ { err := processor.Validate(data) diff --git a/processor/transaction/package_tests/fields_test.go b/processor/transaction/package_tests/fields_test.go index 84fe8055f19..89fe0a28f1e 100644 --- a/processor/transaction/package_tests/fields_test.go +++ b/processor/transaction/package_tests/fields_test.go @@ -14,7 +14,7 @@ func TestEsDocumentation(t *testing.T) { "./../../../_meta/fields.common.yml", "./../_meta/fields.yml", } - processorFn := transaction.NewBackendProcessor + processorFn := transaction.NewProcessor tests.TestEventAttrsDocumentedInFields(t, fieldsPaths, processorFn) tests.TestDocumentedFieldsInEvent(t, fieldsPaths, processorFn, set.New("listening", "view traces")) } diff --git a/processor/transaction/package_tests/processor_test.go b/processor/transaction/package_tests/processor_test.go index 6417faa8cfd..0f610018632 100644 --- a/processor/transaction/package_tests/processor_test.go +++ b/processor/transaction/package_tests/processor_test.go @@ -18,14 +18,14 @@ func TestTransactionProcessorOK(t *testing.T) { {Name: "TestProcessTransactionEmpty", Path: "tests/data/valid/transaction/transaction_empty_values.json"}, {Name: "TestProcessTransactionNull", Path: "tests/data/valid/transaction/transaction_null_values.json"}, } - tests.TestProcessRequests(t, transaction.NewBackendProcessor(), requestInfo) + tests.TestProcessRequests(t, transaction.NewProcessor(), requestInfo) } // ensure invalid documents fail the json schema validation already func TestTransactionProcessorValidationFailed(t *testing.T) { data, err := tests.LoadInvalidData("transaction") assert.Nil(t, err) - p := transaction.NewBackendProcessor() + p := transaction.NewProcessor() err = p.Validate(data) assert.NotNil(t, err) } diff --git a/processor/transaction/processor.go b/processor/transaction/processor.go index 30dcfe2f193..92936bab305 100644 --- a/processor/transaction/processor.go +++ b/processor/transaction/processor.go @@ -10,11 +10,6 @@ import ( "github.com/santhosh-tekuri/jsonschema" ) -func init() { - pr.Registry.AddProcessor(BackendEndpoint, NewBackendProcessor()) - pr.Registry.AddProcessor(FrontendEndpoint, NewFrontendProcessor()) -} - var ( transactionMetrics = monitoring.Default.NewRegistry("apm-server.processor.transaction") transformations = monitoring.NewInt(transactionMetrics, "transformations") @@ -23,28 +18,17 @@ var ( ) const ( - BackendEndpoint = "/v1/transactions" - FrontendEndpoint = "/v1/client-side/transactions" - processorName = "transaction" + processorName = "transaction" ) -func NewBackendProcessor() pr.Processor { - return &processor{ - schema: pr.CreateSchema(transactionSchema, processorName), - typ: pr.Backend, - } -} +var schema = pr.CreateSchema(transactionSchema, processorName) -func NewFrontendProcessor() pr.Processor { - return &processor{ - schema: pr.CreateSchema(transactionSchema, processorName), - typ: pr.Frontend, - } +func NewProcessor() pr.Processor { + return &processor{schema: schema} } type processor struct { schema *jsonschema.Schema - typ int } func (p *processor) Validate(buf []byte) error { @@ -70,7 +54,3 @@ func (p *processor) Transform(buf []byte) ([]beat.Event, error) { func (p *processor) Name() string { return processorName } - -func (p *processor) Type() int { - return p.typ -} diff --git a/processor/transaction/processor_test.go b/processor/transaction/processor_test.go index 1a52c8cae79..a8dade9c08d 100644 --- a/processor/transaction/processor_test.go +++ b/processor/transaction/processor_test.go @@ -9,22 +9,9 @@ import ( ) func TestImplementProcessorInterface(t *testing.T) { - constructors := []func() pr.Processor{NewFrontendProcessor, NewBackendProcessor} - for _, constructor := range constructors { - p := constructor() - assert.NotNil(t, p) - _, ok := p.(pr.Processor) - assert.True(t, ok) - assert.IsType(t, &processor{}, p) - } -} - -func TestAddProcessorToRegistryOnInit(t *testing.T) { - p := pr.Registry.Processor(BackendEndpoint) + p := NewProcessor() assert.NotNil(t, p) - assert.Equal(t, pr.Backend, p.Type()) - - p2 := pr.Registry.Processor(FrontendEndpoint) - assert.NotNil(t, p2) - assert.Equal(t, pr.Frontend, p2.Type()) + _, ok := p.(pr.Processor) + assert.True(t, ok) + assert.IsType(t, &processor{}, p) } diff --git a/script/generate_imports.py b/script/generate_imports.py deleted file mode 100644 index 2b11a44cfe1..00000000000 --- a/script/generate_imports.py +++ /dev/null @@ -1,45 +0,0 @@ -import os -import sys - -# Generates the file list.go with all processors - -header = """/* -Package include imports all processor packages so that they register with the global -registry. This package can be imported in the main package to automatically register -all of the standard supported apm-server processors. -*/ -package include - -import ( -\t// This list is automatically generated by `make imports` -""" - - -def generate(go_beat_path): - - base_dir = "processor" - path = os.path.abspath("processor") - list_file = header - - # Fetch all protocols - for protocol in sorted(os.listdir(base_dir)): - if protocol == "model": - continue - - if os.path.isfile(path + "/" + protocol): - continue - - list_file += ' _ "' + go_beat_path + '/processor/' + protocol + '"\n' - - list_file += ")" - - # output string so it can be concatenated - print(list_file) - - -if __name__ == "__main__": - # First argument is the beat path under GOPATH. - # (e.g. github.com/elastic/beats/packetbeat) - go_beat_path = sys.argv[1] - - generate(go_beat_path) diff --git a/script/output_data/output_data.go b/script/output_data/output_data.go index c7a07e54d37..ab2eacf88c6 100644 --- a/script/output_data/output_data.go +++ b/script/output_data/output_data.go @@ -7,8 +7,7 @@ import ( "os" "path/filepath" - _ "github.com/elastic/apm-server/include" - "github.com/elastic/apm-server/processor" + "github.com/elastic/apm-server/beater" ) func main() { @@ -25,16 +24,16 @@ func generate() error { basepath := "tests/data/valid" outputPath := "docs/data/elasticsearch/" - processors := processor.Registry.Processors() - var checked = map[string]struct{}{} - for _, p := range processors { + for path, mapping := range beater.Routes { - if p.Type() == processor.HealthCheck { + if path == beater.HealthCheckURL { continue } + p := mapping.ProcessorFactory() + // Remove version from name and and s at the end name := p.Name() From d52756e327dd77949275fdacbb116662531fecb1 Mon Sep 17 00:00:00 2001 From: Juan A Date: Wed, 11 Oct 2017 16:04:02 +0200 Subject: [PATCH 2/2] Register processors centrally, so that processor "configuration" / metadata like endpoint and handlers can be all in one place. This also removes the workarounds with blank identifier imports, and instantiates one processor per request to avoid harmful state