Skip to content

Commit 6dafb9e

Browse files
committed
fix formating
1 parent 5c093c2 commit 6dafb9e

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

systemtest/rum_test.go

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,27 @@ func TestRUMXForwardedFor(t *testing.T) {
5151
require.NoError(t, err)
5252
serverURL.Path = "/intake/v2/rum/events"
5353

54+
// Send one transaction and one set of breakdown metrics.
55+
// They should both have geoIP enrichment applied.
5456
const body = `{"metadata":{"service":{"name":"rum-js-test","agent":{"name":"rum-js","version":"5.5.0"}}}}
5557
{"transaction":{"trace_id":"611f4fa950f04631aaaaaaaaaaaaaaaa","id":"611f4fa950f04631","type":"page-load","duration":643,"span_count":{"started":0}}}
5658
{"metricset":{"samples":{"transaction.breakdown.count":{"value":12},"transaction.duration.sum.us":{"value":12},"transaction.duration.count":{"value":2},"transaction.self_time.sum.us":{"value":10},"transaction.self_time.count":{"value":2},"span.self_time.count":{"value":1},"span.self_time.sum.us":{"value":633.288}},"transaction":{"type":"request","name":"GET /"},"span":{"type":"external","subtype":"http"},"timestamp": 1496170422281000}}
5759
`
5860

59-
req, err := http.NewRequest("POST", serverURL.String(), strings.NewReader(body))
60-
require.NoError(t, err)
61-
61+
req, _ := http.NewRequest("POST", serverURL.String(), strings.NewReader(body))
6262
req.Header.Set("Content-Type", "application/x-ndjson")
63-
req.Header.Set("X-Forwarded-For", "220.244.41.16")
64-
63+
ipAddress := "220.244.41.16"
64+
req.Header.Set("X-Forwarded-For", ipAddress)
6565
resp, err := http.DefaultClient.Do(req)
6666
require.NoError(t, err)
67-
68-
_, err = io.ReadAll(resp.Body)
69-
require.NoError(t, err)
7067
require.Equal(t, http.StatusAccepted, resp.StatusCode)
71-
7268
io.Copy(io.Discard, resp.Body)
7369
resp.Body.Close()
7470

75-
idx := []string{
76-
"traces-apm*",
77-
"metrics-apm*",
78-
}
79-
80-
result := estest.ExpectMinDocs(t,
81-
systemtest.Elasticsearch,
82-
len(idx),
83-
strings.Join(idx, ","),
84-
espoll.TermsQuery{
85-
Field: "processor.event",
86-
Values: []any{"transaction", "metric"},
87-
},
88-
)
89-
90-
// Includes checking for absence of `tags` field.
71+
result := estest.ExpectMinDocs(t, systemtest.Elasticsearch, 2, "traces-apm*,metrics-apm*", espoll.TermsQuery{
72+
Field: "processor.event",
73+
Values: []interface{}{"transaction", "metric"},
74+
})
9175
approvaltest.ApproveFields(
9276
t, t.Name(), result.Hits.Hits,
9377
// RUM timestamps are set by the server based on the time the payload is received.

0 commit comments

Comments
 (0)