Class: Datadog::DI::SnapshotPruner Private
- Inherits:
-
Object
- Object
- Datadog::DI::SnapshotPruner
- Defined in:
- lib/datadog/di/snapshot_pruner.rb,
lib/datadog/di/snapshot_pruner/node.rb,
lib/datadog/di/snapshot_pruner/parser.rb,
lib/datadog/di/snapshot_pruner/node_queue.rb
Overview
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.
Reduces an encoded snapshot below a byte limit by replacing captured value objects with the pruned marker, operating directly on the encoded bytes. The largest, most deeply nested captured values are replaced first.
Defined Under Namespace
Classes: Node, NodeQueue, Parser
Constant Summary collapse
- PRUNED_MARKER =
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.
Replacement for each pruned object.
'{"pruned":true}'- MIN_LEVEL =
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.
Shallowest nesting level that is pruned. The snapshot payload nests
debugger,snapshot,capturesand the capture sets above the captured values, which start at level 5 (method probeargumentsandlocalsmembers, line probe line objects). Applying the level to promoted parents as well keepscapturesand the capture sets. 5
Instance Attribute Summary collapse
-
#parser ⇒ Parser
readonly
private
The parser that builds the object tree of an encoded snapshot.
Instance Method Summary collapse
-
#initialize ⇒ void
constructor
private
Initializes the pruner.
-
#prune(json, max_size:) ⇒ String
private
Prunes an encoded snapshot that exceeds
max_size.
Constructor Details
#initialize ⇒ void
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.
Initializes the pruner.
29 30 31 |
# File 'lib/datadog/di/snapshot_pruner.rb', line 29 def initialize @parser = Parser.new end |
Instance Attribute Details
#parser ⇒ Parser (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.
The parser that builds the object tree of an encoded snapshot.
35 36 37 |
# File 'lib/datadog/di/snapshot_pruner.rb', line 35 def parser @parser end |
Instance Method Details
#prune(json, max_size:) ⇒ String
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.
Prunes an encoded snapshot that exceeds max_size.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/datadog/di/snapshot_pruner.rb', line 46 def prune(json, max_size:) excess = json.bytesize - max_size return json if excess <= 0 root = parser.parse(json) selected_nodes = select_nodes(root, excess) return json if selected_nodes.empty? rewrite(json, selected_nodes) end |