Skip to content

Commit 05ea608

Browse files
Update http.request.body to be translated as an object instead of a string (#839)
1 parent 04561e5 commit 05ea608

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

receiver/elasticapmintakereceiver/internal/mappers/intakeV2ToElasticSpecificFields.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ func setHTTP(http *modelpb.HTTP, attributesMap pcommon.Map) {
101101
}
102102

103103
if http.Request.Body != nil {
104-
attributesMap.PutStr(attr.HTTPRequestBody, http.Request.Body.GetStringValue())
104+
// add http body as an object since it is required by the APM index template
105+
// see: https://github.com/elastic/elasticsearch/blob/714c077b11363f168e261ad43cff0b5b74556b7f/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm%40mappings.yaml#L30
106+
bodyValue := attributesMap.PutEmpty(attr.HTTPRequestBody)
107+
insertValue(bodyValue, http.Request.Body)
105108
}
106109
if http.Request.Id != "" {
107110
attributesMap.PutStr(attr.HTTPRequestID, http.Request.Id)

receiver/elasticapmintakereceiver/testdata/transactions_expected.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,21 @@ resourceSpans:
446446
stringValue: string_value:"v2"
447447
- key: http.request.body
448448
value:
449-
stringValue: ""
449+
kvlistValue:
450+
values:
451+
- key: str
452+
value:
453+
stringValue: hello world
454+
- key: additional
455+
value:
456+
kvlistValue:
457+
values:
458+
- key: bar
459+
value:
460+
doubleValue: 123
461+
- key: req
462+
value:
463+
stringValue: additional information
450464
- key: http.request.referrer
451465
value:
452466
stringValue: http://localhost:8000/test/e2e/

receiver/elasticapmintakereceiver/testdata/transactions_spans_expected.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,21 @@ resourceSpans:
212212
stringValue: string_value:"v2"
213213
- key: http.request.body
214214
value:
215-
stringValue: ""
215+
kvlistValue:
216+
values:
217+
- key: str
218+
value:
219+
stringValue: hello world
220+
- key: additional
221+
value:
222+
kvlistValue:
223+
values:
224+
- key: bar
225+
value:
226+
doubleValue: 123
227+
- key: req
228+
value:
229+
stringValue: additional information
216230
- key: http.request.referrer
217231
value:
218232
stringValue: http://localhost:8000/test/e2e/

receiver/elasticapmintakereceiver/testdata/unknown-span-type_expected.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,21 @@ resourceSpans:
206206
stringValue: string_value:"v2"
207207
- key: http.request.body
208208
value:
209-
stringValue: ""
209+
kvlistValue:
210+
values:
211+
- key: str
212+
value:
213+
stringValue: hello world
214+
- key: additional
215+
value:
216+
kvlistValue:
217+
values:
218+
- key: bar
219+
value:
220+
doubleValue: 123
221+
- key: req
222+
value:
223+
stringValue: additional information
210224
- key: http.request.referrer
211225
value:
212226
stringValue: http://localhost:8000/test/e2e/

0 commit comments

Comments
 (0)