Class: Sentry::DataCollection
- Inherits:
-
Object
- Object
- Sentry::DataCollection
- Defined in:
- lib/sentry/data_collection.rb,
lib/sentry/data_collection/key_value_collection.rb
Defined Under Namespace
Classes: GraphQL, HttpHeaders, KeyValueCollection
Constant Summary collapse
- MODES =
Configuration for the categories of data collected by the SDK. Replacement for send_default_pii. Spec: https://develop.sentry.dev/sdk/foundations/client/data-collection/
%i[off deny_list allow_list].freeze
- PII_HEADER_SNIPPETS =
%w[forwarded -ip _ip remote via _user -user].freeze
- BODY_TYPES =
%i[ incoming_request outgoing_request incoming_response outgoing_response ].freeze
Instance Attribute Summary collapse
-
#cookies ⇒ Boolean, KeyValueCollection
A boolean is shorthand for
mode: :deny_list(true) ormode: :off(false). - #database_query_data ⇒ Boolean
- #frame_context_lines ⇒ Integer
- #graphql ⇒ GraphQL
-
#http_bodies ⇒ Array<Symbol>
Containing values from BODY_TYPES.
- #http_headers ⇒ HttpHeaders
- #queues ⇒ Boolean
-
#stack_frame_variables ⇒ Boolean, KeyValueCollection
A boolean is shorthand for
mode: :deny_list(true) ormode: :off(false). -
#url_query_params ⇒ Boolean, KeyValueCollection
A boolean is shorthand for
mode: :deny_list(true) ormode: :off(false). - #user_info ⇒ Boolean
Class Method Summary collapse
-
.backfill(configuration) ⇒ Object
Builds data collection settings compatible with the legacy send_default_pii configuration.
- .default_filter ⇒ Object
-
.filter(values) ⇒ Object
Filters key-value data using the default sensitive denylist.
Instance Method Summary collapse
-
#backfill_stack_frame_variables(configuration) ⇒ Object
Copies the legacy stack frame variable configuration.
-
#collect_incoming_http_body? ⇒ Boolean
Returns whether incoming HTTP request bodies should be collected.
-
#collect_outgoing_http_body? ⇒ Boolean
Returns whether outgoing HTTP request bodies should be collected.
-
#collect_stack_frame_variables? ⇒ Boolean
Returns whether stack frame local variables should be captured.
-
#initialize ⇒ DataCollection
constructor
A new instance of DataCollection.
Constructor Details
#initialize ⇒ DataCollection
Returns a new instance of DataCollection.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/sentry/data_collection.rb', line 153 def initialize @user_info = true self. = KeyValueCollection.new(mode: :deny_list, terms: nil) @http_headers = HttpHeaders.new( request: KeyValueCollection.new(mode: :deny_list, terms: nil), response: KeyValueCollection.new(mode: :deny_list, terms: nil) ) @http_bodies = BODY_TYPES.dup self.url_query_params = KeyValueCollection.new(mode: :deny_list, terms: nil) @database_query_data = true @graphql = GraphQL.new(document: true, variables: true) @queues = true self.stack_frame_variables = false @frame_context_lines = 3 end |
Instance Attribute Details
#cookies ⇒ Boolean, KeyValueCollection
A boolean is shorthand for mode: :deny_list (true) or mode: :off (false).
84 85 86 |
# File 'lib/sentry/data_collection.rb', line 84 def @cookies end |
#database_query_data ⇒ Boolean
101 102 103 |
# File 'lib/sentry/data_collection.rb', line 101 def database_query_data @database_query_data end |
#frame_context_lines ⇒ Integer
118 119 120 |
# File 'lib/sentry/data_collection.rb', line 118 def frame_context_lines @frame_context_lines end |
#graphql ⇒ GraphQL
105 106 107 |
# File 'lib/sentry/data_collection.rb', line 105 def graphql @graphql end |
#http_bodies ⇒ Array<Symbol>
Returns containing values from BODY_TYPES.
92 93 94 |
# File 'lib/sentry/data_collection.rb', line 92 def http_bodies @http_bodies end |
#http_headers ⇒ HttpHeaders
88 89 90 |
# File 'lib/sentry/data_collection.rb', line 88 def http_headers @http_headers end |
#queues ⇒ Boolean
109 110 111 |
# File 'lib/sentry/data_collection.rb', line 109 def queues @queues end |
#stack_frame_variables ⇒ Boolean, KeyValueCollection
A boolean is shorthand for mode: :deny_list (true) or mode: :off (false).
114 115 116 |
# File 'lib/sentry/data_collection.rb', line 114 def stack_frame_variables @stack_frame_variables end |
#url_query_params ⇒ Boolean, KeyValueCollection
A boolean is shorthand for mode: :deny_list (true) or mode: :off (false).
97 98 99 |
# File 'lib/sentry/data_collection.rb', line 97 def url_query_params @url_query_params end |
#user_info ⇒ Boolean
79 80 81 |
# File 'lib/sentry/data_collection.rb', line 79 def user_info @user_info end |
Class Method Details
.backfill(configuration) ⇒ Object
Builds data collection settings compatible with the legacy send_default_pii configuration.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/sentry/data_collection.rb', line 131 def self.backfill(configuration) data_collection = new data_collection.backfill_stack_frame_variables(configuration) return data_collection if configuration.send_default_pii # TODO-neel-data map to exact ruby behaviour for backwards compat behavior data_collection.user_info = false data_collection..mode = :off data_collection.http_headers.request.mode = :deny_list data_collection.http_headers.request.terms = PII_HEADER_SNIPPETS data_collection.http_headers.response.mode = :deny_list data_collection.http_headers.response.terms = PII_HEADER_SNIPPETS data_collection.http_bodies = [] data_collection.url_query_params.mode = :off data_collection.graphql.document = false data_collection.graphql.variables = false data_collection.database_query_data = false data_collection.queues = false data_collection.frame_context_lines = configuration.context_lines data_collection end |
.default_filter ⇒ Object
125 126 127 |
# File 'lib/sentry/data_collection.rb', line 125 def self.default_filter @default_filter ||= KeyValueCollection.new(mode: :deny_list, terms: nil) end |
.filter(values) ⇒ Object
Filters key-value data using the default sensitive denylist.
121 122 123 |
# File 'lib/sentry/data_collection.rb', line 121 def self.filter(values) default_filter.filter(values, cookie: false) end |
Instance Method Details
#backfill_stack_frame_variables(configuration) ⇒ Object
Copies the legacy stack frame variable configuration.
170 171 172 |
# File 'lib/sentry/data_collection.rb', line 170 def backfill_stack_frame_variables(configuration) self.stack_frame_variables = configuration.include_local_variables end |
#collect_incoming_http_body? ⇒ Boolean
Returns whether incoming HTTP request bodies should be collected. nil implies all BODY_TYPES according to spec
193 194 195 |
# File 'lib/sentry/data_collection.rb', line 193 def collect_incoming_http_body? http_bodies.nil? || http_bodies.include?(:incoming_request) end |
#collect_outgoing_http_body? ⇒ Boolean
Returns whether outgoing HTTP request bodies should be collected. nil implies all BODY_TYPES according to spec
199 200 201 |
# File 'lib/sentry/data_collection.rb', line 199 def collect_outgoing_http_body? http_bodies.nil? || http_bodies.include?(:outgoing_request) end |
#collect_stack_frame_variables? ⇒ Boolean
Returns whether stack frame local variables should be captured.
175 176 177 |
# File 'lib/sentry/data_collection.rb', line 175 def collect_stack_frame_variables? stack_frame_variables.mode != :off end |