diff --git a/Steepfile b/Steepfile index b0151312b7d..bdd6b5c7f3f 100644 --- a/Steepfile +++ b/Steepfile @@ -140,10 +140,8 @@ target :datadog do ignore 'lib/datadog/tracing/transport/http/traces.rb' ignore 'lib/datadog/tracing/transport/io/client.rb' ignore 'lib/datadog/tracing/transport/io/traces.rb' - ignore 'lib/datadog/tracing/transport/serializable_trace.rb' ignore 'lib/datadog/tracing/transport/statistics.rb' ignore 'lib/datadog/tracing/transport/trace_formatter.rb' - ignore 'lib/datadog/tracing/transport/traces.rb' ignore 'lib/datadog/tracing/workers.rb' ignore 'lib/datadog/tracing/workers/trace_writer.rb' ignore 'lib/datadog/tracing/writer.rb' diff --git a/sig/datadog/core/configuration.rbs b/sig/datadog/core/configuration.rbs index e241fb56a65..ae76973d007 100644 --- a/sig/datadog/core/configuration.rbs +++ b/sig/datadog/core/configuration.rbs @@ -1,6 +1,8 @@ module Datadog module Core module Configuration + def health_metrics: -> Diagnostics::Health::Metrics + def tracer: () -> Datadog::Tracing::Tracer def logger: () -> Datadog::Core::Logger diff --git a/sig/datadog/core/diagnostics/health.rbs b/sig/datadog/core/diagnostics/health.rbs index d31c41f9cde..ec54e0b87b0 100644 --- a/sig/datadog/core/diagnostics/health.rbs +++ b/sig/datadog/core/diagnostics/health.rbs @@ -3,7 +3,7 @@ module Datadog module Diagnostics module Health class Metrics < Core::Metrics::Client - extend Tracing::Diagnostics::Health::Metrics + include Tracing::Diagnostics::Health::Metrics end end end diff --git a/sig/datadog/tracing/diagnostics/health.rbs b/sig/datadog/tracing/diagnostics/health.rbs index dd3fd3fc616..deeb13ff221 100644 --- a/sig/datadog/tracing/diagnostics/health.rbs +++ b/sig/datadog/tracing/diagnostics/health.rbs @@ -3,7 +3,25 @@ module Datadog module Diagnostics module Health module Metrics - def self.extended: (untyped base) -> untyped + def api_errors: (untyped ?value) ?{ (untyped) -> untyped } -> void + def api_requests: (untyped ?value) ?{ (untyped) -> untyped } -> void + def api_responses: (untyped ?value) ?{ (untyped) -> untyped } -> void + def error_context_overflow: (untyped ?value) ?{ (untyped) -> untyped } -> void + def error_instrumentation_patch: (untyped ?value) ?{ (untyped) -> untyped } -> void + def error_span_finish: (untyped ?value) ?{ (untyped) -> untyped } -> void + def error_unfinished_spans: (untyped ?value) ?{ (untyped) -> untyped } -> void + def instrumentation_patched: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_accepted: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_accepted_lengths: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_dropped: (untyped ?value) ?{ (untyped) -> untyped } -> void + def traces_filtered: (untyped ?value) ?{ (untyped) -> untyped } -> void + def transport_trace_too_large: (untyped ?value) ?{ (untyped) -> untyped } -> void + def transport_chunked: (untyped ?value) ?{ (untyped) -> untyped } -> void + def writer_cpu_time: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_length: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_max_length: (untyped ?value) ?{ (untyped) -> untyped } -> void + def queue_spans: (untyped ?value) ?{ (untyped) -> untyped } -> void + def sampling_service_cache_length: (untyped ?value) ?{ (untyped) -> untyped } -> void end end end diff --git a/sig/datadog/tracing/span.rbs b/sig/datadog/tracing/span.rbs index 9adb31f126a..1324e8227b6 100644 --- a/sig/datadog/tracing/span.rbs +++ b/sig/datadog/tracing/span.rbs @@ -1,10 +1,49 @@ module Datadog module Tracing class Span - attr_accessor span_id: Integer + attr_accessor end_time: (Time | nil) + attr_accessor id: Integer + attr_accessor meta: Hash[String, String] + attr_accessor metrics: Hash[String, Float] + attr_accessor name: String + attr_accessor parent_id: Integer + attr_accessor resource: String + attr_accessor service: (String | nil) + attr_accessor links: Array[untyped] + attr_accessor events: Array[untyped] + attr_accessor type: (String | nil) + attr_accessor start_time: (Time | nil) + attr_accessor status: Integer + attr_accessor trace_id: Integer + attr_writer duration: (Float | nil) - def set_tag: (String key, ?untyped? value) -> void + def initialize: ( + String name, + ?duration: (Float | nil), + ?end_time: (Time | nil), + ?id: (Integer | nil), + ?meta: (Hash[String, String] | nil), + ?metrics: (Hash[String, Float] | nil), + ?parent_id: Integer, + ?resource: String, + ?service: (String | nil), + ?start_time: (Time | nil), + ?status: Integer, + ?type: (String | nil), + ?trace_id: (Integer | nil), + ?service_entry: (bool | nil), + ?links: (Array[untyped] | nil), + ?events: (Array[untyped] | nil) + ) -> void + + def started?: -> bool + def stopped?: -> bool + def duration: -> (Float | nil) + def set_error: (Exception e) -> void + def ==: (Span other) -> bool + def to_s: -> String + def to_hash: -> Hash[Symbol, untyped] + def pretty_print: (PP::Object q) -> void end end end - diff --git a/sig/datadog/tracing/transport/http/client.rbs b/sig/datadog/tracing/transport/http/client.rbs index 5ddbe16ae17..b723af2bd54 100644 --- a/sig/datadog/tracing/transport/http/client.rbs +++ b/sig/datadog/tracing/transport/http/client.rbs @@ -1,16 +1,18 @@ module Datadog - module Transport - module HTTP - class Client - include Transport::HTTP::Statistics + module Tracing + module Transport + module HTTP + class Client + include Transport::HTTP::Statistics - attr_reader api: untyped + attr_reader api: untyped - def initialize: (untyped api) -> void + def initialize: (untyped api) -> void - def send_request: (untyped request) { (untyped, untyped) -> untyped } -> untyped + def send_request: (untyped request) { (untyped, untyped) -> untyped } -> untyped - def build_env: (untyped request) -> untyped + def build_env: (untyped request) -> untyped + end end end end diff --git a/sig/datadog/tracing/transport/http/statistics.rbs b/sig/datadog/tracing/transport/http/statistics.rbs index 0ee2cc8bc95..95ef7ac5661 100644 --- a/sig/datadog/tracing/transport/http/statistics.rbs +++ b/sig/datadog/tracing/transport/http/statistics.rbs @@ -1,17 +1,19 @@ module Datadog - module Transport - module HTTP - module Statistics - def self.included: (untyped base) -> untyped + module Tracing + module Transport + module HTTP + module Statistics + def self.included: (untyped base) -> untyped - module InstanceMethods - def metrics_for_response: (untyped response) -> untyped + module InstanceMethods + def metrics_for_response: (untyped response) -> untyped - private + private - STATUS_CODE_200: "status_code:200" + STATUS_CODE_200: "status_code:200" - def metrics_tag_value: (untyped status_code) -> (untyped | ::String) + def metrics_tag_value: (untyped status_code) -> (untyped | ::String) + end end end end diff --git a/sig/datadog/tracing/transport/serializable_trace.rbs b/sig/datadog/tracing/transport/serializable_trace.rbs index ab84fcfc23d..f8cd87e7bff 100644 --- a/sig/datadog/tracing/transport/serializable_trace.rbs +++ b/sig/datadog/tracing/transport/serializable_trace.rbs @@ -4,7 +4,7 @@ module Datadog class SerializableTrace @native_events_supported: bool - attr_reader trace: Span + attr_reader trace: TraceSegment def initialize: (untyped trace, bool native_events_supported) -> void diff --git a/sig/datadog/tracing/transport/traces.rbs b/sig/datadog/tracing/transport/traces.rbs index 2a9ce5e5239..5ecffec6cd3 100644 --- a/sig/datadog/tracing/transport/traces.rbs +++ b/sig/datadog/tracing/transport/traces.rbs @@ -28,7 +28,7 @@ module Datadog attr_reader max_size: untyped - def initialize: (untyped encoder, ?max_size: untyped) -> void + def initialize: (untyped encoder, bool native_events_supported, ?max_size: untyped) -> void def encode_in_chunks: (untyped traces) -> untyped @@ -38,7 +38,7 @@ module Datadog end module Encoder - def self?.encode_trace: (untyped encoder, untyped trace) -> untyped + def self?.encode_trace: (untyped encoder, untyped trace, bool native_events_supported) -> untyped end class Transport diff --git a/spec/datadog/tracing/transport/traces_spec.rb b/spec/datadog/tracing/transport/traces_spec.rb index bd9da232cc9..2371874aedd 100644 --- a/spec/datadog/tracing/transport/traces_spec.rb +++ b/spec/datadog/tracing/transport/traces_spec.rb @@ -173,7 +173,9 @@ let(:chunker) { instance_double(Datadog::Tracing::Transport::Traces::Chunker, max_size: 1) } let(:native_events_supported) { nil } - let(:agent_info_response) { instance_double(Datadog::Core::Remote::Transport::HTTP::Negotiation::Response, span_events: native_events_supported) } + let(:agent_info_response) do + instance_double(Datadog::Core::Remote::Transport::HTTP::Negotiation::Response, span_events: native_events_supported) + end before do allow(Datadog::Tracing::Transport::Traces::Chunker).to receive(:new).with(encoder_v1, false).and_return(chunker) @@ -189,7 +191,7 @@ allow(Datadog::Tracing::Transport::Traces::Request).to receive(:new).and_return(request) allow_any_instance_of(Datadog::Core::Environment::AgentInfo).to receive(:fetch) - .and_return(agent_info_response) + .and_return(agent_info_response) end context 'which returns an OK response' do @@ -268,7 +270,10 @@ let(:native_events_supported) { nil } it 'does not encode native span events' do - expect(Datadog::Tracing::Transport::Traces::Chunker).to receive(:new).with(encoder_v2, false).and_return(chunker) + expect(Datadog::Tracing::Transport::Traces::Chunker).to receive(:new).with( + encoder_v2, + false + ).and_return(chunker) send_traces end end @@ -286,7 +291,10 @@ let(:native_events_supported) { false } it 'encodes native span events' do - expect(Datadog::Tracing::Transport::Traces::Chunker).to receive(:new).with(encoder_v2, false).and_return(chunker) + expect(Datadog::Tracing::Transport::Traces::Chunker).to receive(:new).with( + encoder_v2, + false + ).and_return(chunker) send_traces end end