Skip to content

Commit

Permalink
update endpoints to separate intake from assets
Browse files Browse the repository at this point in the history
Closes elastic#1336.
  • Loading branch information
Ron cohen committed Sep 6, 2018
1 parent 77989a5 commit cffc357
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
39 changes: 24 additions & 15 deletions beater/route_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,28 @@ import (
)

var (
rootURL = "/"
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"
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 {
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions beater/v2_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions docs/sourcemap-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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" \
Expand Down
2 changes: 1 addition & 1 deletion tests/system/apmserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}

Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cffc357

Please sign in to comment.