Commit a92eb02c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve Error Tracking models

A follow-up on c2a8cbe7f4c2bfce3720c0597ae076b2a4142bbd. This commit
will update event payload json schema to better match the data it will
store. Additionally it adds counter cache for error event model.
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Changelog: changed
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent bd902553
# frozen_string_literal: true
class ErrorTracking::ErrorEvent < ApplicationRecord
belongs_to :error
belongs_to :error, counter_cache: :events_count
validates :payload, json_schema: { filename: 'error_tracking_event_payload' }
......
......@@ -2,6 +2,9 @@
"description": "Error tracking event payload",
"type": "object",
"required": [],
"modules": {
"type": "object"
},
"properties": {
"event_id": {
"type": "string"
......@@ -73,28 +76,7 @@
}
},
"trace": {
"type": "object",
"required": [],
"properties": {
"trace_id": {
"type": "string"
},
"span_id": {
"type": "string"
},
"parent_span_id": {
"type": "string"
},
"description": {
"type": "string"
},
"op": {
"type": "string"
},
"status": {
"type": "string"
}
}
"type": "object"
}
}
},
......@@ -118,52 +100,13 @@
"type": "string"
},
"data": {
"type": "object",
"required": [],
"properties": {
"controller": {
"type": "string"
},
"action": {
"type": "string"
},
"params": {
"type": "object",
"required": [],
"properties": {
"controller": {
"type": "string"
},
"action": {
"type": "string"
}
}
},
"format": {
"type": "string"
},
"method": {
"type": "string"
},
"path": {
"type": "string"
},
"start_timestamp": {
"type": "number"
}
}
},
"level": {
"type": "string"
"type": "object"
},
"message": {
"type": "string"
},
"timestamp": {
"type": "number"
},
"type": {
"type": "string"
}
}
}
......@@ -199,37 +142,7 @@
"type": "string"
},
"headers": {
"type": "object",
"required": [],
"properties": {
"Host": {
"type": "string"
},
"User-Agent": {
"type": "string"
},
"Accept": {
"type": "string"
},
"Accept-Language": {
"type": "string"
},
"Accept-Encoding": {
"type": "string"
},
"Referer": {
"type": "string"
},
"Turbolinks-Referrer": {
"type": "string"
},
"Connection": {
"type": "string"
},
"X-Request-Id": {
"type": "string"
}
}
"type": "object"
},
"env": {
"type": "object",
......@@ -290,25 +203,19 @@
"type": "number"
},
"in_app": {
"type": "string"
"type": "boolean"
},
"filename": {
"type": "string"
},
"pre_context": {
"type": "array",
"items": {
"type": "string"
}
"type": "array"
},
"context_line": {
"type": "string"
},
"post_context": {
"type": "array",
"items": {
"type": "string"
}
"type": "array"
}
}
}
......
# frozen_string_literal: true
class AddErrorTrackingCounterCache < ActiveRecord::Migration[6.1]
def up
add_column :error_tracking_errors, :events_count, :bigint, null: false, default: 0
end
def down
remove_column :error_tracking_errors, :events_count
end
end
ed0c0dc015e7c3457248303b8b478c8d259d6a800a2bfed8b05b1f976b6794a7
\ No newline at end of file
......@@ -12767,6 +12767,7 @@ CREATE TABLE error_tracking_errors (
platform text,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
events_count bigint DEFAULT 0 NOT NULL,
CONSTRAINT check_18a758e537 CHECK ((char_length(name) <= 255)),
CONSTRAINT check_b5cb4d3888 CHECK ((char_length(actor) <= 255)),
CONSTRAINT check_c739788b12 CHECK ((char_length(description) <= 1024)),
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment