From cffc3573a7bb193b01d9efd7e4082b604dff9d37 Mon Sep 17 00:00:00 2001 From: Ron cohen Date: Thu, 6 Sep 2018 12:06:54 +0200 Subject: [PATCH 1/4] update endpoints to separate intake from assets Closes https://github.com/elastic/apm-server/issues/1336. --- beater/route_config.go | 39 +++++++++++++++++++++-------------- beater/v2_handler_test.go | 8 +++---- docs/sourcemap-api.asciidoc | 4 ++-- tests/system/apmserver.py | 2 +- tests/system/test_access.py | 2 +- tests/system/test_requests.py | 2 +- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/beater/route_config.go b/beater/route_config.go index ffbab716a1a..80845d6a27a 100644 --- a/beater/route_config.go +++ b/beater/route_config.go @@ -36,7 +36,10 @@ import ( ) var ( - rootURL = "/" + rootURL = "/" + HealthCheckURL = "/healthcheck" + + // intake v1 BackendTransactionsURL = "/v1/transactions" ClientSideTransactionsURL = "/v1/client-side/transactions" RumTransactionsURL = "/v1/rum/transactions" @@ -44,12 +47,17 @@ var ( ClientSideErrorsURL = "/v1/client-side/errors" RumErrorsURL = "/v1/rum/errors" MetricsURL = "/v1/metrics" - SourcemapsClientSideURL = "/v1/client-side/sourcemaps" - SourcemapsURL = "/v1/rum/sourcemaps" - V2BackendURL = "/v2/intake" - V2RumURL = "/v2/rum/intake" - HealthCheckURL = "/healthcheck" + // intake v2 + V2BackendURL = "/intake/v2/events" + V2RumURL = "/intake/v2/rum/events" + + // assets + SourcemapsURL = "/assets/v2/sourcemaps" + + // deprecated + SourcemapsClientSideURLDeprecated = "/v1/client-side/sourcemaps" + SourcemapsURLDeprecated = "/v1/rum/sourcemaps" ) type routeType struct { @@ -59,15 +67,16 @@ type routeType struct { } var V1Routes = map[string]v1Route{ - BackendTransactionsURL: {backendRouteType, transaction.Processor, v1RequestDecoder}, - ClientSideTransactionsURL: {rumRouteType, transaction.Processor, v1RequestDecoder}, - RumTransactionsURL: {rumRouteType, transaction.Processor, v1RequestDecoder}, - BackendErrorsURL: {backendRouteType, perr.Processor, v1RequestDecoder}, - ClientSideErrorsURL: {rumRouteType, perr.Processor, v1RequestDecoder}, - RumErrorsURL: {rumRouteType, perr.Processor, v1RequestDecoder}, - MetricsURL: {metricsRouteType, metric.Processor, v1RequestDecoder}, - SourcemapsClientSideURL: {sourcemapRouteType, sourcemap.Processor, sourcemapUploadDecoder}, - SourcemapsURL: {sourcemapRouteType, sourcemap.Processor, sourcemapUploadDecoder}, + BackendTransactionsURL: {backendRouteType, transaction.Processor, v1RequestDecoder}, + ClientSideTransactionsURL: {rumRouteType, transaction.Processor, v1RequestDecoder}, + RumTransactionsURL: {rumRouteType, transaction.Processor, v1RequestDecoder}, + BackendErrorsURL: {backendRouteType, perr.Processor, v1RequestDecoder}, + ClientSideErrorsURL: {rumRouteType, perr.Processor, v1RequestDecoder}, + RumErrorsURL: {rumRouteType, perr.Processor, v1RequestDecoder}, + MetricsURL: {metricsRouteType, metric.Processor, v1RequestDecoder}, + SourcemapsURL: {sourcemapRouteType, sourcemap.Processor, sourcemapUploadDecoder}, + SourcemapsClientSideURLDeprecated: {sourcemapRouteType, sourcemap.Processor, sourcemapUploadDecoder}, + SourcemapsURLDeprecated: {sourcemapRouteType, sourcemap.Processor, sourcemapUploadDecoder}, } var V2Routes = map[string]v2Route{ diff --git a/beater/v2_handler_test.go b/beater/v2_handler_test.go index 1854b84aae3..916dc67280f 100644 --- a/beater/v2_handler_test.go +++ b/beater/v2_handler_test.go @@ -37,7 +37,7 @@ import ( ) func TestInvalidContentType(t *testing.T) { - req := httptest.NewRequest("POST", "/v2/intake", nil) + req := httptest.NewRequest("POST", V2BackendURL, nil) w := httptest.NewRecorder() c := defaultConfig("7.0.0") @@ -49,7 +49,7 @@ func TestInvalidContentType(t *testing.T) { } func TestEmptyRequest(t *testing.T) { - req := httptest.NewRequest("POST", "/v2/intake", nil) + req := httptest.NewRequest("POST", V2BackendURL, nil) req.Header.Add("Content-Type", "application/x-ndjson") w := httptest.NewRecorder() @@ -63,7 +63,7 @@ func TestEmptyRequest(t *testing.T) { } func TestRequestDecoderError(t *testing.T) { - req := httptest.NewRequest("POST", "/v2/intake", bytes.NewBufferString(`asdasd`)) + req := httptest.NewRequest("POST", V2BackendURL, bytes.NewBufferString(`asdasd`)) req.Header.Add("Content-Type", "application/x-ndjson") w := httptest.NewRecorder() @@ -111,7 +111,7 @@ func TestRequestIntegration(t *testing.T) { require.NoError(t, err) bodyReader := bytes.NewBuffer(b) - req := httptest.NewRequest("POST", "/v2/intake", bodyReader) + req := httptest.NewRequest("POST", V2BackendURL, bodyReader) req.Header.Add("Content-Type", "application/x-ndjson") w := httptest.NewRecorder() diff --git a/docs/sourcemap-api.asciidoc b/docs/sourcemap-api.asciidoc index f69d647ad75..0139174ed88 100644 --- a/docs/sourcemap-api.asciidoc +++ b/docs/sourcemap-api.asciidoc @@ -10,7 +10,7 @@ Send a `HTTP POST` request with the `Content-Type` header set to `multipart/form [source,bash] ------------------------------------------------------------ -http(s)://{hostname}:{port}/v1/rum/sourcemaps +http(s)://{hostname}:{port}/assets/v2/sourcemaps ------------------------------------------------------------ [[sourcemap-request-fields]] @@ -35,7 +35,7 @@ Example source map request ["source","sh",subs="attributes"] --------------------------------------------------------------------------- -curl -X POST http://127.0.0.1:8200/v1/rum/sourcemaps \ +curl -X POST http://127.0.0.1:8200/assets/v1/sourcemaps \ -F service_name="test-service" \ -F service_version="1.0" \ -F bundle_filepath="http://localhost/static/js/bundle.js" \ diff --git a/tests/system/apmserver.py b/tests/system/apmserver.py index 07211ebf029..98cce937af4 100644 --- a/tests/system/apmserver.py +++ b/tests/system/apmserver.py @@ -274,7 +274,7 @@ def check_for_no_smap(self, doc): class ClientSideBaseTest(ServerBaseTest): transactions_url = 'http://localhost:8200/v1/rum/transactions' errors_url = 'http://localhost:8200/v1/rum/errors' - sourcemap_url = 'http://localhost:8200/v1/rum/sourcemaps' + sourcemap_url = 'http://localhost:8200/assets/v2/sourcemaps' @classmethod def setUpClass(cls): diff --git a/tests/system/test_access.py b/tests/system/test_access.py index 93e114379a6..273f4f221ab 100644 --- a/tests/system/test_access.py +++ b/tests/system/test_access.py @@ -38,7 +38,7 @@ def test_with_token_v2(self): Test that access works with token """ - url = 'http://localhost:8200/v2/intake' + url = 'http://localhost:8200/intake/v2/events' transactions = self.get_transaction_v2_payload() headers = {'content-type': 'application/x-ndjson'} diff --git a/tests/system/test_requests.py b/tests/system/test_requests.py index 24e6d4aa417..a65cb2b298d 100644 --- a/tests/system/test_requests.py +++ b/tests/system/test_requests.py @@ -66,7 +66,7 @@ def test_rum_default_disabled(self): 'http://localhost:8200/v1/client-side/transactions', json=transactions) assert r.status_code == 403, r.status_code - def test_rum_default_disabled(self): + def test_rum_default_disabled_2(self): transactions = self.get_transaction_payload() r = requests.post( 'http://localhost:8200/v1/rum/transactions', json=transactions) From 20d00ee08fd7feff29cad72544c3f673a88a826c Mon Sep 17 00:00:00 2001 From: Ron cohen Date: Mon, 10 Sep 2018 14:08:39 +0200 Subject: [PATCH 2/4] Update url config --- beater/route_config.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/beater/route_config.go b/beater/route_config.go index 80845d6a27a..6682e83deed 100644 --- a/beater/route_config.go +++ b/beater/route_config.go @@ -36,28 +36,26 @@ import ( ) var ( - rootURL = "/" - HealthCheckURL = "/healthcheck" - - // intake v1 - BackendTransactionsURL = "/v1/transactions" - ClientSideTransactionsURL = "/v1/client-side/transactions" - RumTransactionsURL = "/v1/rum/transactions" - BackendErrorsURL = "/v1/errors" - ClientSideErrorsURL = "/v1/client-side/errors" - RumErrorsURL = "/v1/rum/errors" - MetricsURL = "/v1/metrics" + rootURL = "/" // intake v2 V2BackendURL = "/intake/v2/events" V2RumURL = "/intake/v2/rum/events" // assets - SourcemapsURL = "/assets/v2/sourcemaps" + SourcemapsURL = "/assets/v1/sourcemaps" // deprecated SourcemapsClientSideURLDeprecated = "/v1/client-side/sourcemaps" SourcemapsURLDeprecated = "/v1/rum/sourcemaps" + BackendTransactionsURL = "/v1/transactions" + ClientSideTransactionsURL = "/v1/client-side/transactions" + RumTransactionsURL = "/v1/rum/transactions" + BackendErrorsURL = "/v1/errors" + ClientSideErrorsURL = "/v1/client-side/errors" + RumErrorsURL = "/v1/rum/errors" + MetricsURL = "/v1/metrics" + HealthCheckURL = "/healthcheck" ) type routeType struct { From e650642e7a5e8976d0573d57d51fa13e57981210 Mon Sep 17 00:00:00 2001 From: Ron cohen Date: Mon, 10 Sep 2018 14:09:57 +0200 Subject: [PATCH 3/4] Update sourcemap tests for /assets/v1/sourcemaps --- docs/sourcemap-api.asciidoc | 2 +- tests/system/apmserver.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sourcemap-api.asciidoc b/docs/sourcemap-api.asciidoc index 0139174ed88..1744cac5784 100644 --- a/docs/sourcemap-api.asciidoc +++ b/docs/sourcemap-api.asciidoc @@ -10,7 +10,7 @@ Send a `HTTP POST` request with the `Content-Type` header set to `multipart/form [source,bash] ------------------------------------------------------------ -http(s)://{hostname}:{port}/assets/v2/sourcemaps +http(s)://{hostname}:{port}/assets/v1/sourcemaps ------------------------------------------------------------ [[sourcemap-request-fields]] diff --git a/tests/system/apmserver.py b/tests/system/apmserver.py index 98cce937af4..511450a6e92 100644 --- a/tests/system/apmserver.py +++ b/tests/system/apmserver.py @@ -274,7 +274,7 @@ def check_for_no_smap(self, doc): class ClientSideBaseTest(ServerBaseTest): transactions_url = 'http://localhost:8200/v1/rum/transactions' errors_url = 'http://localhost:8200/v1/rum/errors' - sourcemap_url = 'http://localhost:8200/assets/v2/sourcemaps' + sourcemap_url = 'http://localhost:8200/assets/v1/sourcemaps' @classmethod def setUpClass(cls): From edb5aa3428286a4ff910f7ae41865d3701235da9 Mon Sep 17 00:00:00 2001 From: Ron cohen Date: Wed, 12 Sep 2018 15:32:00 +0200 Subject: [PATCH 4/4] adds deprecation notice --- docs/sourcemap-api.asciidoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sourcemap-api.asciidoc b/docs/sourcemap-api.asciidoc index 1744cac5784..74eaa8d8aa6 100644 --- a/docs/sourcemap-api.asciidoc +++ b/docs/sourcemap-api.asciidoc @@ -13,6 +13,8 @@ Send a `HTTP POST` request with the `Content-Type` header set to `multipart/form http(s)://{hostname}:{port}/assets/v1/sourcemaps ------------------------------------------------------------ +NOTE: The URL for uploading sourcemaps was previously `/v1/sourcemaps`. It still works, but is being deprecated in favor of `/assets/v1/sourcemaps`. + [[sourcemap-request-fields]] [float] ==== Request Fields