lib/new_relic/agent/transaction/segment.rb in newrelic_rpm-5.2.0.345 vs lib/new_relic/agent/transaction/segment.rb in newrelic_rpm-5.3.0.346
- old
+ new
@@ -1,10 +1,11 @@
# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
require 'new_relic/agent/transaction/abstract_segment'
+require 'new_relic/agent/span_event_primitive'
module NewRelic
module Agent
class Transaction
class Segment < AbstractSegment
@@ -42,9 +43,22 @@
else
@unscoped_metrics = [@unscoped_metrics, metric]
end
else
@unscoped_metrics = metric
+ end
+ end
+
+ def segment_complete
+ record_span_event if transaction.sampled?
+ end
+
+ def record_span_event
+ aggregator = ::NewRelic::Agent.agent.span_event_aggregator
+ priority = transaction.priority
+
+ aggregator.record(priority: priority) do
+ SpanEventPrimitive.for_segment(self)
end
end
end
end
end