Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apmpackage/apm/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- description: added `span.links` fields to traces and rum_traces data streams
type: enhancement
link: https://github.com/elastic/apm-server/pull/7291
- description: Added field mapping for `faas.name` and `faas.version` to internal_metrics data stream
type: enhancement
link: https://github.com/elastic/apm-server/pull/7427
- version: "8.1.0"
changes:
- description: Added field mapping for `faas.coldstart` and `faas.trigger.type`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
type: keyword
description: |
The trigger type.
- name: name
type: keyword
description: |
The lambda function name.
- name: version
type: keyword
description: |
The lambda function version.
- name: kubernetes
title: Kubernetes
type: group
Expand Down
8 changes: 8 additions & 0 deletions apmpackage/apm/data_stream/traces/fields/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
type: keyword
description: |
The trigger type.
- name: name
type: keyword
description: |
The lambda function name.
- name: version
type: keyword
description: |
The lambda function version.
- name: http
type: group
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,10 @@
"faas": {
"coldstart": false,
"execution": "2e13b309-23e1-417f-8bf7-074fc96bc683",
"name": "faasName",
"trigger.request_id": "FuH2Cir_vHcEMUA=",
"trigger.type": "http"
"trigger.type": "http",
"version": "1.0.0"
},
"host": {
"architecture": "x64",
Expand Down
1 change: 1 addition & 0 deletions changelogs/head.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ See <<apm-server-configuration>> for more information.

[float]
==== Intake API Changes
- Support for `faas.name` and `faas.version` added to intake and transaction metrics {pull}7427[7427]

[float]
==== Added
Expand Down
14 changes: 14 additions & 0 deletions docs/spec/v2/transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,13 @@
"string"
]
},
"name": {
"description": "The lambda function name.",
"type": [
"null",
"string"
]
},
"trigger": {
"description": "Trigger attributes.",
"type": [
Expand All @@ -855,6 +862,13 @@
]
}
}
},
"version": {
"description": "The lambda function version.",
"type": [
"null",
"string"
]
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions model/apmevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func TestAPMEventFields(t *testing.T) {
Execution: "execution",
TriggerType: "http",
TriggerRequestID: "abc123",
Name: "faasName",
Version: "1.0.0",
},
Cloud: Cloud{
Origin: &CloudOrigin{
Expand Down Expand Up @@ -184,6 +186,8 @@ func TestAPMEventFields(t *testing.T) {
"execution": "execution",
"trigger.type": "http",
"trigger.request_id": "abc123",
"name": "faasName",
"version": "1.0.0",
},
"cloud": common.MapStr{
"origin": common.MapStr{
Expand Down
4 changes: 4 additions & 0 deletions model/faas.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type FAAS struct {
Execution string
TriggerType string
TriggerRequestID string
Name string
Version string
}

func (f *FAAS) fields() common.MapStr {
Expand All @@ -35,5 +37,7 @@ func (f *FAAS) fields() common.MapStr {
fields.maybeSetString("execution", f.Execution)
fields.maybeSetString("trigger.type", f.TriggerType)
fields.maybeSetString("trigger.request_id", f.TriggerRequestID)
fields.maybeSetString("name", f.Name)
fields.maybeSetString("version", f.Version)
return common.MapStr(fields)
}
2 changes: 2 additions & 0 deletions model/modeldecoder/rumv3/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func metadataExceptions(keys ...string) func(key string) bool {
"FAAS.Execution",
"FAAS.TriggerType",
"FAAS.TriggerRequestID",
"FAAS.Name",
"FAAS.Version",
"Experimental",
"HTTP",
"Kubernetes",
Expand Down
6 changes: 6 additions & 0 deletions model/modeldecoder/v2/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ func mapToFAASModel(from faas, faas *model.FAAS) {
if from.Trigger.RequestID.IsSet() {
faas.TriggerRequestID = from.Trigger.RequestID.Val
}
if from.Name.IsSet() {
faas.Name = from.Name.Val
}
if from.Version.IsSet() {
faas.Version = from.Version.Val
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions model/modeldecoder/v2/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func isUnmappedMetadataField(key string) bool {
"FAAS.Execution",
"FAAS.TriggerType",
"FAAS.TriggerRequestID",
"FAAS.Name",
"FAAS.Version",
"HTTP",
"HTTP.Request",
"HTTP.Response",
Expand Down
4 changes: 4 additions & 0 deletions model/modeldecoder/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ type faas struct {
Execution nullable.String `json:"execution"`
// Trigger attributes.
Trigger trigger `json:"trigger"`
// The lambda function name.
Name nullable.String `json:"name"`
// The lambda function version.
Version nullable.String `json:"version"`
}

type trigger struct {
Expand Down
4 changes: 3 additions & 1 deletion model/modeldecoder/v2/model_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions model/modeldecoder/v2/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ func TestDecodeMapToTransactionModel(t *testing.T) {
input.FAAS.Execution.Set("execution")
input.FAAS.Trigger.Type.Set("http")
input.FAAS.Trigger.RequestID.Set("abc123")
input.FAAS.Name.Set("faasName")
input.FAAS.Version.Set("1.0.0")
mapToTransactionModel(&input, &out)
assert.Equal(t, "faasID", out.FAAS.ID)
assert.True(t, *out.FAAS.Coldstart)
assert.Equal(t, "execution", out.FAAS.Execution)
assert.Equal(t, "http", out.FAAS.TriggerType)
assert.Equal(t, "abc123", out.FAAS.TriggerRequestID)
assert.Equal(t, "faasName", out.FAAS.Name)
assert.Equal(t, "1.0.0", out.FAAS.Version)
})

t.Run("dropped_span_stats", func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,10 @@
"faas": {
"coldstart": false,
"execution": "2e13b309-23e1-417f-8bf7-074fc96bc683",
"name": "faasName",
"trigger.request_id": "FuH2Cir_vHcEMUA=",
"trigger.type": "http"
"trigger.type": "http",
"version": "1.0.0"
},
"host": {
"architecture": "x64",
Expand Down
2 changes: 1 addition & 1 deletion testdata/intake-v2/transactions.ndjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
{"transaction": {"id": "4340a8e0df1906ecbfa9", "trace_id": "0acd456789abcdef0123456789abcdef", "name": "GET /api/types","type": "request","duration": 32.592981,"outcome":"success", "result": "success", "timestamp": 1496170407154000, "sampled": true, "span_count": {"started": 17},"context": {"service": {"runtime": {"version": "7.0"}},"page":{"referer":"http://localhost:8000/test/e2e/","url":"http://localhost:8000/test/e2e/general-usecase/"}, "request": {"socket": {"remote_address": "12.53.12.1","encrypted": true},"http_version": "1.1","method": "POST","url": {"protocol": "https:","full": "https://www.example.com/p/a/t/h?query=string#hash","hostname": "www.example.com","port": "8080","pathname": "/p/a/t/h","search": "?query=string","hash": "#hash","raw": "/p/a/t/h?query=string#hash"},"headers": {"user-agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36","Mozilla Chrome Edge"],"content-type": "text/html","cookie": "c1=v1, c2=v2","some-other-header": "foo","array": ["foo","bar","baz"]},"cookies": {"c1": "v1","c2": "v2"},"env": {"SERVER_SOFTWARE": "nginx","GATEWAY_INTERFACE": "CGI/1.1"},"body": {"str": "hello world","additional": { "foo": {},"bar": 123,"req": "additional information"}}},"response": {"status_code": 200,"headers": {"content-type": "application/json"},"headers_sent": true,"finished": true,"transfer_size":25.8,"encoded_body_size":26.90,"decoded_body_size":29.90}, "user": {"domain": "ldap://abc","id": "99","username": "foo"},"tags": {"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8", "tag2": 12, "tag3": 12.45, "tag4": false, "tag5": null },"custom": {"my_key": 1,"some_other_value": "foo bar","and_objects": {"foo": ["bar","baz"]},"(": "not a valid regex and that is fine"}}}}
{"transaction": { "id": "cdef4340a8e0df19", "trace_id": "0acd456789abcdef0123456789abcdef", "type": "request", "duration": 13.980558, "timestamp": 1532976822281000, "sampled": null, "span_count": { "dropped": 55, "started": 436 }, "marks": {"navigationTiming": {"appBeforeBootstrap": 608.9300000000001,"navigationStart": -21},"another_mark": {"some_long": 10,"some_float": 10.0}, "performance": {}}, "context": { "request": { "socket": { "remote_address": "192.0.1", "encrypted": null }, "method": "POST", "headers": { "user-agent": null, "content-type": null, "cookie": null }, "url": { "protocol": null, "full": null, "hostname": null, "port": null, "pathname": null, "search": null, "hash": null, "raw": null } }, "response": { "headers": { "content-type": null } }, "service": {"environment":"testing","name": "service1","node": {"configured_name": "node-ABC"}, "language": {"version": "2.5", "name": "ruby"}, "agent": {"version": "2.2", "name": "elastic-ruby", "ephemeral_id": "justanid"}, "framework": {"version": "5.0", "name": "Rails"}, "version": "2", "runtime": {"version": "2.5", "name": "cruby"}}},"experience":{"cls":1,"fid":2.0,"tbt":3.4,"longtask":{"count":3,"sum":2.5,"max":1}}}}
{"transaction": { "id": "00xxxxFFaaaa1234", "trace_id": "0123456789abcdef0123456789abcdef", "name": "amqp receive", "parent_id": "abcdefabcdef01234567", "type": "messaging", "duration": 3, "span_count": { "started": 1 }, "context": {"message": {"queue": { "name": "new_users"}, "age":{ "ms": 1577958057123}, "headers": {"user_id": "1ax3", "involved_services": ["user", "auth"]}, "body": "user created", "routing_key": "user-created-transaction"}},"session":{"id":"sunday","sequence":123}}}
{"transaction": { "name": "july-2021-delete-after-july-31", "type": "lambda", "result": "success", "id": "142e61450efb8574", "trace_id": "eb56529a1f461c5e7e2f66ecb075e983", "subtype": null, "action": null, "duration": 38.853, "timestamp": 1631736666365048, "sampled": true, "context": { "cloud": { "origin": { "account": { "id": "abc123" }, "provider": "aws", "region": "us-east-1", "service": { "name": "serviceName" } } }, "service": { "origin": { "id": "abc123", "name": "service-name", "version": "1.0" } }, "user": {}, "tags": {}, "custom": { } }, "sync": true, "span_count": { "started": 0 }, "outcome": "unknown", "faas": { "coldstart": false, "execution": "2e13b309-23e1-417f-8bf7-074fc96bc683", "trigger": { "request_id": "FuH2Cir_vHcEMUA=", "type": "http" } }, "sample_rate": 1 } }
{"transaction": { "name": "july-2021-delete-after-july-31", "type": "lambda", "result": "success", "id": "142e61450efb8574", "trace_id": "eb56529a1f461c5e7e2f66ecb075e983", "subtype": null, "action": null, "duration": 38.853, "timestamp": 1631736666365048, "sampled": true, "context": { "cloud": { "origin": { "account": { "id": "abc123" }, "provider": "aws", "region": "us-east-1", "service": { "name": "serviceName" } } }, "service": { "origin": { "id": "abc123", "name": "service-name", "version": "1.0" } }, "user": {}, "tags": {}, "custom": { } }, "sync": true, "span_count": { "started": 0 }, "outcome": "unknown", "faas": { "name": "faasName", "version": "1.0.0", "coldstart": false, "execution": "2e13b309-23e1-417f-8bf7-074fc96bc683", "trigger": { "request_id": "FuH2Cir_vHcEMUA=", "type": "http" } }, "sample_rate": 1 } }
8 changes: 8 additions & 0 deletions x-pack/apm-server/aggregation/txmetrics/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ func (a *Aggregator) makeTransactionAggregationKey(event model.APMEvent, interva
faasColdstart: event.FAAS.Coldstart,
faasID: event.FAAS.ID,
faasTriggerType: event.FAAS.TriggerType,
faasName: event.FAAS.Name,
faasVersion: event.FAAS.Version,
}
}

Expand Down Expand Up @@ -434,6 +436,8 @@ func makeMetricset(
Coldstart: key.faasColdstart,
ID: key.faasID,
TriggerType: key.faasTriggerType,
Name: key.faasName,
Version: key.faasVersion,
},
Processor: model.MetricsetProcessor,
Metricset: &model.Metricset{
Expand Down Expand Up @@ -478,6 +482,8 @@ type transactionAggregationKey struct {
timestamp time.Time
faasColdstart *bool
faasID string
faasName string
faasVersion string
agentName string
hostOSPlatform string
kubernetesPodName string
Expand Down Expand Up @@ -547,6 +553,8 @@ func (k *transactionAggregationKey) hash() uint64 {
h.WriteString(k.eventOutcome)
h.WriteString(k.faasID)
h.WriteString(k.faasTriggerType)
h.WriteString(k.faasName)
h.WriteString(k.faasVersion)
return h.Sum64()
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/apm-server/aggregation/txmetrics/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ func TestAggregationFields(t *testing.T) {
&input.Host.OS.Platform,
&input.FAAS.ID,
&input.FAAS.TriggerType,
&input.FAAS.Name,
&input.FAAS.Version,
}
boolInputFields := []*bool{
input.FAAS.Coldstart,
Expand Down