Skip to content

Commit

Permalink
Allow numbers and boolean values for tags. (#1712) (#1784)
Browse files Browse the repository at this point in the history
* Allow numbers and boolean values for tags. (#1712)

fixes #828.
  • Loading branch information
simitt authored Jan 14, 2019
1 parent cb4d0fc commit 51ae8ed
Show file tree
Hide file tree
Showing 42 changed files with 157 additions and 97 deletions.
6 changes: 5 additions & 1 deletion _meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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 @@ -11,6 +11,11 @@ https://github.com/elastic/apm-server/compare/6.5\...6.x[View commits]
- Make `service.framework` properties optional and nullable {pull}1546[1546].
- Add `transaction.sampled` to errors {pull}1662[1662].
- Remove formatting of `duration.us` to milliseconds in index pattern pull{1717}[1717].
- 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]
==== Bug fixes
Expand Down
10 changes: 6 additions & 4 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 All @@ -31,8 +32,9 @@
"float_gauge": 9.16,
"integer_gauge": 42767,
"labels": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"some": "abc",
"success": true
},
"long_gauge": 3147483648,
"negative": {
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 @@ -90,7 +90,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 @@ -183,7 +183,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
10 changes: 6 additions & 4 deletions docs/data/elasticsearch/metric.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"platform": "darwin"
},
"tags": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"key": "value",
"success": true
}
},
"dotted": {
Expand All @@ -44,8 +45,9 @@
"float_gauge": 9.16,
"integer_gauge": 42767,
"labels": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"key": "value",
"success": true
},
"long_gauge": 3147483648,
"negative": {
Expand Down
2 changes: 2 additions & 0 deletions docs/data/elasticsearch/span.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"name": "1234_service-12a3"
},
"tags": {
"bool_error": false,
"number_code": 200,
"span_tag": "something"
}
},
Expand Down
2 changes: 2 additions & 0 deletions docs/data/elasticsearch/transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
"platform": "darwin"
},
"tags": {
"bool_error": false,
"number_code": 2,
"organization_uuid": "9f0e9d64-c185-4d21-a6f4-4673ed561ec8"
},
"user": {
Expand Down
10 changes: 1 addition & 9 deletions docs/spec/metricsets/common_metricset.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,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
4 changes: 2 additions & 2 deletions docs/spec/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number 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.

4 changes: 2 additions & 2 deletions model/error/generated/schema/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ const ModelSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
4 changes: 2 additions & 2 deletions model/error/generated/schema/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ const PayloadSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
20 changes: 11 additions & 9 deletions model/metricset/generated/schema/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,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, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
"additionalProperties": false
}
},
"required": ["samples"] },
Expand Down
20 changes: 11 additions & 9 deletions model/metricset/generated/schema/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ const PayloadSchema = `{
"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, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
"additionalProperties": false
}
},
"required": ["samples"] },
Expand Down
4 changes: 2 additions & 2 deletions model/span/generated/schema/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ const ModelSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
8 changes: 4 additions & 4 deletions model/transaction/generated/schema/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ const PayloadSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down Expand Up @@ -478,10 +478,10 @@ const PayloadSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
4 changes: 2 additions & 2 deletions model/transaction/generated/schema/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ const ModelSchema = `{
"$id": "doc/spec/tags.json",
"title": "Tags",
"type": ["object", "null"],
"description": "A flat mapping of user-defined tags with string values.",
"description": "A flat mapping of user-defined tags with string, boolean or number values.",
"patternProperties": {
"^[^.*\"]*$": {
"type": ["string", "null"],
"type": ["string", "boolean", "number", "null"],
"maxLength": 1024
}
},
Expand Down
8 changes: 4 additions & 4 deletions processor/error/package_tests/attrs_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ func schemaTestData(td []tests.SchemaTestData) []tests.SchemaTestData {
{Key: "errors.context.request.cookies", Valid: val{obj{}},
Invalid: []tests.Invalid{{Msg: `/context/properties/request/properties/cookies/type`, Values: val{102, "a"}}}},
{Key: "errors.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/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}, obj{"invali.d": "hello"}}}}},
{Msg: `tags/type`, Values: val{"tags"}},
{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: "errors.context.user.id", Valid: val{123, tests.Str1024Special},
Invalid: []tests.Invalid{
{Msg: `context/properties/user/properties/id/type`, Values: val{obj{}}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
"platform": "darwin"
},
"tags": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"key": "value",
"success": true
}
},
"dotted": {
Expand All @@ -47,8 +48,9 @@
"float_gauge": 9.16,
"integer_gauge": 42767,
"labels": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"key": "value",
"success": true
},
"long_gauge": 3147483648,
"negative": {
Expand Down
7 changes: 3 additions & 4 deletions processor/metricset/package_tests/json_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ func TestInvalidPayloads(t *testing.T) {
{Msg: `timestamp/format`, Values: val{"2017-05-30T18:53Z", "2017-05-30T18:53:27.Z", "2017-05-30T18:53:27a123Z"}},
{Msg: `timestamp/pattern`, Values: val{"2017-05-30T18:53:27.000+00:20", "2017-05-30T18:53:27ZNOTCORRECT"}}}},
{Key: "metrics.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/additionalproperties`, Values: val{obj{"invali*d": "hello"}, obj{"invali\"d": "hello"}}}},
},
{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: "metrics.samples",
Valid: val{
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 All @@ -31,8 +32,9 @@
"float_gauge": 9.16,
"integer_gauge": 42767,
"labels": {
"code": "200",
"some.other.code": "abc"
"code": 200,
"some": "abc",
"success": true
},
"long_gauge": 3147483648,
"negative": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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 @@ -183,7 +183,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
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 @@ -223,10 +223,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
Loading

0 comments on commit 51ae8ed

Please sign in to comment.