Skip to content

Commit

Permalink
[v2] accept unix epoch timestamps in microseconds
Browse files Browse the repository at this point in the history
* makes "start" optional if "timestamp" is given for v2
* if "timestamp" is not given, it is set to the sum of req-time + start
* adds timestamp.us (long) to span, transaction and error documents (both v1 and v2)
  • Loading branch information
Ron cohen committed Oct 1, 2018
1 parent 388353b commit 126e9b3
Show file tree
Hide file tree
Showing 85 changed files with 2,099 additions and 1,683 deletions.
10 changes: 10 additions & 0 deletions _meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
type: keyword
description: Processor event.

- name: timestamp
type: group
description:
fields:
- name: us
type: long
count: 1
description: >
Timestamp of the event in microseconds since Unix epoch.
- name: context
type: group
description: >
Expand Down
3 changes: 3 additions & 0 deletions docs/data/elasticsearch/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@
"event": "error",
"name": "error"
},
"timestamp": {
"us": 1494342245999999
},
"transaction": {
"id": "945254c5-67a5-417e-8a4e-aa29efcbfb79"
}
Expand Down
3 changes: 3 additions & 0 deletions docs/data/elasticsearch/span.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
},
"type": "db.postgresql.query"
},
"timestamp": {
"us": 1496170407154000
},
"transaction": {
"id": "945254c5-67a5-417e-8a4e-aa29efcbfb79"
}
Expand Down
3 changes: 3 additions & 0 deletions docs/data/elasticsearch/transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
"event": "transaction",
"name": "transaction"
},
"timestamp": {
"us": 1496170407154000
},
"transaction": {
"duration": {
"us": 32592
Expand Down
16 changes: 16 additions & 0 deletions docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ type: keyword
Processor event.
--
[float]
== timestamp fields
None
*`timestamp.us`*::
+
--
type: long
Timestamp of the event in microseconds since Unix epoch.
--
[float]
Expand Down
8 changes: 1 addition & 7 deletions docs/spec/errors/common_error.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$id": "docs/spec/errors/error.json",
"$id": "docs/spec/errors/common_error.json",
"type": "object",
"description": "Data captured by an agent representing an event occurring in a monitored service",
"properties": {
Expand Down Expand Up @@ -86,12 +86,6 @@
}
},
"required": ["message"]
},
"timestamp": {
"type": ["string","null"],
"format": "date-time",
"pattern": "Z$",
"description": "Recorded time of the error, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
}
},
"anyOf": [
Expand Down
6 changes: 6 additions & 0 deletions docs/spec/errors/v1_error.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
}
}
},
"timestamp": {
"type": ["string","null"],
"format": "date-time",
"pattern": "Z$",
"description": "Recorded time of the error, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion docs/spec/errors/v2_error.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"description": "Hex encoded 64 random bits ID of the parent transaction or span. Must be present if trace_id and transaction_id are set.",
"type": ["string", "null"],
"maxLength": 1024
},
"timestamp": {
"description": "Recorded time of the span, UTC based and formatted as microseconds since Unix epoch",
"type": ["integer", "null"]
}
},
"allOf": [
Expand All @@ -36,7 +40,6 @@
"then": { "required": ["parent_id"], "properties": {"parent_id": { "type": "string" }}} },
{ "if": {"required": ["parent_id"], "properties": {"parent_id": { "type": "string" }}},
"then": { "required": ["transaction_id"], "properties": {"transaction_id": { "type": "string" }}} }

]
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "docs/spec/metricsets/metricset.json",
"$id": "docs/spec/metricsets/common_metricset.json",
"type": "object",
"description": "Metric data captured by an APM agent",
"properties": {
Expand All @@ -24,13 +24,7 @@
}
},
"additionalProperties": false
},
"timestamp": {
"type": "string",
"format": "date-time",
"pattern": "Z$",
"description": "Recorded time of the metric, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
}
},
"required": ["samples", "timestamp"]
"required": ["samples"]
}
2 changes: 1 addition & 1 deletion docs/spec/metricsets/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"metrics": {
"type": "array",
"items": {
"$ref": "metricset.json"
"$ref": "v1_metricset.json"
},
"minItems": 1
},
Expand Down
20 changes: 20 additions & 0 deletions docs/spec/metricsets/v1_metricset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$id": "docs/spec/errors/v2_error.json",
"type": "object",
"description": "Data captured by an agent representing an event occurring in a monitored service",
"allOf": [

{ "$ref": "common_metricset.json" },
{
"properties": {
"timestamp": {
"type": "string",
"format": "date-time",
"pattern": "Z$",
"description": "Recorded time of the metric, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
}
},
"required": ["timestamp"]
}
]
}
19 changes: 19 additions & 0 deletions docs/spec/metricsets/v2_metricset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$id": "docs/spec/errors/v2_error.json",
"type": "object",
"description": "Data captured by an agent representing an event occurring in a monitored service",
"allOf": [

{ "$ref": "common_metricset.json" },
{
"properties": {

"timestamp": {
"description": "Recorded time of the span, UTC based and formatted as microseconds since Unix epoch",
"type": "integer"
}
},
"required": ["timestamp"]
}
]
}
6 changes: 1 addition & 5 deletions docs/spec/spans/common_span.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@
},
"minItems": 0
},
"start": {
"type": "number",
"description": "Offset relative to the transaction's timestamp identifying the start of the span, in milliseconds"
},
"type": {
"type": "string",
"description": "Keyword of specific relevance in the service's domain (eg: 'db.postgresql.query', 'template.erb', etc)",
"maxLength": 1024
}
},
"required": ["duration", "name", "start", "type"]
"required": ["duration", "name", "type"]
}
5 changes: 5 additions & 0 deletions docs/spec/spans/v1_span.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
"parent": {
"type": ["integer", "null"],
"description": "The ID of the parent of the span."
},
"start": {
"type": "number",
"description": "Offset relative to the transaction's timestamp identifying the start of the span, in milliseconds"
}
},
"required": ["start"],
"dependencies": {
"parent": {
"required": ["id"]
Expand Down
15 changes: 11 additions & 4 deletions docs/spec/spans/v2_span.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@
"maxLength": 1024
},
"timestamp": {
"description": "Recorded time of the span, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ",
"type": ["string", "null"],
"pattern": "Z$",
"format": "date-time"
"description": "Recorded time of the span, UTC based and formatted as microseconds since Unix epoch",
"type": ["integer", "null"]
},
"start": {
"type": ["number", "null"],
"description": "Offset relative to the transaction's timestamp identifying the start of the span, in milliseconds"
}
},
"required": ["id", "transaction_id", "trace_id", "parent_id"]
},
{ "anyOf":[
{"required": ["timestamp"], "properties": {"timestamp": { "type": "integer" }}},
{"required": ["start"], "properties": {"start": { "type": "number" }}}
]
}
]
}
6 changes: 0 additions & 6 deletions docs/spec/transactions/common_transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
"description": "The result of the transaction. For HTTP-related transactions, this should be the status code formatted like 'HTTP 2xx'.",
"maxLength": 1024
},
"timestamp": {
"type": ["string", "null"],
"pattern": "Z$",
"format": "date-time",
"description": "Recorded time of the transaction, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
},
"type": {
"type": "string",
"description": "Keyword of specific relevance in the service's domain (eg: 'request', 'backgroundjob', etc)",
Expand Down
6 changes: 6 additions & 0 deletions docs/spec/transactions/v1_transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
}
}
}
},
"timestamp": {
"type": ["string", "null"],
"pattern": "Z$",
"format": "date-time",
"description": "Recorded time of the transaction, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
}
},
"required": ["id"]
Expand Down
4 changes: 4 additions & 0 deletions docs/spec/transactions/v2_transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
}
},
"required": ["started"]
},
"timestamp": {
"description": "Recorded time of the span, UTC based and formatted as microseconds since Unix epoch",
"type": ["integer", "null"]
}
},
"required": ["id", "trace_id", "span_count"]
Expand Down
Loading

0 comments on commit 126e9b3

Please sign in to comment.