public class SpanEventsServiceImpl extends AbstractService implements AgentConfigListener, SpanEventsService, TransactionListener
SpanEventsServiceImpl
collects span events and transmits them to the collectors.
Ideally, all span events are stored until harvest and then transmitted. If the number of events exceeds a configurable limit, events are replaced using a "reservoir" priority sampling algorithm.
This service can be configured using span_events
with enabled
or max_samples_stored
.
Modifier and Type | Class and Description |
---|---|
static class |
SpanEventsServiceImpl.Builder |
logger
Constructor and Description |
---|
SpanEventsServiceImpl(SpanEventsServiceImpl.Builder builder) |
Modifier and Type | Method and Description |
---|---|
void |
addHarvestableToService(java.lang.String appName)
There is only one event reservoir for Distributed Tracing so there only needs to be one harvestable for it.
|
static SpanEventsServiceImpl.Builder |
builder() |
void |
clearReservoir()
Reset the event reservoir to allow for the next harvest to start
|
void |
configChanged(java.lang.String appName,
AgentConfig agentConfig) |
void |
dispatcherTransactionFinished(TransactionData transactionData,
TransactionStats transactionStats)
Called after a dispatcher transaction finishes on the request thread.
|
protected void |
doStart() |
protected void |
doStop() |
java.lang.String |
getEventHarvestIntervalMetric()
Returns the metric name for this service that records the actual interval in which the harvest is happening.
|
java.lang.String |
getEventHarvestLimitMetric()
Returns the metric name for this service that records the harvest limit.
|
int |
getMaxSamplesStored()
Returns the current limit of events to store per harvest interval.
|
com.newrelic.agent.interfaces.SamplingPriorityQueue<com.newrelic.agent.model.SpanEvent> |
getOrCreateDistributedSamplingReservoir() |
java.lang.String |
getReportPeriodInSecondsMetric()
Returns the metric name for this service that records the expected report period.
|
void |
harvestEvents(java.lang.String appName)
Perform the harvest of any pending events right now.
|
boolean |
isEnabled()
Is the service enabled.
|
void |
setMaxSamplesStored(int maxSamplesStored)
For the setting to take effect, the reservoir must be re-created.
|
void |
storeEvent(com.newrelic.agent.model.SpanEvent event) |
getLogger, getName, isStarted, isStartedOrStarting, isStopped, isStoppedOrStopping, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLogger, getName, isStarted, isStartedOrStarting, isStopped, isStoppedOrStopping, start, stop
public SpanEventsServiceImpl(SpanEventsServiceImpl.Builder builder)
public void dispatcherTransactionFinished(TransactionData transactionData, TransactionStats transactionStats)
TransactionListener
dispatcherTransactionFinished
in interface TransactionListener
transactionData
- the final data from the transactiontransactionStats
- the final metric information from the transactionpublic void harvestEvents(java.lang.String appName)
EventService
harvestEvents
in interface EventService
appName
- the application to harvest forpublic java.lang.String getEventHarvestIntervalMetric()
EventService
getEventHarvestIntervalMetric
in interface EventService
public java.lang.String getReportPeriodInSecondsMetric()
EventService
getReportPeriodInSecondsMetric
in interface EventService
public java.lang.String getEventHarvestLimitMetric()
EventService
getEventHarvestLimitMetric
in interface EventService
public boolean isEnabled()
Service
protected void doStart() throws java.lang.Exception
doStart
in class AbstractService
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class AbstractService
java.lang.Exception
public void storeEvent(com.newrelic.agent.model.SpanEvent event)
storeEvent
in interface SpanEventsService
public int getMaxSamplesStored()
EventService
getMaxSamplesStored
in interface EventService
public void setMaxSamplesStored(int maxSamplesStored)
setMaxSamplesStored
in interface EventService
maxSamplesStored
- the new maximum number of events to store per harvest interval.public void clearReservoir()
EventService
clearReservoir
in interface EventService
public void addHarvestableToService(java.lang.String appName)
addHarvestableToService
in interface SpanEventsService
public void configChanged(java.lang.String appName, AgentConfig agentConfig)
configChanged
in interface AgentConfigListener
public com.newrelic.agent.interfaces.SamplingPriorityQueue<com.newrelic.agent.model.SpanEvent> getOrCreateDistributedSamplingReservoir()
getOrCreateDistributedSamplingReservoir
in interface SpanEventsService
public static SpanEventsServiceImpl.Builder builder()