Skip to content

Commit

Permalink
Add benchmark for propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Feb 23, 2024
1 parent d24fd06 commit 85cee5e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions benchmarks/tracing_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,54 @@ def benchmark_log_correlation
end
end
end

def benchmark_propagation_datadog
Datadog.configure do |c|
c.tracing.propagation_style = ['datadog']
end

Datadog::Tracing.trace('op.name') do |span, trace|
injected_trace_digest = trace.to_digest
Benchmark.ips do |x|
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.001, warmup: 0 } : { time: 10.5, warmup: 2 }
x.config(**benchmark_time)

x.report("Propagation - Datadog") do
env = {}
Datadog::Tracing::Contrib::HTTP.inject(injected_trace_digest, env)
extracted_trace_digest = Datadog::Tracing::Contrib::HTTP.extract(env)
raise unless extracted_trace_digest
end

x.save! "#{__FILE__}-results.json" unless VALIDATE_BENCHMARK_MODE
x.compare!
end
end
end

def benchmark_propagation_trace_context
Datadog.configure do |c|
c.tracing.propagation_style = ['tracecontext']
end

Datadog::Tracing.trace('op.name') do |span, trace|
injected_trace_digest = trace.to_digest
Benchmark.ips do |x|
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.001, warmup: 0 } : { time: 10.5, warmup: 2 }
x.config(**benchmark_time)

x.report("Propagation - Trace Context") do
env = {}
Datadog::Tracing::Contrib::HTTP.inject(injected_trace_digest, env)
extracted_trace_digest = Datadog::Tracing::Contrib::HTTP.extract(env)
raise unless extracted_trace_digest
end

x.save! "#{__FILE__}-results.json" unless VALIDATE_BENCHMARK_MODE
x.compare!
end
end
end
end

puts "Current pid is #{Process.pid}"
Expand All @@ -115,4 +163,6 @@ def run_benchmark(&block)
run_benchmark { benchmark_no_network }
run_benchmark { benchmark_to_digest }
run_benchmark { benchmark_log_correlation }
run_benchmark { benchmark_propagation_datadog }
run_benchmark { benchmark_propagation_trace_context }
end

0 comments on commit 85cee5e

Please sign in to comment.