diff --git a/lib/ddtrace/sync_writer.rb b/lib/ddtrace/sync_writer.rb index b5ac47f0657..0175470c934 100644 --- a/lib/ddtrace/sync_writer.rb +++ b/lib/ddtrace/sync_writer.rb @@ -1,13 +1,22 @@ +require 'ddtrace/runtime/metrics' + module Datadog # SyncWriter flushes both services and traces synchronously class SyncWriter - attr_reader :transport + attr_reader \ + :runtime_metrics, + :transport def initialize(options = {}) @transport = options.fetch(:transport) do transport_options = options.fetch(:transport_options, {}) HTTPTransport.new(transport_options) end + + # Runtime metrics + @runtime_metrics = options.fetch(:runtime_metrics) do + Runtime::Metrics.new + end end def write(trace, services = nil) diff --git a/spec/ddtrace/sync_writer_spec.rb b/spec/ddtrace/sync_writer_spec.rb new file mode 100644 index 00000000000..ed99b02cd92 --- /dev/null +++ b/spec/ddtrace/sync_writer_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +require 'ddtrace' +require 'ddtrace/sync_writer' + +RSpec.describe Datadog::SyncWriter do + subject(:sync_writer) { described_class.new } + + describe '#runtime_metrics' do + subject(:runtime_metrics) { sync_writer.runtime_metrics } + it { is_expected.to be_a_kind_of(Datadog::Runtime::Metrics) } + end +end