Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] update endpoints to separate intake from assets #1360

Merged
merged 4 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions beater/route_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,26 @@ import (
)

var (
rootURL = "/"
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"
rootURL = "/"

// intake v2
V2BackendURL = "/intake/v2/events"
V2RumURL = "/intake/v2/rum/events"

// assets
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 {
Expand All @@ -59,15 +65,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
6 changes: 4 additions & 2 deletions docs/sourcemap-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ 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/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
Expand All @@ -35,7 +37,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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect to have a note about the deprecated URL somewhere in the docs. It is going to be part of a minor release, we should avoid simply removing deprecated but supported URLS.

-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/v1/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