Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Jan 14, 2025
1 parent 1d374b3 commit 653dd58
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 31 deletions.
2 changes: 0 additions & 2 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/core/configuration.rbs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/core/diagnostics/health.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion sig/datadog/tracing/diagnostics/health.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 42 additions & 3 deletions sig/datadog/tracing/span.rbs
Original file line number Diff line number Diff line change
@@ -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

18 changes: 10 additions & 8 deletions sig/datadog/tracing/transport/http/client.rbs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 11 additions & 9 deletions sig/datadog/tracing/transport/http/statistics.rbs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/tracing/transport/serializable_trace.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions sig/datadog/tracing/transport/traces.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
16 changes: 12 additions & 4 deletions spec/datadog/tracing/transport/traces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 653dd58

Please sign in to comment.