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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"name": "elastic-node",
"version": "3.14.0"
},
"child": {
"id": [
"51234abcdef56789"
]
},
"container": {
"id": "container-id"
},
Expand Down
5 changes: 5 additions & 0 deletions docs/data/elasticsearch/generated/spans.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@
"name": "GET /api/types",
"id": "3aaaaaaaaaaaaaaa"
},
"child": {
"id": [
"4aaaaaaaaaaaaaaa"
]
},
"trace": {
"id": "945254c567a5417eaaaaaaaaaaaaaaaa"
},
Expand Down
11 changes: 11 additions & 0 deletions docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,17 @@ format: url
--


*`child.id`*::
+
--
The ID(s)s of the child event(s).


type: keyword

--


*`span.id`*::
+
--
Expand Down
10 changes: 10 additions & 0 deletions docs/spec/spans/span.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"type": "string",
"maxLength": 1024
},
"child_ids": {
"description": "List of successor transactions and/or spans.",
"type": ["array", "null"],
"minItems": 0,
"maxLength": 1024,
"items": {
"type": "string",
"maxLength": 1024
}
},
"start": {
"type": ["number", "null"],
"description": "Offset relative to the transaction's timestamp identifying the start of the span, in milliseconds"
Expand Down
2 changes: 1 addition & 1 deletion include/fields.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion model/modeldecoder/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package modeldecoder
import (
"testing"

"github.com/elastic/apm-server/model"
"github.com/stretchr/testify/assert"

"github.com/elastic/apm-server/model"
)

func TestContainerDecode(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion model/modeldecoder/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package modeldecoder
import (
"testing"

"github.com/elastic/apm-server/model"
"github.com/stretchr/testify/assert"

"github.com/elastic/apm-server/model"
)

func TestKubernetesDecode(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion model/modeldecoder/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/santhosh-tekuri/jsonschema"

"github.com/elastic/apm-server/model"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/model/metadata/generated/schema"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/validation"
)

Expand Down
2 changes: 1 addition & 1 deletion model/modeldecoder/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/pkg/errors"

"github.com/elastic/apm-server/model"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/model/metricset/generated/schema"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/transform"
"github.com/elastic/apm-server/utility"
"github.com/elastic/apm-server/validation"
Expand Down
3 changes: 2 additions & 1 deletion model/modeldecoder/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package modeldecoder
import (
"testing"

"github.com/elastic/apm-server/model"
"github.com/stretchr/testify/assert"

"github.com/elastic/apm-server/model"
)

func TestProcessDecode(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion model/modeldecoder/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package modeldecoder
import (
"testing"

"github.com/elastic/apm-server/model"
"github.com/stretchr/testify/assert"

"github.com/elastic/apm-server/model"
)

const (
Expand Down
1 change: 1 addition & 0 deletions model/modeldecoder/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func decodeSpan(input Input, schema *jsonschema.Schema) (*model.Span, error) {
Timestamp: decoder.TimeEpochMicro(raw, fieldName("timestamp")),
ID: decoder.String(raw, fieldName("id")),
ParentID: decoder.StringPtr(raw, "parent_id"),
ChildIDs: decoder.StringArr(raw, "child_ids"),
// ParentIdx comes from RUM V3 payloads only, and used to populate ParentID
ParentIdx: decoder.IntPtr(raw, fieldName("parent_idx")),
TraceID: decoder.StringPtr(raw, "trace_id"),
Expand Down
3 changes: 2 additions & 1 deletion model/modeldecoder/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
"net"
"testing"

"github.com/elastic/apm-server/model"
"github.com/stretchr/testify/assert"

"github.com/elastic/apm-server/model"
)

func TestUserDecode(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions model/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Span struct {
ID string
TransactionID *string
ParentID *string
ChildIDs []string
ParentIdx *int
TraceID *string

Expand Down Expand Up @@ -191,6 +192,9 @@ func (e *Span) Transform(ctx context.Context, tctx *transform.Context) []beat.Ev
// merges with metadata labels, overrides conflicting keys
utility.DeepUpdate(fields, "labels", e.Labels)
utility.AddId(fields, "parent", e.ParentID)
if e.ChildIDs != nil {
utility.Set(fields, "child", common.MapStr{"id": e.ChildIDs})
}
utility.AddId(fields, "trace", e.TraceID)
utility.AddId(fields, "transaction", e.TransactionID)
utility.Set(fields, "experimental", e.Experimental)
Expand Down
9 changes: 9 additions & 0 deletions model/span/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
format: url
label_template: "View Spans"

- name: child
type: group
dynamic: false
fields:
- name: id
type: keyword
description: >
The ID(s)s of the child event(s).

- name: span
type: group
dynamic: false
Expand Down
10 changes: 10 additions & 0 deletions model/span/generated/schema/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ const ModelSchema = `{
"type": "string",
"maxLength": 1024
},
"child_ids": {
"description": "List of successor transactions and/or spans.",
"type": ["array", "null"],
"minItems": 0,
"maxLength": 1024,
"items": {
"type": "string",
"maxLength": 1024
}
},
"start": {
"type": ["number", "null"],
"description": "Offset relative to the transaction's timestamp identifying the start of the span, in milliseconds"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Action": null,
"ChildIDs": null,
"DB": null,
"Destination": null,
"DestinationService": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Action": null,
"ChildIDs": null,
"DB": {
"Instance": "db01",
"Link": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Action": null,
"ChildIDs": null,
"DB": null,
"Destination": {
"Address": "mysql://db:3306",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Action": null,
"ChildIDs": null,
"DB": null,
"Destination": null,
"DestinationService": null,
Expand Down
1 change: 1 addition & 0 deletions processor/stream/package_tests/span_attrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestKeywordLimitationOnSpanAttrs(t *testing.T) {
spanKeywordExceptionKeys(),
[]tests.FieldTemplateMapping{
{Template: "transaction.id", Mapping: "transaction_id"},
{Template: "child.id", Mapping: "child_ids"},
{Template: "parent.id", Mapping: "parent_id"},
{Template: "trace.id", Mapping: "trace_id"},
{Template: "span.id", Mapping: "id"},
Expand Down
2 changes: 1 addition & 1 deletion processor/stream/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/elastic/apm-server/beater/config"
"github.com/elastic/apm-server/decoder"
"github.com/elastic/apm-server/model"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/model/modeldecoder"
"github.com/elastic/apm-server/model/modeldecoder/field"
"github.com/elastic/apm-server/publish"
"github.com/elastic/apm-server/transform"
"github.com/elastic/apm-server/utility"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"name": "elastic-node",
"version": "3.14.0"
},
"child": {
"id": [
"51234abcdef56789"
]
},
"container": {
"id": "container-id"
},
Expand Down
2 changes: 1 addition & 1 deletion testdata/intake-v2/spans.ndjson
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"metadata": {"user": {"id": "123", "email": "s@test.com", "username": "john"}, "process": {"ppid": 6789, "pid": 1234,"argv": ["node", "server.js"], "title": "node"}, "system": {"platform": "darwin", "hostname": "prod1.example.com", "architecture": "x64", "container": {"id": "container-id"}, "kubernetes": {"namespace": "namespace1", "pod": {"uid": "pod-uid", "name": "pod-name"}, "node": {"name": "node-name"}}}, "labels": {"tag1": "label1"}, "service": {"name": "backendspans", "language": {"version": "8", "name": "ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": "staging", "framework": {"version": "1.2.3", "name": "Express"}, "version": "5.1.3", "runtime": {"version": "8.0.0", "name": "node"}}}}
{"span": {"trace_id": "fdedef0123456789abcdef9876543210", "parent_id": "abcdef0123456789", "id": "abcdef01234567", "transaction_id": "01af25874dec69dd", "name": "GET /api/types", "type": "db.postgresql.query.custom","start": null, "duration": 141.581, "timestamp": 1532976822281000}}
{"span": {"trace_id": "fdedef0123456789abcdef9876543210", "parent_id": "abcdef0123456789", "id": "abcdef01234567", "child_ids": ["51234abcdef56789"], "transaction_id": "01af25874dec69dd", "name": "GET /api/types", "type": "db.postgresql.query.custom","start": null, "duration": 141.581, "timestamp": 1532976822281000}}
{"span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "0000000011111111", "id": "1234abcdef567895", "transaction_id": "ab45781d265894fe", "name": "GET /api/types", "type": "request", "start": 22, "duration": 32.592981, "timestamp": 1532976822281000,"context":{"service":{"environment":"prod","agent":{}}}}}
{"span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "abcdefabcdef7890", "id": "0123456a89012345", "transaction_id": "ab23456a89012345", "name": "GET /api/types", "type": "request.http", "start": 1.845, "duration": 3.5642981, "stacktrace": [], "context":{"tags": {"tag1": "value1", "tag2": 123, "tag3": 12.34, "tag4": true, "tag5": null},"service":{}}}}
{"span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "ababcdcdefefabde", "id": "abcde56a89012345", "transaction_id": null, "name": "get /api/types", "sync": false, "type": "request", "subtype": "http", "action": "call", "start": 0, "duration": 13.9802981, "stacktrace": null, "context": null }}
Expand Down
2 changes: 1 addition & 1 deletion testdata/intake-v2/transactions_spans.ndjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{"span":{"id":"0aaaaaaaaaaaaaaa","timestamp":1496170407154000,"parent":null,"name":"SELECT FROM product_types","type":"db.postgresql.query","start":2.83092,"duration":3.781912,"sync":false,"stacktrace":[{"function":"onread","abs_path":"net.js","filename":"net.js","lineno":547,"library_frame":true,"vars":{"key":"value"},"module":"some module","colno":4,"context_line":"line3","pre_context":[" var trans = this.currentTransaction",""],"post_context":[" ins.currentTransaction = prev"," return result","}"]},{"filename":"my2file.js","lineno":10}],"context":{"db":{"instance":"customers","statement":"SELECT * FROM product_types WHERE user_id=?","type":"sql","user":"readonly_user"},"http":{"url":"http://localhost:8000","status_code":200,"method":"GET"},"tags":{"span_tag":"something"}},"transaction_id":"945254c567a5417e","parent_id":"945254c567a5417e","trace_id":"945254c567a5417eaaaaaaaaaaaaaaaa"}}
{"span":{"id":"1aaaaaaaaaaaaaaa","timestamp":1496170407154000,"parent":0,"name":"GET /api/types","type":"request.external","start":0,"duration":32.592981,"transaction_id":"945254c567a5417e","parent_id":"945254c567a5417e","trace_id":"945254c567a5417eaaaaaaaaaaaaaaaa", "context":{"service":null}}}
{"span":{"id":"2aaaaaaaaaaaaaaa","timestamp":1496170407154000,"parent":1,"name":"GET /api/types","type":"request","subtype":"http","action":"post","start":1.845,"duration":3.5642981,"stacktrace":[],"context":{},"transaction_id":"945254c567a5417e","parent_id":"945254c567a5417e","trace_id":"945254c567a5417eaaaaaaaaaaaaaaaa"}}
{"span":{"id":"3aaaaaaaaaaaaaaa","timestamp":1496170407154000,"parent":2,"name":"GET /api/types","type":"request","start":0,"duration":13.9802981,"stacktrace":null,"context":null,"transaction_id":"945254c567a5417e","parent_id":"945254c567a5417e","trace_id":"945254c567a5417eaaaaaaaaaaaaaaaa"}}
{"span":{"id":"3aaaaaaaaaaaaaaa","timestamp":1496170407154000,"parent":2,"child_ids":["4aaaaaaaaaaaaaaa"],"name":"GET /api/types","type":"request","start":0,"duration":13.9802981,"stacktrace":null,"context":null,"transaction_id":"945254c567a5417e","parent_id":"945254c567a5417e","trace_id":"945254c567a5417eaaaaaaaaaaaaaaaa"}}
{"transaction":{"id":"85925e55b43f4340","name":"GET /api/types","type":"request","duration":13.980558,"result":"failure","timestamp":1496170422281000,"sampled":true,"trace_id":"85925e55b43f4340aaaaaaaaaaaaaaaa","span_count":{"started":0},"context":{"service":{}}}}
{"transaction":{"id":"85925e55b43f4341","name":"GET /api/types","type":"request","duration":13.980558,"result":"200","timestamp":1496170422000000,"sampled":false,"trace_id":"85925e55b43f4341aaaaaaaaaaaaaaaa","span_count":{"started":0},"context":{"service":null}}}
{"transaction":{"id":"85925e55b43f4342","name":"GET /api/types","type":"request","duration":13.980558,"result":"200","timestamp":1496170422281999,"sampled":true,"span_count":{"dropped":258,"started":1},"trace_id":"85925e55b43f4342aaaaaaaaaaaaaaaa"}}
Expand Down
5 changes: 5 additions & 0 deletions tests/system/spans.approved.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@
"name": "GET /api/types",
"id": "3aaaaaaaaaaaaaaa"
},
"child": {
"id": [
"4aaaaaaaaaaaaaaa"
]
},
"trace": {
"id": "945254c567a5417eaaaaaaaaaaaaaaaa"
},
Expand Down