Skip to content

Commit 97458ce

Browse files
marclopmergify-bot
authored andcommitted
Add transaction.name mapping to logs-apm.error (#6912)
Adds the missing mapping for `transaction.name` to `logs-apm.error`. (cherry picked from commit 43850ef)
1 parent 2d1c270 commit 97458ce

File tree

6 files changed

+201
-1
lines changed

6 files changed

+201
-1
lines changed

apmpackage/apm/data_stream/error_logs/fields/fields.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@
220220
type: boolean
221221
description: |
222222
Transactions that are 'sampled' will include all available information. Transactions that are not sampled will not have spans or context.
223+
- name: name
224+
type: keyword
225+
description: |
226+
Keyword of designation of a transaction in the scope of a single service, eg: 'GET /users/:id'.
223227
- name: type
224228
type: keyword
225229
description: |

beater/test_approved_es_documents/TestPublishIntegrationErrors.approved.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@
840840
},
841841
"transaction": {
842842
"id": "1234567890987654",
843+
"name": "mytx",
843844
"sampled": true,
844845
"type": "request"
845846
},

processor/stream/test_approved_es_documents/testIntakeIntegrationErrors.approved.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@
771771
},
772772
"transaction": {
773773
"id": "1234567890987654",
774+
"name": "mytx",
774775
"sampled": true,
775776
"type": "request"
776777
},
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{
2+
"events": [
3+
{
4+
"@timestamp": "2018-08-09T15:04:05.999Z",
5+
"agent": {
6+
"ephemeral_id": "abcdef123",
7+
"name": "elastic-node",
8+
"version": "3.14.0"
9+
},
10+
"cloud": {
11+
"account": {
12+
"id": "account_id",
13+
"name": "account_name"
14+
},
15+
"availability_zone": "cloud_availability_zone",
16+
"instance": {
17+
"id": "instance_id",
18+
"name": "instance_name"
19+
},
20+
"machine": {
21+
"type": "machine_type"
22+
},
23+
"project": {
24+
"id": "project_id",
25+
"name": "project_name"
26+
},
27+
"provider": "cloud_provider",
28+
"region": "cloud_region",
29+
"service": {
30+
"name": "lambda"
31+
}
32+
},
33+
"container": {
34+
"id": "container-id"
35+
},
36+
"data_stream.dataset": "apm.error",
37+
"data_stream.namespace": "default",
38+
"data_stream.type": "logs",
39+
"ecs": {
40+
"version": "dynamic"
41+
},
42+
"error": {
43+
"grouping_key": "d6b3f958dfea98dc9ed2b57d5f0c48bb",
44+
"grouping_name": "Cannot read property 'baz' of undefined",
45+
"id": "abcdef0123456789",
46+
"log": {
47+
"level": "custom log level",
48+
"message": "Cannot read property 'baz' of undefined"
49+
}
50+
},
51+
"event": {
52+
"agent_id_status": "missing",
53+
"ingested": "dynamic"
54+
},
55+
"host": {
56+
"architecture": "x64",
57+
"hostname": "node-name",
58+
"ip": [
59+
"127.0.0.1"
60+
],
61+
"name": "prod.example",
62+
"os": {
63+
"platform": "darwin"
64+
}
65+
},
66+
"kubernetes": {
67+
"namespace": "namespace1",
68+
"node": {
69+
"name": "node-name"
70+
},
71+
"pod": {
72+
"name": "pod-name",
73+
"uid": "pod-uid"
74+
}
75+
},
76+
"message": "Cannot read property 'baz' of undefined",
77+
"observer": {
78+
"ephemeral_id": "dynamic",
79+
"hostname": "dynamic",
80+
"id": "dynamic",
81+
"type": "apm-server",
82+
"version": "dynamic",
83+
"version_major": "dynamic"
84+
},
85+
"parent": {
86+
"id": "9632587410abcdef"
87+
},
88+
"process": {
89+
"args": [
90+
"node",
91+
"server.js"
92+
],
93+
"pid": 1234,
94+
"ppid": 6789,
95+
"title": "node"
96+
},
97+
"processor": {
98+
"event": "error",
99+
"name": "error"
100+
},
101+
"service": {
102+
"environment": "staging",
103+
"framework": {
104+
"name": "Express",
105+
"version": "1.2.3"
106+
},
107+
"language": {
108+
"name": "ecmascript",
109+
"version": "8"
110+
},
111+
"name": "1234_service-12a3",
112+
"node": {
113+
"name": "node-abc"
114+
},
115+
"runtime": {
116+
"name": "node",
117+
"version": "8.0.0"
118+
},
119+
"version": "5.1.3"
120+
},
121+
"timestamp": {
122+
"us": 1533827045999000
123+
},
124+
"trace": {
125+
"id": "0123456789abcdeffedcba0123456789"
126+
},
127+
"transaction": {
128+
"id": "1234567890987654",
129+
"name": "mytx",
130+
"sampled": true,
131+
"type": "request"
132+
},
133+
"user": {
134+
"domain": "ldap://abc",
135+
"email": "[email protected]",
136+
"id": "123",
137+
"name": "bar"
138+
}
139+
}
140+
]
141+
}

