Class: Sentry::Envelope::Item Private
- Inherits:
-
Object
- Object
- Sentry::Envelope::Item
- Defined in:
- lib/sentry/envelope/item.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- STACKTRACE_FRAME_LIMIT_ON_OVERSIZED_PAYLOAD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
500
- MAX_SERIALIZED_PAYLOAD_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1024 * 1000
- SIZE_LIMITS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Hash.new(MAX_SERIALIZED_PAYLOAD_SIZE).update( "profile" => 1024 * 1000 * 50 )
Instance Attribute Summary collapse
- #data_category ⇒ Object readonly private
- #headers ⇒ Object readonly private
- #payload ⇒ Object readonly private
- #size_limit ⇒ Object readonly private
- #type ⇒ Object readonly private
Class Method Summary collapse
-
.data_category(type) ⇒ Object
private
rate limits and client reports use the data_category rather than envelope item type.
Instance Method Summary collapse
-
#initialize(headers, payload) ⇒ Item
constructor
private
A new instance of Item.
- #serialize ⇒ Object private
- #size_breakdown ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(headers, payload) ⇒ Item
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Item.
28 29 30 31 32 33 34 |
# File 'lib/sentry/envelope/item.rb', line 28 def initialize(headers, payload) @headers = headers @payload = payload @type = headers[:type] || "event" @data_category = self.class.data_category(type) @size_limit = SIZE_LIMITS[type] end |
Instance Attribute Details
#data_category ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/sentry/envelope/item.rb', line 13 def data_category @data_category end |
#headers ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/sentry/envelope/item.rb', line 13 def headers @headers end |
#payload ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/sentry/envelope/item.rb', line 13 def payload @payload end |
#size_limit ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/sentry/envelope/item.rb', line 13 def size_limit @size_limit end |
#type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/sentry/envelope/item.rb', line 13 def type @type end |
Class Method Details
.data_category(type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rate limits and client reports use the data_category rather than envelope item type
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sentry/envelope/item.rb', line 16 def self.data_category(type) case type when "session", "attachment", "transaction", "profile", "span" then type when "sessions" then "session" when "check_in" then "monitor" when "statsd", "metric_meta" then "metric_bucket" when "event" then "error" when "client_report" then "internal" else "default" end end |
Instance Method Details
#serialize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sentry/envelope/item.rb', line 40 def serialize result = to_s if result.bytesize > size_limit result = to_s end if result.bytesize > size_limit reduce_stacktrace! result = to_s end [result, result.bytesize > size_limit] end |
#size_breakdown ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 |
# File 'lib/sentry/envelope/item.rb', line 56 def size_breakdown payload.map do |key, value| "#{key}: #{JSON.generate(value).bytesize}" end.join(", ") end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/sentry/envelope/item.rb', line 36 def to_s [JSON.generate(@headers), @payload.is_a?(String) ? @payload : JSON.generate(@payload)].join("\n") end |