Skip to content

Commit

Permalink
Merge pull request #65 from DataDog/anmarchenko/remove_dd_measured
Browse files Browse the repository at this point in the history
Remove _dd.measured tag from spans
  • Loading branch information
anmarchenko authored Nov 7, 2023
2 parents 57b8bcd + 2eeeb6c commit ef6e234
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
8 changes: 3 additions & 5 deletions lib/datadog/ci/recorder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "datadog/tracing"
require "datadog/tracing/contrib/analytics"

require "rbconfig"

Expand Down Expand Up @@ -48,23 +47,22 @@ def trace(span_type, span_name, tags: {}, &block)

def create_datadog_span(span_name, span_options: {}, tags: {}, &block)
if block
::Datadog::Tracing.trace(span_name, **span_options) do |tracer_span, trace|
Datadog::Tracing.trace(span_name, **span_options) do |tracer_span, trace|
set_internal_tracing_context!(trace, tracer_span)
block.call(Span.new(tracer_span, tags))
end
else
tracer_span = Datadog::Tracing.trace(span_name, **span_options)
trace = ::Datadog::Tracing.active_trace
trace = Datadog::Tracing.active_trace

set_internal_tracing_context!(trace, tracer_span)
Span.new(tracer_span, tags)
end
end

def set_internal_tracing_context!(trace, span)
# Set default tags
# Sets trace's origin to ciapp-test
trace.origin = Ext::Test::CONTEXT_ORIGIN if trace
::Datadog::Tracing::Contrib::Analytics.set_measured(span)
end
end
end
Expand Down
10 changes: 0 additions & 10 deletions spec/datadog/ci/recorder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
end

shared_examples_for "internal tracing context" do
it do
expect(Datadog::Tracing::Contrib::Analytics)
.to have_received(:set_measured)
.with(span_op)
end

it do
expect(trace_op)
.to have_received(:origin=)
Expand Down Expand Up @@ -67,7 +61,6 @@
trace_block.call(span_op, trace_op)
end

allow(Datadog::Tracing::Contrib::Analytics).to receive(:set_measured)
allow(Datadog::CI::Span).to receive(:new).with(span_op, expected_tags).and_return(ci_test)

trace
Expand Down Expand Up @@ -103,7 +96,6 @@
)
.and_return(span_op)

allow(Datadog::Tracing::Contrib::Analytics).to receive(:set_measured)
allow(Datadog::CI::Span).to receive(:new).with(span_op, expected_tags).and_return(ci_test)

trace
Expand Down Expand Up @@ -152,7 +144,6 @@
trace_block.call(span_op, trace_op)
end

allow(Datadog::Tracing::Contrib::Analytics).to receive(:set_measured)
allow(Datadog::CI::Span).to receive(:new).with(span_op, expected_tags).and_return(ci_span)

trace
Expand Down Expand Up @@ -187,7 +178,6 @@
)
.and_return(span_op)

allow(Datadog::Tracing::Contrib::Analytics).to receive(:set_measured)
allow(Datadog::CI::Span).to receive(:new).with(span_op, expected_tags).and_return(ci_span)

trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
)
expect(metrics).to eq(
{"_dd.measured" => 1.0, "_dd.top_level" => 1.0, "memory_allocations" => 16}
{"_dd.top_level" => 1.0, "memory_allocations" => 16}
)
end
end
Expand Down
12 changes: 0 additions & 12 deletions spec/support/span_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ def description_of(actual) # rubocop:disable Lint/NestedMethodDefinition
end
end

# Span with the metric '_dd.measured' set to 1.0.
RSpec::Matchers.define :be_measured do
match do |span|
value = span.get_metric("_dd.measured")
values_match? 1.0, value
end

def description_of(actual)
"#{actual} with metrics #{actual.instance_variable_get(:@metrics)}"
end
end

# Does this span have no parent span?
RSpec::Matchers.define :be_root_span do
match do |span|
Expand Down

0 comments on commit ef6e234

Please sign in to comment.