Skip to content

Commit

Permalink
add type-level metadata dictionaries to msgpack header
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Sep 19, 2024
1 parent 0fc0203 commit f4baad8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/datadog/ci/ext/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ module Test
TAG_SPAN_KIND = "span.kind"
SPAN_KIND_TEST = "test"

# common tags that are serialized directly in msgpack header in metadata field
METADATA_TAG_TEST_SESSION_NAME = "test_session.name"

# tags that are common for the whole session and can be inherited from the test session
INHERITABLE_TAGS = [TAG_FRAMEWORK, TAG_FRAMEWORK_VERSION].freeze

Expand Down
11 changes: 10 additions & 1 deletion lib/datadog/ci/test_visibility/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "datadog/core/environment/identity"

require_relative "serializers/factories/test_level"
require_relative "../ext/app_types"
require_relative "../ext/telemetry"
require_relative "../ext/transport"
require_relative "../transport/event_platform_transport"
Expand Down Expand Up @@ -75,7 +76,7 @@ def write_payload_header(packer)
packer.write(1)

packer.write("metadata")
packer.write_map_header(1)
packer.write_map_header(1 + Ext::AppTypes::CI_SPAN_TYPES.size)

packer.write("*")
metadata_fields_count = dd_env ? 4 : 3
Expand All @@ -95,6 +96,14 @@ def write_payload_header(packer)
packer.write("library_version")
packer.write(Datadog::CI::VERSION::STRING)

Ext::AppTypes::CI_SPAN_TYPES.each do |ci_span_type|
packer.write(ci_span_type)
packer.write_map_header(1)

packer.write(Ext::Test::METADATA_TAG_TEST_SESSION_NAME)
packer.write("dummy")
end

packer.write("events")
end

Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/ext/test.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ module Datadog

EARLY_FLAKE_FAULTY: "faulty"

METADATA_TAG_TEST_SESSION_NAME: "test_session.name"

module Status
PASS: "pass"

Expand Down
5 changes: 5 additions & 0 deletions spec/datadog/ci/test_visibility/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
expect(metadata).to include("runtime-id", "library_version")
expect(metadata["language"]).to eq("ruby")

Datadog::CI::Ext::AppTypes::CI_SPAN_TYPES.each do |type|
type_metadata = payload["metadata"][type]
expect(type_metadata).to include("test_session.name" => "dummy")
end

events = payload["events"]
expect(events.count).to eq(1)
expect(events.first["content"]["resource"]).to include("calculator_tests")
Expand Down

0 comments on commit f4baad8

Please sign in to comment.