Class: Sentry::Envelope::Item Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/envelope.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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.



12
13
14
15
# File 'lib/sentry/envelope.rb', line 12

def initialize(headers, payload)
  @headers = headers
  @payload = payload
end

Instance Attribute Details

#headersObject

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.



10
11
12
# File 'lib/sentry/envelope.rb', line 10

def headers
  @headers
end

#payloadObject

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.



10
11
12
# File 'lib/sentry/envelope.rb', line 10

def payload
  @payload
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



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sentry/envelope.rb', line 22

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

#data_categoryObject

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.



34
35
36
# File 'lib/sentry/envelope.rb', line 34

def data_category
  self.class.data_category(type)
end

#serializeObject

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.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sentry/envelope.rb', line 42

def serialize
  result = to_s

  if result.bytesize > MAX_SERIALIZED_PAYLOAD_SIZE
    remove_breadcrumbs!
    result = to_s
  end

  if result.bytesize > MAX_SERIALIZED_PAYLOAD_SIZE
    reduce_stacktrace!
    result = to_s
  end

  [result, result.bytesize > MAX_SERIALIZED_PAYLOAD_SIZE]
end

#size_breakdownObject

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.



58
59
60
61
62
# File 'lib/sentry/envelope.rb', line 58

def size_breakdown
  payload.map do |key, value|
    "#{key}: #{JSON.generate(value).bytesize}"
  end.join(", ")
end

#to_sObject

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.



38
39
40
# File 'lib/sentry/envelope.rb', line 38

def to_s
  [JSON.generate(@headers), @payload.is_a?(String) ? @payload : JSON.generate(@payload)].join("\n")
end

#typeObject

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.



17
18
19
# File 'lib/sentry/envelope.rb', line 17

def type
  @headers[:type] || 'event'
end