Skip to content

Commit 534eb50

Browse files
tobiasstadlermergify-bot
authored andcommitted
Added support for transaction.name in an error object to the intake API (#6539)
* Added support for transaction.name to the intake API * Added #6539 to the changelog * Improved Changelog (cherry picked from commit fe1db82)
1 parent 057820d commit 534eb50

File tree

11 files changed

+55
-2
lines changed

11 files changed

+55
-2
lines changed

changelogs/head.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ https://github.com/elastic/apm-server/compare/7.15\...master[View commits]
3636
- `context.message.routing_key` was added to the intake API {pull}6177[6177]
3737
- `transaction.dropped_spans_stats` was added to the intake API {pull}6200[6200]
3838
- map incoming OTel spans from agent bridges to apm spans/transactions {pull}6308[6308]
39+
- `transaction.name` was added to the error objects in the intake API {pull}6539[6539]
3940

4041
[float]
4142
==== Added

docs/spec/rumv3/error.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,14 @@
695695
"object"
696696
],
697697
"properties": {
698+
"n": {
699+
"description": "Name is the generic designation of a transaction in the scope of a single service, eg: 'GET /users/:id'.",
700+
"type": [
701+
"null",
702+
"string"
703+
],
704+
"maxLength": 1024
705+
},
698706
"sm": {
699707
"description": "Sampled indicates whether or not the full information for a transaction is captured. If a transaction is unsampled no spans and less context information will be reported.",
700708
"type": [

docs/spec/v2/error.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,14 @@
10961096
"object"
10971097
],
10981098
"properties": {
1099+
"name": {
1100+
"description": "Name is the generic designation of a transaction in the scope of a single service, eg: 'GET /users/:id'.",
1101+
"type": [
1102+
"null",
1103+
"string"
1104+
],
1105+
"maxLength": 1024
1106+
},
10991107
"sampled": {
11001108
"description": "Sampled indicates whether or not the full information for a transaction is captured. If a transaction is unsampled no spans and less context information will be reported.",
11011109
"type": [

model/modeldecoder/rumv3/decoder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ func mapToErrorModel(from *errorEvent, event *model.APMEvent) {
249249
if from.Transaction.Sampled.IsSet() {
250250
event.Transaction.Sampled = from.Transaction.Sampled.Val
251251
}
252+
if from.Transaction.Name.IsSet() {
253+
event.Transaction.Name = from.Transaction.Name.Val
254+
}
252255
if from.Transaction.Type.IsSet() {
253256
event.Transaction.Type = from.Transaction.Type.Val
254257
}

model/modeldecoder/rumv3/error_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,12 @@ func TestDecodeMapToErrorModel(t *testing.T) {
201201
mapToErrorModel(&input, &out)
202202
assert.Equal(t, "123", out.Error.Exception.Code)
203203
})
204+
205+
t.Run("transaction-name", func(t *testing.T) {
206+
var input errorEvent
207+
var out model.APMEvent
208+
input.Transaction.Name.Set("My Transaction")
209+
mapToErrorModel(&input, &out)
210+
assert.Equal(t, "My Transaction", out.Transaction.Name)
211+
})
204212
}

model/modeldecoder/rumv3/model.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ type errorTransactionRef struct {
233233
// is captured. If a transaction is unsampled no spans and less context
234234
// information will be reported.
235235
Sampled nullable.Bool `json:"sm"`
236+
// Name is the generic designation of a transaction in the scope of a
237+
// single service, eg: 'GET /users/:id'.
238+
Name nullable.String `json:"n" validate:"maxLength=1024"`
236239
// Type expresses the correlated transaction's type as keyword that has
237240
// specific relevance within the service's domain,
238241
// eg: 'request', 'backgroundjob'.

model/modeldecoder/rumv3/model_generated.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/modeldecoder/v2/decoder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ func mapToErrorModel(from *errorEvent, event *model.APMEvent) {
396396
if from.Transaction.Sampled.IsSet() {
397397
event.Transaction.Sampled = from.Transaction.Sampled.Val
398398
}
399+
if from.Transaction.Name.IsSet() {
400+
event.Transaction.Name = from.Transaction.Name.Val
401+
}
399402
if from.Transaction.Type.IsSet() {
400403
event.Transaction.Type = from.Transaction.Type.Val
401404
}

model/modeldecoder/v2/error_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,12 @@ func TestDecodeMapToErrorModel(t *testing.T) {
197197
mapToErrorModel(&input, &out)
198198
assert.Equal(t, "123", out.Error.Exception.Code)
199199
})
200+
201+
t.Run("transaction-name", func(t *testing.T) {
202+
var input errorEvent
203+
var out model.APMEvent
204+
input.Transaction.Name.Set("My Transaction")
205+
mapToErrorModel(&input, &out)
206+
assert.Equal(t, "My Transaction", out.Transaction.Name)
207+
})
200208
}

model/modeldecoder/v2/model.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ type errorTransactionRef struct {
398398
// is captured. If a transaction is unsampled no spans and less context
399399
// information will be reported.
400400
Sampled nullable.Bool `json:"sampled"`
401+
// Name is the generic designation of a transaction in the scope of a
402+
// single service, eg: 'GET /users/:id'.
403+
Name nullable.String `json:"name" validate:"maxLength=1024"`
401404
// Type expresses the correlated transaction's type as keyword that has
402405
// specific relevance within the service's domain,
403406
// eg: 'request', 'backgroundjob'.

0 commit comments

Comments
 (0)