From e97a23c5dec75a3625ffb07cc14eb0f7459bade4 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev <156273877+p-datadog@users.noreply.github.com> Date: Thu, 19 Sep 2024 07:56:19 -0400 Subject: [PATCH] DEBUG-2334 add types for dynamic instrumentation settings (#3924) Co-authored-by: Oleg Pudeyev --- lib/datadog/di/redactor.rb | 7 ++-- sig/datadog/core/configuration/settings.rbs | 40 +++++++++++++++++++++ sig/datadog/di/redactor.rbs | 2 +- sig/datadog/di/serializer.rbs | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/lib/datadog/di/redactor.rb b/lib/datadog/di/redactor.rb index 0c3bdb52f66..1a3fc15c73e 100644 --- a/lib/datadog/di/redactor.rb +++ b/lib/datadog/di/redactor.rb @@ -72,10 +72,13 @@ def redacted_type_names_regexp if name.start_with?("::") # :: prefix is redundant, all names are expected to be # fully-qualified. - name = name[2...name.length] + # + # Defaulting to empty string is for steep. + name = name[2...name.length] || "" end if name.end_with?("*") - name = name[0..-2] + # Defaulting to empty string is for steep. + name = name[0..-2] || "" suffix = ".*" else suffix = "" diff --git a/sig/datadog/core/configuration/settings.rbs b/sig/datadog/core/configuration/settings.rbs index fe07d63c6db..48d9617ac7c 100644 --- a/sig/datadog/core/configuration/settings.rbs +++ b/sig/datadog/core/configuration/settings.rbs @@ -54,6 +54,44 @@ module Datadog def templates: () -> _TemplatesBlock end + interface _DI + def enabled: () -> bool + + def enabled=: (bool) -> void + + def untargeted_trace_points: () -> bool + + def untargeted_trace_points=: (bool) -> void + + def propagate_all_exceptions: () -> bool + + def propagate_all_exceptions=: (bool) -> void + + def redacted_identifiers: () -> Array[String] + + def redacted_identifiers=: (Array[String]) -> void + + def redacted_type_names: () -> Array[String] + + def redacted_type_names=: (Array[String]) -> void + + def max_capture_depth: () -> Integer + + def max_capture_depth=: (Integer) -> void + + def max_capture_collection_size: () -> Integer + + def max_capture_collection_size=: (Integer) -> void + + def max_capture_string_length: () -> Integer + + def max_capture_string_length=: (Integer) -> void + + def max_capture_attribute_count: () -> Integer + + def max_capture_attribute_count=: (Integer) -> void + end + interface _TemplatesBlock def html=: (::String) -> void @@ -84,6 +122,8 @@ module Datadog def appsec: (?untyped? options) -> Datadog::Core::Configuration::Settings::_AppSec + def dynamic_instrumentation: (?untyped? options) -> Datadog::Core::Configuration::Settings::_DI + def remote: (?untyped? options) -> Datadog::Core::Configuration::Settings::_Remote end end diff --git a/sig/datadog/di/redactor.rbs b/sig/datadog/di/redactor.rbs index b568e4d139f..5337bd3d0a2 100644 --- a/sig/datadog/di/redactor.rbs +++ b/sig/datadog/di/redactor.rbs @@ -9,7 +9,7 @@ module Datadog def initialize: (untyped settings) -> void - attr_reader settings: untyped + attr_reader settings: Datadog::Core::Configuration::Settings def redact_identifier?: (String name) -> (true | false) diff --git a/sig/datadog/di/serializer.rbs b/sig/datadog/di/serializer.rbs index e3060f5e959..54f075aa43a 100644 --- a/sig/datadog/di/serializer.rbs +++ b/sig/datadog/di/serializer.rbs @@ -7,7 +7,7 @@ module Datadog def initialize: (untyped settings, untyped redactor) -> void - attr_reader settings: untyped + attr_reader settings: Datadog::Core::Configuration::Settings attr_reader redactor: untyped def serialize_args: (untyped args, untyped kwargs) -> untyped