Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow numbers and boolean values for tags. #1712

Merged
merged 6 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 5 additions & 1 deletion _meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

- name: tags
type: object
object_type: keyword
object_type_params:
- object_type: keyword
- object_type: boolean
- object_type: scaled_float
scaling_factor: 1000000
dynamic: true
description: >
A flat mapping of user-defined tags with string values.
Expand Down
5 changes: 5 additions & 0 deletions changelogs/head.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- Update Go version to 1.11.4 {pull}1700[1700].
- Update Elastic APM Go agent to v1.1.2 {pull}1711[1711], {pull}1728[1728].
- Allow numbers and boolean values for `transaction.tags`, `span.tags`, `metricset.tags` {pull}1712[1712].

[float]
==== Removed
- Remove support for using dots in tags for experimental metricset endpoint {pull}1712[1712].

[float]
==== Removed
Expand Down
5 changes: 3 additions & 2 deletions docs/data/elasticsearch/generated/metricsets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"name": "1234_service-12a3"
},
"tags": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"some": "abc",
"success": true
}
},
"dotted": {
Expand Down
5 changes: 4 additions & 1 deletion docs/data/elasticsearch/generated/spans.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@
"name": "backendspans"
},
"tags": {
"tag1": "value1"
"tag1": "value1",
"tag2": 123,
"tag3": 12.34,
"tag4": true
}
},
"parent": {
Expand Down
5 changes: 4 additions & 1 deletion docs/data/elasticsearch/generated/transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@
"platform": "darwin"
},
"tags": {
"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8"
"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8",
"tag2": 12,
"tag3": 12.45,
"tag4": false
},
"user": {
"email": "[email protected]",
Expand Down
16 changes: 1 addition & 15 deletions docs/spec/metricsets/metricset.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,7 @@
"additionalProperties": false
},
"tags": {
"type": [
"object",
"null"
],
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^*\"]*$": {
"type": [
"string",
"null"
],
"maxLength": 1024
}
},
"additionalProperties": false
"$ref": "../tags.json"
}
},
"required": ["samples"]
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
2 changes: 1 addition & 1 deletion include/fields.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion model/error/generated/schema/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const ModelSchema = `{
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
26 changes: 11 additions & 15 deletions model/metricset/generated/schema/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,17 @@ const ModelSchema = `{
"additionalProperties": false
},
"tags": {
"type": [
"object",
"null"
],
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^*\"]*$": {
"type": [
"string",
"null"
],
"maxLength": 1024
}
},
"additionalProperties": false
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
"additionalProperties": false
}
},
"required": ["samples"]
Expand Down
2 changes: 1 addition & 1 deletion model/span/generated/schema/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const ModelSchema = `{
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
2 changes: 1 addition & 1 deletion model/transaction/generated/schema/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const ModelSchema = `{
"description": "A flat mapping of user-defined tags with string values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
4 changes: 2 additions & 2 deletions processor/stream/package_tests/error_attrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ func TestPayloadDataForError(t *testing.T) {
{Key: "error.context.request.cookies", Valid: val{obj{}},
Invalid: []tests.Invalid{{Msg: `/context/properties/request/properties/cookies/type`, Values: val{102, "a"}}}},
{Key: "error.context.tags",
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}},
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}, obj{tests.Str1024: 123.45}, obj{tests.Str1024: true}},
Invalid: []tests.Invalid{
{Msg: `context/properties/tags/type`, Values: val{"tags"}},
{Msg: `context/properties/tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: 123}, obj{tests.Str1024: obj{}}}},
{Msg: `context/properties/tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: obj{}}}},
{Msg: `context/properties/tags/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}, obj{"invali.d": "hello"}}}}},
{Key: "error.context.user.id", Valid: val{123, tests.Str1024Special},
Invalid: []tests.Invalid{
Expand Down
4 changes: 2 additions & 2 deletions processor/stream/package_tests/metricset_attrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func TestInvalidPayloads(t *testing.T) {
Invalid: []tests.Invalid{
{Msg: `timestamp/type`, Values: val{"1496170422281000"}}}},
{Key: "metricset.tags",
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}},
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}, obj{tests.Str1024: 123.45}, obj{tests.Str1024: true}},
Invalid: []tests.Invalid{
{Msg: `tags/type`, Values: val{"tags"}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: 123}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}}}},
},
{
Expand Down
7 changes: 3 additions & 4 deletions processor/stream/package_tests/span_attrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func spanPayloadAttrsNotInFields() *tests.Set {
"context.http",
"context.http.url",
"context.http.method",
"context.tags.tag1",
)
}

Expand All @@ -67,7 +66,7 @@ func spanPayloadAttrsNotInJsonSchema() *tests.Set {
return tests.NewSet(
"span",
"span.stacktrace.vars.key",
"span.context.tags.tag1",
tests.Group("span.context.tags.tag"),
)
}

Expand Down Expand Up @@ -165,10 +164,10 @@ func TestPayloadDataForSpans(t *testing.T) {
spanProcSetup().DataValidation(t,
[]tests.SchemaTestData{
{Key: "span.context.tags",
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}},
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}, obj{tests.Str1024: 123.45}, obj{tests.Str1024: true}},
Invalid: []tests.Invalid{
{Msg: `tags/type`, Values: val{"tags"}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: 123}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}, obj{"invali.d": "hello"}}}},
},
{Key: "span.timestamp",
Expand Down
4 changes: 2 additions & 2 deletions processor/stream/package_tests/transaction_attrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ func TestPayloadDataForTransaction(t *testing.T) {
Valid: []interface{}{obj{}},
Invalid: []tests.Invalid{{Msg: `context/properties/request/properties/cookies/type`, Values: val{123, ""}}}},
{Key: "transaction.context.tags",
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}},
Valid: val{obj{tests.Str1024Special: tests.Str1024Special}, obj{tests.Str1024: 123.45}, obj{tests.Str1024: true}},
Invalid: []tests.Invalid{
{Msg: `tags/type`, Values: val{"tags"}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: 123}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/patternproperties`, Values: val{obj{"invalid": tests.Str1025}, obj{tests.Str1024: obj{}}}},
{Msg: `tags/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}, obj{"invali.d": "hello"}}}}},
{Key: "transaction.context.user.id",
Valid: val{123, tests.Str1024Special},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"name": "1234_service-12a3"
},
"tags": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"some": "abc",
"success": true
}
},
"dotted": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@
"name": "backendspans"
},
"tags": {
"tag1": "value1"
"tag1": "value1",
"tag2": 123,
"tag3": 12.34,
"tag4": true
}
},
"parent": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@
"platform": "darwin"
},
"tags": {
"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8"
"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8",
"tag2": 12,
"tag3": 12.45,
"tag4": false
},
"user": {
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion testdata/intake-v2/invalid-json-metadata.ndjson
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"metadata": {"invalid-json"}}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some.other.code": "abc" }, "timestamp": 1496170422281000 }}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "code": "abc" }, "timestamp": 1496170422281000 }}
2 changes: 1 addition & 1 deletion testdata/intake-v2/invalid-metadata-2.ndjson
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"not": "metadata"}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some.other.code": "abc" }, "timestamp": 1496170422281000 }}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "key": "abc" }, "timestamp": 1496170422281000 }}

2 changes: 1 addition & 1 deletion testdata/intake-v2/invalid-metadata.ndjson
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"metadata": {"user": null}}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some.other.code": "abc" }, "timestamp": 1496170422281000 }}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some": "abc" }, "timestamp": 1496170422281000 }}

2 changes: 1 addition & 1 deletion testdata/intake-v2/metricsets.ndjson
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"metadata": {"user": null, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "1234_service-12a3", "language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": null, "framework": null,"version": null, "runtime": null}}}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some.other.code": "abc" }, "timestamp": 1496170422281000 }}
{"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "some": "abc", "code": 200, "success": true }, "timestamp": 1496170422281000 }}
{ "metricset": { "samples": { "go.memstats.heap.sys.bytes": { "value": 6.520832e+06 } }, "timestamp": 1496170422281000 }}
2 changes: 1 addition & 1 deletion testdata/intake-v2/spans.ndjson
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"metadata": {"user": {"id": "123", "email": "[email protected]", "username": "john"}, "process": {"ppid": 6789, "pid": 1234,"argv": ["node", "server.js"], "title": "node"}, "system": {"platform": "darwin", "hostname": "prod1.example.com", "architecture": "x64"}, "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": "request","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} }
{ "span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "abcdefabcdef7890", "id": "0123456a89012345", "transaction_id": "ab23456a89012345", "name": "GET /api/types", "type": "request", "start": 1.845, "duration": 3.5642981, "stacktrace": [], "context": {"tags": {"tag1": "value1"}} }}
{ "span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "abcdefabcdef7890", "id": "0123456a89012345", "transaction_id": "ab23456a89012345", "name": "GET /api/types", "type": "request", "start": 1.845, "duration": 3.5642981, "stacktrace": [], "context": {"tags": {"tag1": "value1", "tag2": 123, "tag3": 12.34, "tag4": true, "tag5": null}} }}
{ "span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "ababcdcdefefabde", "id": "abcde56a89012345", "transaction_id": "bed3456a89012345", "name": "get /api/types", "sync": false, "type": "request", "subtype": "http", "action": "call", "start": 0, "duration": 13.9802981, "stacktrace": null, "context": null }}
{ "span": {"trace_id": "abcdef0123456789abcdef9876543210", "parent_id": "abcdef0123456789", "id": "1234567890aaaade","transaction_id": "aff4567890aaaade", "sync": true, "name": "SELECT FROM product_types", "type": "db", "subtype": "postgresql", "action": "query", "start": 2.83092, "duration": 3.781912, "stacktrace": [{ "filename": "net.js", "lineno": 547},{"filename": "file2.js", "lineno": 12, "post_context": [ " ins.currentTransaction = prev", "}"]}, { "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"] }], "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" } } }}
Loading