-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move contrib tracer helpers to common helpers;
serialize test event to msgpack
- Loading branch information
1 parent
2a854ff
commit cd2d070
Showing
24 changed files
with
333 additions
and
296 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializer | ||
class Base | ||
attr_reader :trace, :span | ||
|
||
def initialize(trace, span) | ||
@trace = trace | ||
@span = span | ||
end | ||
|
||
def runtime_id | ||
@trace.runtime_id | ||
end | ||
|
||
# Used for serialization | ||
# @return [Integer] in nanoseconds since Epoch | ||
def time_nano(time) | ||
time.to_i * 1000000000 + time.nsec | ||
end | ||
|
||
# Used for serialization | ||
# @return [Integer] in nanoseconds since Epoch | ||
def duration_nano(duration) | ||
(duration * 1e9).to_i | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializer | ||
class Span < Base | ||
def to_msgpack(packer = nil) | ||
packer ||= MessagePack::Packer.new | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
require_relative "../../ext/test" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializer | ||
class Test < Base | ||
def to_msgpack(packer = nil) | ||
packer ||= MessagePack::Packer.new unless defined?(@packer) | ||
|
||
packer.write_map_header(3) | ||
|
||
packer.write("type") | ||
packer.write("test") | ||
|
||
packer.write("version") | ||
packer.write(1) | ||
|
||
packer.write("content") | ||
|
||
packer.write_map_header(10) | ||
|
||
packer.write("trace_id") | ||
packer.write(@trace.id) | ||
|
||
packer.write("span_id") | ||
packer.write(@span.id) | ||
|
||
packer.write("name") | ||
packer.write("#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test") | ||
|
||
packer.write("resource") | ||
packer.write("#{@span.get_tag(Ext::Test::TAG_SUITE)}.#{@span.get_tag(Ext::Test::TAG_NAME)}") | ||
|
||
packer.write("service") | ||
packer.write(@span.service) | ||
|
||
packer.write("type") | ||
packer.write("test") | ||
|
||
packer.write("start") | ||
packer.write(time_nano(@span.start_time)) | ||
|
||
packer.write("duration") | ||
packer.write(duration_nano(@span.duration)) | ||
|
||
packer.write("meta") | ||
packer.write(@span.meta) | ||
|
||
# metrics have the same value as meta | ||
packer.write("metrics") | ||
packer.write({}) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
lib/datadog/ci/test_visibility/something_that_converts_traces.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "serializer/test" | ||
require_relative "serializer/span" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module SomethingThatConvertsTraces | ||
module_function | ||
|
||
def convert(trace) | ||
trace.spans.map { |span| convert_span(trace, span) } | ||
end | ||
|
||
def convert_span(trace, span) | ||
case span.type | ||
when Datadog::CI::Ext::AppTypes::TYPE_TEST | ||
Serializer::Test.new(trace, span) | ||
else | ||
Serializer::Span.new(trace, span) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require_relative "../support/spec_helper" | ||
|
||
require "stringio" | ||
require "cucumber" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.