-
Notifications
You must be signed in to change notification settings - Fork 406
DI: capture expressions #5845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,073
−42
Merged
DI: capture expressions #5845
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1eaaa3c
DI: capture expressions
p-ddsign e654ddc
DI: capture expressions: full per-expression limit support + Steep sigs
p-ddsign c6b5c3c
DI: capture expressions: reuse DD_DYNAMIC_INSTRUMENTATION_MAX_TIME_TO…
p-ddsign 720d6ee
DI: capture-expression resolver honors probe-level collection_size an…
p-ddsign 46b14dc
DI: ProbeBuilder validates captureExpressions type before checking empty
p-ddsign 1223e4d
DI: method-probe capture expressions can reference arg/kwarg locals
p-ddsign 3731094
DI: thread probe-level capture limits through snapshot serialization
p-ddsign dd5b753
remove docs
f4e4a52
Wire telemetry through capture-expression evaluator and fix probe-lev…
p-ddsign f2a676a
Split CaptureLimits into its own file
p-ddsign 16784b7
DI: inject logger/telemetry into capture-expression evaluator + requi…
p-ddsign 951c8b9
DI: document types/contracts of capture-expression public surfaces
p-ddsign c177f28
DI: remove references to internal planning repo from public source
p-ddsign d98276b
DI: tighten RBS sigs and fix trailing blank line in capture_expressio…
p-ddsign 03df970
DI: update integration spec to match new ProbeNotificationBuilder sig…
p-ddsign 15a411f
DI: add end-to-end tests for capture-expression behaviors, restore op…
p-ddsign 1bcc718
DI: declare max_time_to_serialize_ms in _DI settings RBS interface
p-ddsign a223e5c
DI: drop entry.captureExpressions from method probes
p-ddsign 25fbe0c
DI: rename capture-expression timeout counter, add mid-loop test, gua…
p-ddsign f006105
DI: honor evaluateAt on capture-expression method probes
p-ddsign 536e37b
Fix StandardRB Performance/UnfreezeString violations
p-ddsign 7c1d614
DI: drop private-repo path from capture-expression comments
p-ddsign 003bb43
DI: protect entry-time capture-expression evaluation with rescue
p-ddsign e6e0c12
DI: integration coverage for probe-level capture limits
p-ddsign 5b9e104
DI: use instance_double for CaptureExpression expr in probe_spec
p-ddsign 538c4eb
Merge branch 'master' into di-capture-expressions
p-datadog 894fc41
DI: fix YARD logger type to DI::Logger facade
p-ddsign 9895aca
DI: correct capture_expression_evaluator construction comment
p-ddsign bac314e
DI: make @duration EL expansion nil-safe at entry time
p-ddsign a083101
DI: drop exit-time consumer sentence from entry-capture comment
p-ddsign dea1048
DI: trim entry-capture comment in instrumenter
p-ddsign 3dae84b
DI: apply #5945 fatal-exception handling to capture-expression rescues
p-ddsign b5cd07b
DI: inject logger into ProbeBuilder instead of Datadog.logger global
p-ddsign 2c65598
Merge remote-tracking branch 'origin/master' into di-capture-expressions
p-ddsign 81ffa25
Use ASCII characters in capture-expression comments
p-ddsign 14ee270
Use instance_double for settings in capture-limit specs
p-ddsign 89ab76a
DI: collapse duplicate capture-expression names at parse time
p-ddsign 73c860e
DI: note cross-tracer last-wins parity in dedup comment
p-ddsign 8700aac
DI: capture expressions — remove explanatory comments
p-ddsign 427a214
DI: drop .NET cross-tracer reference and timeout-stub detail from MAX…
p-ddsign 90a64e1
DI: drop Java cross-tracer reference from probe_builder_spec context
p-ddsign 1ef3cfb
DI: drop libdatadog reference from probe_builder_spec example descrip…
p-ddsign f10f3f6
Merge branch 'master' into di-capture-expressions
p-datadog 0111853
Extract capture-expression predicates and simplify limit resolution o…
p-ddsign c19b846
DI RBS: use `any` alias for diff-added arbitrary-value untyped
p-ddsign 60e8c77
Merge branch 'master' into di-capture-expressions
TonyCTHsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative "capture_limits" | ||
|
|
||
| module Datadog | ||
| module DI | ||
| class CaptureExpression | ||
| def initialize(name:, expr:, limits: nil) | ||
| @name = name | ||
| @expr = expr | ||
| @limits = limits | ||
| end | ||
|
|
||
| attr_reader :name | ||
|
|
||
| attr_reader :expr | ||
|
|
||
| attr_reader :limits | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative "capture_expression" | ||
| require_relative "capture_limits" | ||
| require_relative "fatal_exceptions" | ||
|
|
||
| module Datadog | ||
| module DI | ||
| class CaptureExpressionEvaluator | ||
| TELEMETRY_NAMESPACE = "dynamic_instrumentation" | ||
|
|
||
| def initialize(settings:, serializer:, logger:, telemetry: nil) | ||
| @settings = settings | ||
| @serializer = serializer | ||
| @logger = logger | ||
| @telemetry = telemetry | ||
| end | ||
|
|
||
| attr_reader :settings | ||
|
|
||
| attr_reader :serializer | ||
|
|
||
| attr_reader :logger | ||
|
|
||
| attr_reader :telemetry | ||
|
|
||
| def evaluate(probe, context) | ||
| budget_ns = settings.dynamic_instrumentation.max_time_to_serialize_ms * 1_000_000 | ||
| deadline_ns = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :nanosecond) + budget_ns | ||
|
|
||
| output = {} | ||
| evaluation_errors = [] | ||
|
|
||
| probe.capture_expressions.each do |capture_expression| | ||
| name = capture_expression.name | ||
|
|
||
| if ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :nanosecond) >= deadline_ns | ||
| output[name] = {notCapturedReason: "timeout"} | ||
| telemetry&.inc(TELEMETRY_NAMESPACE, "capture_expressions_skipped_by_timeout", 1) | ||
| next | ||
| end | ||
|
|
||
| begin | ||
| value = capture_expression.expr.evaluate(context) | ||
| limits = CaptureLimits.resolve( | ||
| expr_limits: capture_expression.limits, | ||
| probe: probe, | ||
| settings: settings, | ||
| ) | ||
| output[name] = serializer.serialize_value( | ||
| value, name: name, | ||
| depth: limits[:depth], | ||
| attribute_count: limits[:attribute_count], | ||
| length: limits[:length], | ||
| collection_size: limits[:collection_size], | ||
| ) | ||
| rescue Exception => exc # standard:disable Lint/RescueException | ||
| Datadog::DI.reraise_if_fatal(exc) | ||
| evaluation_errors << {expr: name, message: "#{exc.class}: #{exc.message}"} | ||
| logger.debug do | ||
| "di: probe #{probe.id}: capture expression #{name}: evaluation failed: #{exc.class}: #{exc.message}" | ||
| end | ||
| telemetry&.report(exc, description: "DI capture-expression evaluation failed") | ||
| end | ||
| end | ||
|
|
||
| [output, evaluation_errors] | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Datadog | ||
| module DI | ||
| class CaptureLimits | ||
| def initialize(max_reference_depth: nil, max_collection_size: nil, | ||
| max_length: nil, max_field_count: nil) | ||
| @max_reference_depth = max_reference_depth | ||
| @max_collection_size = max_collection_size | ||
| @max_length = max_length | ||
| @max_field_count = max_field_count | ||
| end | ||
|
|
||
| attr_reader :max_reference_depth | ||
|
|
||
| attr_reader :max_collection_size | ||
|
|
||
| attr_reader :max_length | ||
|
|
||
| attr_reader :max_field_count | ||
|
|
||
| def self.resolve(expr_limits:, probe:, settings:) | ||
| di = settings.dynamic_instrumentation | ||
| { | ||
| depth: expr_limits&.max_reference_depth || | ||
| probe.max_capture_depth || | ||
| di.max_capture_depth, | ||
| collection_size: expr_limits&.max_collection_size || | ||
| probe.max_capture_collection_size || | ||
| di.max_capture_collection_size, | ||
| length: expr_limits&.max_length || | ||
| probe.max_capture_string_length || | ||
| di.max_capture_string_length, | ||
| attribute_count: expr_limits&.max_field_count || | ||
| probe.max_capture_attribute_count || | ||
| di.max_capture_attribute_count, | ||
| } | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.