From 8ac1843265c9a30a322699686fb4db54cccd8551 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Mon, 10 Sep 2018 14:05:52 +0200 Subject: [PATCH] [v2] rename "metric" entity to "metricset" (#1359) Rename json schemas as well Closes https://github.com/elastic/apm-server/issues/1356. --- docs/spec/metrics/{metric.json => metricset.json} | 2 +- docs/spec/metrics/payload.json | 2 +- model/metric/generated/schema/{metric.go => metricset.go} | 2 +- model/metric/generated/schema/payload.go | 2 +- processor/stream/stream_processor.go | 2 +- script/inline_schemas/inline_schemas.go | 2 +- testdata/intake-v2/invalid-json-metadata.ndjson | 2 +- testdata/intake-v2/invalid-metadata-2.ndjson | 2 +- testdata/intake-v2/invalid-metadata.ndjson | 2 +- testdata/intake-v2/metrics.ndjson | 4 ++-- testdata/intake-v2/minimal_process.ndjson | 2 +- testdata/intake-v2/minimal_service.ndjson | 2 +- testdata/intake-v2/optional-timestamps.ndjson | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) rename docs/spec/metrics/{metric.json => metricset.json} (96%) rename model/metric/generated/schema/{metric.go => metricset.go} (97%) diff --git a/docs/spec/metrics/metric.json b/docs/spec/metrics/metricset.json similarity index 96% rename from docs/spec/metrics/metric.json rename to docs/spec/metrics/metricset.json index ce247a4245..8df1eecc6c 100644 --- a/docs/spec/metrics/metric.json +++ b/docs/spec/metrics/metricset.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$id": "docs/spec/metrics/metric.json", + "$id": "docs/spec/metrics/metricset.json", "type": "object", "description": "Metric data captured by an APM agent", "properties": { diff --git a/docs/spec/metrics/payload.json b/docs/spec/metrics/payload.json index 95dc1aadf4..631c5ee98c 100644 --- a/docs/spec/metrics/payload.json +++ b/docs/spec/metrics/payload.json @@ -8,7 +8,7 @@ "metrics": { "type": "array", "items": { - "$ref": "metric.json" + "$ref": "metricset.json" }, "minItems": 1 }, diff --git a/model/metric/generated/schema/metric.go b/model/metric/generated/schema/metricset.go similarity index 97% rename from model/metric/generated/schema/metric.go rename to model/metric/generated/schema/metricset.go index 22350cc79c..485c3407d8 100644 --- a/model/metric/generated/schema/metric.go +++ b/model/metric/generated/schema/metricset.go @@ -19,7 +19,7 @@ package schema const ModelSchema = `{ "$schema": "http://json-schema.org/draft-04/schema#", - "$id": "docs/spec/metrics/metric.json", + "$id": "docs/spec/metrics/metricset.json", "type": "object", "description": "Metric data captured by an APM agent", "properties": { diff --git a/model/metric/generated/schema/payload.go b/model/metric/generated/schema/payload.go index c727dba61d..c79ea820c7 100644 --- a/model/metric/generated/schema/payload.go +++ b/model/metric/generated/schema/payload.go @@ -28,7 +28,7 @@ const PayloadSchema = `{ "type": "array", "items": { "$schema": "http://json-schema.org/draft-04/schema#", - "$id": "docs/spec/metrics/metric.json", + "$id": "docs/spec/metrics/metricset.json", "type": "object", "description": "Metric data captured by an APM agent", "properties": { diff --git a/processor/stream/stream_processor.go b/processor/stream/stream_processor.go index 5ec0f705ac..ef5a2cdd5c 100644 --- a/processor/stream/stream_processor.go +++ b/processor/stream/stream_processor.go @@ -68,7 +68,7 @@ var models = []struct { span.V2DecodeEvent, }, { - "metric", + "metricset", metric.ModelSchema(), metric.DecodeMetric, }, diff --git a/script/inline_schemas/inline_schemas.go b/script/inline_schemas/inline_schemas.go index e6aa3a0ce7..472c2ba006 100644 --- a/script/inline_schemas/inline_schemas.go +++ b/script/inline_schemas/inline_schemas.go @@ -42,7 +42,7 @@ func main() { {"errors/v2_error.json", "model/error/generated/schema/error.go", "ModelSchema"}, {"transactions/v2_transaction.json", "model/transaction/generated/schema/transaction.go", "ModelSchema"}, {"spans/v2_span.json", "model/span/generated/schema/transaction.go", "ModelSchema"}, - {"metrics/metric.json", "model/metric/generated/schema/metric.go", "ModelSchema"}, + {"metrics/metricset.json", "model/metric/generated/schema/metricset.go", "ModelSchema"}, } for _, schemaInfo := range schemaPaths { file := filepath.Join(filepath.Dir(basePath), schemaInfo.path) diff --git a/testdata/intake-v2/invalid-json-metadata.ndjson b/testdata/intake-v2/invalid-json-metadata.ndjson index 64d535ad0c..22f5af5903 100644 --- a/testdata/intake-v2/invalid-json-metadata.ndjson +++ b/testdata/intake-v2/invalid-json-metadata.ndjson @@ -1,2 +1,2 @@ {"metadata": {"invalid-json"}} -{"metric": { "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": "2017-05-30T18:53:42.281Z" }} +{"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": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/invalid-metadata-2.ndjson b/testdata/intake-v2/invalid-metadata-2.ndjson index eece457a02..ee5925bdca 100644 --- a/testdata/intake-v2/invalid-metadata-2.ndjson +++ b/testdata/intake-v2/invalid-metadata-2.ndjson @@ -1,3 +1,3 @@ {"not": "metadata"} -{"metric": { "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": "2017-05-30T18:53:42.281Z" }} +{"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": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/invalid-metadata.ndjson b/testdata/intake-v2/invalid-metadata.ndjson index 0e16a892a7..6dbbe09ba1 100644 --- a/testdata/intake-v2/invalid-metadata.ndjson +++ b/testdata/intake-v2/invalid-metadata.ndjson @@ -1,3 +1,3 @@ {"metadata": {"user": null}} -{"metric": { "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": "2017-05-30T18:53:42.281Z" }} +{"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": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/metrics.ndjson b/testdata/intake-v2/metrics.ndjson index 9033771e56..a61e7b3b63 100644 --- a/testdata/intake-v2/metrics.ndjson +++ b/testdata/intake-v2/metrics.ndjson @@ -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}}} -{"metric": { "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": "2017-05-30T18:53:42.281Z" }} -{ "metric": { "samples": { "go.memstats.heap.sys.bytes": { "value": 6.520832e+06 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} +{"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": "2017-05-30T18:53:42.281Z" }} +{ "metricset": { "samples": { "go.memstats.heap.sys.bytes": { "value": 6.520832e+06 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/minimal_process.ndjson b/testdata/intake-v2/minimal_process.ndjson index 3d839cb328..7be0c1f762 100644 --- a/testdata/intake-v2/minimal_process.ndjson +++ b/testdata/intake-v2/minimal_process.ndjson @@ -2,4 +2,4 @@ { "error": {"id": "abcdef0123456789", "timestamp": "2018-08-09T15:04:05.999Z","log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}} { "span": { "id": "0123456a89012345", "trace_id": "0123456789abcdef0123456789abcdef", "transaction_id": "ab23456a89012345", "parent": 1, "name": "GET /api/types", "type": "request", "start": 1.845, "duration": 3.5642981, "stacktrace": [], "context": {} }} { "transaction": { "trace_id": "01234567890123456789abcdefabcdef", "id": "abcdef1478523690", "type": "request", "duration": 32.592981, "timestamp": "2018-08-30T18:53:27.154Z", "result": "200", "context": null, "spans": null, "sampled": null, "span_count": null }} -{ "metric": { "samples": { "go.memstats.heap.sys.bytes": { "value": 61235 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} +{ "metricset": { "samples": { "go.memstats.heap.sys.bytes": { "value": 61235 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/minimal_service.ndjson b/testdata/intake-v2/minimal_service.ndjson index 4fe6bd913b..fa25105755 100644 --- a/testdata/intake-v2/minimal_service.ndjson +++ b/testdata/intake-v2/minimal_service.ndjson @@ -1,3 +1,3 @@ {"metadata": { "service": {"name": "1234_service-12a3", "language": {"name": "ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}}}} { "error": {"id": "abcdef0123456789", "timestamp": "2018-08-09T15:04:05.999Z","log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}} -{ "metric": { "samples": { "go.memstats.heap.sys.bytes": { "value": 61235 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} +{ "metricset": { "samples": { "go.memstats.heap.sys.bytes": { "value": 61235 } }, "timestamp": "2017-05-30T18:53:42.281Z" }} diff --git a/testdata/intake-v2/optional-timestamps.ndjson b/testdata/intake-v2/optional-timestamps.ndjson index 57281ee1fa..18ad471f23 100644 --- a/testdata/intake-v2/optional-timestamps.ndjson +++ b/testdata/intake-v2/optional-timestamps.ndjson @@ -1,4 +1,4 @@ {"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"}, "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"}}}} {"transaction": {"name": "tx1", "id": "1111222233334444", "trace_id": "abcdefabcdef01234567890123456789", "duration": 12, "type": "request"}} {"span": {"name": "sp1","trace_id": "abcdefabcdef01234567890123456789", "duration": 20, "start": 10, "type": "db", "id": "0147258369abcdef", "transaction_id": "fedcba0123456789"}} -{"metric": {"samples": {"my-metric": {"value": 99}}, "timestamp": "2018-01-01T11:00:00Z"}} +{"metricset": {"samples": {"my-metric": {"value": 99}}, "timestamp": "2018-01-01T11:00:00Z"}}