Skip to content

Commit

Permalink
fix static type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Sep 21, 2023
1 parent 040773c commit 622305a
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 81 deletions.
1 change: 1 addition & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ target :lib do
library "open3"
library "rspec"
library "cucumber"
library "msgpack"
end
4 changes: 3 additions & 1 deletion lib/datadog/ci/test_visibility/serializers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def duration_nano(duration)
end

def content_fields_count
return @content_fields_count if defined?(@content_fields_count)

res = 0
content_fields.each do |field|
res += if field.is_a?(Hash)
Expand All @@ -127,7 +129,7 @@ def content_fields_count
1
end
end
res
@content_fields_count = res
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/datadog/ci/test_visibility/serializers/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module Serializers
class Span < Base
def content_fields
@content_fields ||= [
"trace_id", "span_id", "parent_id", "name",
"resource", "service", "error", "start",
"duration", "meta", "metrics",
"trace_id", "span_id", "parent_id",
"name", "resource", "service",
"error", "start", "duration",
"meta", "metrics",
"type" => "span_type"
]
end
Expand Down
6 changes: 4 additions & 2 deletions lib/datadog/ci/test_visibility/serializers/test_v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ module Serializers
class TestV1 < Base
def content_fields
@content_fields ||= [
"trace_id", "span_id", "name", "resource", "service",
"start", "duration", "meta", "metrics", "error",
"trace_id", "span_id",
"name", "resource", "service",
"error", "start", "duration",
"meta", "metrics",
"type" => "span_type"
]
end
Expand Down
22 changes: 11 additions & 11 deletions lib/datadog/ci/transport/http.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true
# # frozen_string_literal: true

module Datadog
module CI
module Transport
class HTTP
def initialize
end
end
end
end
end
# module Datadog
# module CI
# module Transport
# class HTTP
# def initialize
# end
# end
# end
# end
# end
11 changes: 0 additions & 11 deletions sig/datadog/ci/test_visibility/events.rbs

This file was deleted.

13 changes: 0 additions & 13 deletions sig/datadog/ci/test_visibility/events/event.rbs

This file was deleted.

11 changes: 0 additions & 11 deletions sig/datadog/ci/test_visibility/events/span.rbs

This file was deleted.

11 changes: 0 additions & 11 deletions sig/datadog/ci/test_visibility/events/test.rbs

This file was deleted.

10 changes: 10 additions & 0 deletions sig/datadog/ci/test_visibility/serializers.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Datadog
module CI
module TestVisibility
module Serializers
def self?.convert_trace_to_serializable_events: (Datadog::Tracing::TraceSegment trace) -> untyped
def self?.convert_span_to_serializable_event: (Datadog::Tracing::TraceSegment trace, Datadog::Tracing::Span span) -> untyped
end
end
end
end
58 changes: 58 additions & 0 deletions sig/datadog/ci/test_visibility/serializers/base.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module Datadog
module CI
module TestVisibility
module Serializers
class Base
@content_fields_count: Integer

attr_reader trace: Datadog::Tracing::TraceSegment
attr_reader span: Datadog::Tracing::Span

def initialize: (Datadog::Tracing::TraceSegment trace, Datadog::Tracing::Span span) -> void

def to_msgpack: (?untyped? packer) -> untyped

def content_fields: () -> ::Array[String | Hash[String, String]]

def runtime_id: () -> String

def trace_id: () -> String

def span_id: () -> String

def parent_id: () -> String

def type: () -> nil

def version: () -> 1

def span_type: () -> String

def name: () -> String

def resource: () -> String

def service: () -> String

def start: () -> Integer

def duration: () -> Integer

def meta: () -> Hash[String, untyped]

def metrics: () -> Hash[String, untyped]

def error: () -> Integer

private

def write_field: (untyped packer, String field_name, ?String? method) -> untyped
def time_nano: (Time time) -> Integer
def duration_nano: (Integer duration) -> Integer

def content_fields_count: () -> Integer
end
end
end
end
end
14 changes: 14 additions & 0 deletions sig/datadog/ci/test_visibility/serializers/span.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Datadog
module CI
module TestVisibility
module Serializers
class Span < Base
@content_fields: Array[String | Hash[String, String]]
def content_fields: () -> Array[String | Hash[String, String]]

def type: () -> "span"
end
end
end
end
end
18 changes: 18 additions & 0 deletions sig/datadog/ci/test_visibility/serializers/test_v1.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Datadog
module CI
module TestVisibility
module Serializers
class TestV1 < Base
@content_fields: Array[String | Hash[String, String]]
def content_fields: () -> Array[String | Hash[String, String]]

def type: () -> "test"

def name: () -> ::String

def resource: () -> ::String
end
end
end
end
end
18 changes: 0 additions & 18 deletions sig/datadog/ci/test_visibility/transport.rbs

This file was deleted.

14 changes: 14 additions & 0 deletions vendor/rbs/ddtrace/0/datadog/tracing/span.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ module Datadog
attr_accessor span_id: Integer

def set_tag: (String key, ?untyped? value) -> void
def get_tag: (String key) -> String?
def type: () -> String
def id: () -> String
def trace_id: () -> String
def parent_id: () -> String
def name: () -> String
def resource: () -> String
def service: () -> String
def status: () -> Integer
def start_time: () -> Time
def end_time: () -> Time
def duration: () -> Integer
def meta: () -> Hash[String, untyped]
def metrics: () -> Hash[String, untyped]
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions vendor/rbs/msgpack/0/message_pack/packer.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module MessagePack
class Packer
def initialize: () -> void

def write: (String input) -> self
def write_map_header: (Integer keys_number) -> self
def write_array_header: (Integer keys_number) -> self
end
end

0 comments on commit 622305a

Please sign in to comment.