diff --git a/Steepfile b/Steepfile index 27b00ccfc98..23076c9885e 100644 --- a/Steepfile +++ b/Steepfile @@ -93,25 +93,6 @@ target :datadog do ignore 'lib/datadog/core/pin.rb' ignore 'lib/datadog/core/runtime/ext.rb' ignore 'lib/datadog/core/runtime/metrics.rb' - ignore 'lib/datadog/core/telemetry/client.rb' - ignore 'lib/datadog/core/telemetry/collector.rb' - ignore 'lib/datadog/core/telemetry/emitter.rb' - ignore 'lib/datadog/core/telemetry/event.rb' - ignore 'lib/datadog/core/telemetry/ext.rb' - ignore 'lib/datadog/core/telemetry/heartbeat.rb' - ignore 'lib/datadog/core/telemetry/http/adapters/net.rb' - ignore 'lib/datadog/core/telemetry/http/env.rb' - ignore 'lib/datadog/core/telemetry/http/ext.rb' - ignore 'lib/datadog/core/telemetry/http/response.rb' - ignore 'lib/datadog/core/telemetry/http/transport.rb' - ignore 'lib/datadog/core/telemetry/v1/app_event.rb' - ignore 'lib/datadog/core/telemetry/v1/application.rb' - ignore 'lib/datadog/core/telemetry/v1/configuration.rb' - ignore 'lib/datadog/core/telemetry/v1/dependency.rb' - ignore 'lib/datadog/core/telemetry/v1/host.rb' - ignore 'lib/datadog/core/telemetry/v1/integration.rb' - ignore 'lib/datadog/core/telemetry/v1/product.rb' - ignore 'lib/datadog/core/telemetry/v1/telemetry_request.rb' ignore 'lib/datadog/core/transport/ext.rb' ignore 'lib/datadog/core/transport/http/adapters/net.rb' ignore 'lib/datadog/core/transport/http/adapters/registry.rb' diff --git a/lib/datadog/core/telemetry/event.rb b/lib/datadog/core/telemetry/event.rb index 40fa9d95554..49b292878bb 100644 --- a/lib/datadog/core/telemetry/event.rb +++ b/lib/datadog/core/telemetry/event.rb @@ -38,6 +38,7 @@ def payload(seq_id) private def products + # @type var products: Hash[Symbol, Hash[Symbol, Object]] products = { appsec: { enabled: Datadog::AppSec.enabled?, diff --git a/lib/datadog/core/telemetry/heartbeat.rb b/lib/datadog/core/telemetry/heartbeat.rb index bf94318059a..b2129504e68 100644 --- a/lib/datadog/core/telemetry/heartbeat.rb +++ b/lib/datadog/core/telemetry/heartbeat.rb @@ -6,7 +6,7 @@ module Datadog module Core module Telemetry - # Periodically (every DEFAULT_INTERVAL_SECONDS) sends a heartbeat event to the telemetry API. + # Periodically sends a heartbeat event to the telemetry API. class Heartbeat < Core::Worker include Core::Workers::Polling diff --git a/sig/datadog/core.rbs b/sig/datadog/core.rbs index 230abdce92e..410f4f2cd29 100644 --- a/sig/datadog/core.rbs +++ b/sig/datadog/core.rbs @@ -3,4 +3,5 @@ module Datadog end extend Core::Configuration + extend Tracing::Contrib::Extensions::Helpers end diff --git a/sig/datadog/core/telemetry/client.rbs b/sig/datadog/core/telemetry/client.rbs index bc572c05a87..9bd2f4a97cc 100644 --- a/sig/datadog/core/telemetry/client.rbs +++ b/sig/datadog/core/telemetry/client.rbs @@ -2,37 +2,37 @@ module Datadog module Core module Telemetry class Client + @enabled: bool @dependency_collection: bool @started: bool @stopped: bool - - attr_reader emitter: untyped + @emitter: Datadog::Core::Telemetry::Emitter + @unsupported: bool + @worker: Datadog::Core::Telemetry::Heartbeat attr_reader enabled: bool attr_reader unsupported: bool - attr_reader worker: untyped - include Core::Utils::Forking def initialize: (heartbeat_interval_seconds: Numeric, dependency_collection: bool, enabled: bool) -> void - def disable!: () -> untyped + def disable!: () -> void def client_configuration_change!: (Enumerable[[String, Numeric | bool | String]] changes) -> void - def started!: () -> (nil | untyped) + def started!: () -> void - def emit_closing!: () -> (nil | untyped) + def emit_closing!: () -> void - def stop!: () -> (nil | untyped) + def stop!: () -> void - def integrations_change!: () -> (nil | untyped) + def integrations_change!: () -> void private - def heartbeat!: () -> (nil | untyped) + def heartbeat!: () -> void end end end diff --git a/sig/datadog/core/telemetry/emitter.rbs b/sig/datadog/core/telemetry/emitter.rbs index fa1eb05534d..e1d4320d763 100644 --- a/sig/datadog/core/telemetry/emitter.rbs +++ b/sig/datadog/core/telemetry/emitter.rbs @@ -8,7 +8,7 @@ module Datadog extend Core::Utils::Forking def initialize: (?http_transport: untyped) -> void - def request: (String request_type, data: Object?) -> Datadog::Core::Telemetry::Http::Adapters::Net::Response + def request: (Datadog::Core::Telemetry::Event::Base event) -> Datadog::Core::Telemetry::Http::Adapters::Net::Response def self.sequence: () -> untyped end end diff --git a/sig/datadog/core/telemetry/event.rbs b/sig/datadog/core/telemetry/event.rbs index ba45df34aba..4e0e3824109 100644 --- a/sig/datadog/core/telemetry/event.rbs +++ b/sig/datadog/core/telemetry/event.rbs @@ -3,8 +3,57 @@ module Datadog module Telemetry class Event class Base - def payload: (int seq_id) -> ::Hash[Symbol, Object] - def type: -> string + def payload: (int seq_id) -> Hash[Symbol, untyped] + def type: -> String? + end + + class AppStarted < Base + TARGET_OPTIONS: Array[String] + + @seq_id: int + + private + + def products: -> Hash[Symbol, untyped] + + def configuration: -> Array[Hash[Symbol, untyped]] + + def agent_transport: (untyped config) -> String + + def conf_value: (String name, Object value, ?String origin) -> Hash[Symbol, untyped] + + def to_value: (Object value) -> Object + + def install_signature: -> Hash[Symbol, Object] + end + + class AppDependenciesLoaded < Base + private + + def dependencies: -> Array[Hash[Symbol, String]] + end + + class AppIntegrationsChange < Base + private + + def integrations: -> Array[Hash[Symbol, string]] + + def patch_error: (untyped integration) -> String + end + + class AppClientConfigurationChange < Base + @changes: Enumerable[[String, Numeric | bool | String | int]] + @origin: String + + def initialize: (Enumerable[[String, Numeric | bool | String]] changes, String origin) -> void + + def configuration: (int seq_id) -> Array[Hash[Symbol, untyped]] + end + + class AppHeartbeat < Base + end + + class AppClosing < Base end end end diff --git a/sig/datadog/core/telemetry/heartbeat.rbs b/sig/datadog/core/telemetry/heartbeat.rbs index e1fcaae79fe..b89aeedca8b 100644 --- a/sig/datadog/core/telemetry/heartbeat.rbs +++ b/sig/datadog/core/telemetry/heartbeat.rbs @@ -3,16 +3,17 @@ module Datadog module Telemetry class Heartbeat < Core::Worker include Core::Workers::Polling + include Core::Workers::Async::Thread + include Core::Workers::Async::Thread::PrependedMethods + include Core::Workers::IntervalLoop - DEFAULT_INTERVAL_SECONDS: 60 + def initialize: (?enabled: bool, heartbeat_interval_seconds: Numeric) ?{ () -> void } -> void - def initialize: (?enabled: bool, ?interval: untyped) ?{ () -> untyped } -> void - - def loop_wait_before_first_iteration?: () -> true + def loop_wait_before_first_iteration?: () -> bool? private - def start: () -> untyped + def start: () -> void end end end diff --git a/sig/datadog/core/telemetry/http/adapters/net.rbs b/sig/datadog/core/telemetry/http/adapters/net.rbs index e3e57cf0acf..5cf50e53adf 100644 --- a/sig/datadog/core/telemetry/http/adapters/net.rbs +++ b/sig/datadog/core/telemetry/http/adapters/net.rbs @@ -4,21 +4,24 @@ module Datadog module Http module Adapters class Net - attr_reader hostname: untyped + type response = Datadog::Core::Telemetry::Http::Adapters::Net::Response | ::Datadog::Core::Telemetry::Http::InternalErrorResponse - attr_reader port: untyped + attr_reader hostname: String - attr_reader timeout: untyped + attr_reader port: Integer? - attr_reader ssl: untyped + attr_reader timeout: Float | Integer + + attr_reader ssl: bool DEFAULT_TIMEOUT: 30 - def initialize: (hostname: untyped, ?port: untyped?, ?timeout: untyped, ?ssl: bool) -> void + def initialize: (hostname: String, ?port: Integer?, ?timeout: Float | Integer, ?ssl: bool?) -> void + + def open: () { (::Net::HTTP http) -> ::Net::HTTPResponse } -> untyped - def open: () ?{ () -> untyped } -> untyped + def post: (untyped env) -> response - def post: (untyped env) -> Datadog::Core::Telemetry::Http::Adapters::Net::Response class Response include Datadog::Core::Telemetry::Http::Response diff --git a/sig/datadog/core/telemetry/http/ext.rbs b/sig/datadog/core/telemetry/http/ext.rbs index d471905fe2f..22cea7d1fd0 100644 --- a/sig/datadog/core/telemetry/http/ext.rbs +++ b/sig/datadog/core/telemetry/http/ext.rbs @@ -13,6 +13,12 @@ module Datadog HEADER_DD_TELEMETRY_REQUEST_TYPE: "DD-Telemetry-Request-Type" + HEADER_CLIENT_LIBRARY_LANGUAGE: "DD-Client-Library-Language" + + HEADER_CLIENT_LIBRARY_VERSION: "DD-Client-Library-Version" + + HEADER_TELEMETRY_DEBUG_ENABLED: "DD-Telemetry-Debug-Enabled" + CONTENT_TYPE_APPLICATION_JSON: "application/json" API_VERSION: "v1" diff --git a/sig/datadog/core/telemetry/http/response.rbs b/sig/datadog/core/telemetry/http/response.rbs index 95e92044cae..4113c007214 100644 --- a/sig/datadog/core/telemetry/http/response.rbs +++ b/sig/datadog/core/telemetry/http/response.rbs @@ -9,6 +9,8 @@ module Datadog def unsupported?: () -> nil + def code: () -> nil + def not_found?: () -> nil def client_error?: () -> nil diff --git a/sig/datadog/core/telemetry/http/transport.rbs b/sig/datadog/core/telemetry/http/transport.rbs index 2a707e66e48..d6ac33f5a40 100644 --- a/sig/datadog/core/telemetry/http/transport.rbs +++ b/sig/datadog/core/telemetry/http/transport.rbs @@ -3,23 +3,25 @@ module Datadog module Telemetry module Http class Transport - attr_reader host: untyped + @adapter: Http::Adapters::Net - attr_reader port: untyped + attr_reader host: String - attr_reader ssl: untyped + attr_reader port: Integer - attr_reader path: untyped + attr_reader ssl: bool + + attr_reader path: String def initialize: () -> void - def request: (request_type: String, payload: String) -> Datadog::Core::Telemetry::Http::Adapters::Net::Response + def request: (request_type: String, payload: String) -> Datadog::Core::Telemetry::Http::Adapters::Net::response private def headers: (request_type: untyped, ?api_version: untyped) -> ::Hash[untyped, untyped] - def adapter: () -> untyped + def adapter: () -> Http::Adapters::Net end end end diff --git a/sig/datadog/core/transport/ext.rbs b/sig/datadog/core/transport/ext.rbs index 8be8ba0bbbb..335e293b941 100644 --- a/sig/datadog/core/transport/ext.rbs +++ b/sig/datadog/core/transport/ext.rbs @@ -24,6 +24,8 @@ module Datadog HEADER_META_LANG_INTERPRETER: ::String HEADER_META_TRACER_VERSION: ::String + + HEADER_DD_INTERNAL_UNTRACED_REQUEST: ::String end module Test diff --git a/sig/datadog/core/worker.rbs b/sig/datadog/core/worker.rbs index 7c59eb58d60..5654f60e88d 100644 --- a/sig/datadog/core/worker.rbs +++ b/sig/datadog/core/worker.rbs @@ -1,6 +1,7 @@ module Datadog module Core class Worker + def initialize: () ?{ () -> void } -> void end end end