Skip to content

Commit

Permalink
extract tags_with_inherited_globals in Recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Nov 30, 2023
1 parent 65c8cc7 commit 64ad04f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/datadog/ci/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def start_test_session(service_name: nil, tags: {})
def start_test_module(test_module_name, service_name: nil, tags: {})
return skip_tracing unless test_suite_level_visibility_enabled

tags = tags_with_inherited_globals(tags)

test_session = active_test_session
if test_session
tags = test_session.inheritable_tags.merge(tags)

tags[Ext::Test::TAG_TEST_SESSION_ID] = test_session.id
end

Expand All @@ -75,10 +75,10 @@ def start_test_module(test_module_name, service_name: nil, tags: {})
def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block)
return skip_tracing(block) unless enabled

tags = tags_with_inherited_globals(tags)

test_session = active_test_session
if test_session
tags = test_session.inheritable_tags.merge(tags)

tags[Ext::Test::TAG_TEST_SESSION_ID] = test_session.id
end

Expand Down Expand Up @@ -209,6 +209,10 @@ def build_span_options(service_name, span_type, other_options = {})
other_options
end

def tags_with_inherited_globals(tags)
@global_context.inheritable_session_tags.merge(tags)
end

def set_initial_tags(ci_span, tags)
ci_span.set_default_tags
ci_span.set_environment_runtime_tags
Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/recorder.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ module Datadog
def skip_tracing: (?untyped block) -> untyped

def start_datadog_tracer_span: (String span_name, Hash[untyped, untyped] span_options) ?{ (untyped) -> untyped } -> untyped

def tags_with_inherited_globals: (Hash[untyped, untyped] tags) -> Hash[untyped, untyped]
end
end
end

0 comments on commit 64ad04f

Please sign in to comment.