systemtest/errors_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package systemtest_test
19+
20+
import (
21+
"bytes"
22+
"io/ioutil"
23+
"net/http"
24+
"testing"
25+
26+
"github.com/stretchr/testify/assert"
27+
"github.com/stretchr/testify/require"
28+
29+
"github.com/elastic/apm-server/systemtest"
30+
"github.com/elastic/apm-server/systemtest/apmservertest"
31+
"github.com/elastic/apm-server/systemtest/estest"
32+
)
33+
34+
func TestErrorIngest(t *testing.T) {
35+
systemtest.CleanupElasticsearch(t)
36+
srv := apmservertest.NewServer(t)
37+
38+
// TODO(marclop): Update APM go agent to the latest to test this.
39+
events, err := ioutil.ReadFile("../testdata/intake-v2/errors.ndjson")
40+
require.NoError(t, err)
41+
42+
req, _ := http.NewRequest("POST", srv.URL+"/intake/v2/events", bytes.NewReader(events))
43+
req.Header.Set("Content-Type", "application/x-ndjson")
44+
resp, err := http.DefaultClient.Do(req)
45+
require.NoError(t, err)
46+
defer resp.Body.Close()
47+
assert.Equal(t, http.StatusAccepted, resp.StatusCode)
48+
49+
result := systemtest.Elasticsearch.ExpectDocs(t, "logs-apm.error*", estest.ExistsQuery{
50+
Field: "transaction.name",
51+
})
52+
systemtest.ApproveEvents(t, t.Name(), result.Hits.Hits)
53+
}

testdata/intake-v2/errors.ndjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
{"error": {"id": "xFoaabb123FFFFFF", "timestamp": 1533826745999000,"log": {"message": "no user found", "stacktrace": [{"classname": "User::Special"}]}}}
44
{"error": {"id": "cdefab0123456789", "trace_id": null, "timestamp": 1533826745999000,"exception": {"message": "Cannot read property 'baz' no defined"}}}
55
{"error": {"id": "cdefab0123456780", "trace_id": "0123456789abcdeffedcba0123456789", "parent_id": "9632587410abcdef", "exception": {"type": "DbError"}, "context":{"service": {"name": "service1", "environment":"testing","language": {"version": "2.5", "name": "ruby"}, "agent": {"version": "2.1.3", "name": "elastic-ruby", "ephemeral_id":"justanid"}, "framework": {"version": "5.0", "name": "Rails"}, "version": "2", "runtime": {"version": "2.5", "name": "cruby"}}}}}
6-
{"error": {"id": "abcdef0123456789", "trace_id": "0123456789abcdeffedcba0123456789", "parent_id": "9632587410abcdef", "transaction_id": "1234567890987654", "transaction": { "sampled": true, "type": "request"}, "timestamp": 1533827045999000,"log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}}
6+
{"error": {"id": "abcdef0123456789", "trace_id": "0123456789abcdeffedcba0123456789", "parent_id": "9632587410abcdef", "transaction_id": "1234567890987654", "transaction": { "sampled": true, "type": "request", "name": "mytx"}, "timestamp": 1533827045999000,"log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}}

0 commit comments

Comments
 (0)