public class TransactionEventsService extends AbstractService implements EventService, TransactionListener, AgentConfigListener
TransactionEventsService
collects per-transaction analytic events and transmits them to the collectors.
This class implements parts of both the Recording Analytics Events for Transactions and Agent Support for
Synthetics specifications. Both specifications can be found in Confluence.
Ideally, all analytic events are stored until harvest and then transmitted. If the number of events exceeds a configurable limit, events are replaced using a "reservoir" sampling algorithm.
If the transaction was generated by New Relic Synthetics, however, events are stored deterministically up to a fixed limit after which the reservoir storage is used as a fall-back mechanism.
This service can be configured using transaction_events
with enabled
or max_samples_stored
.
logger
Constructor and Description |
---|
TransactionEventsService(TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics) |
Modifier and Type | Method and Description |
---|---|
void |
addHarvestableToService(java.lang.String appName) |
void |
clearReservoir()
Reset the event reservoir to allow for the next harvest to start
|
void |
configChanged(java.lang.String appName,
AgentConfig agentConfig) |
TransactionEvent |
createEvent(TransactionData transactionData,
TransactionStats transactionStats,
java.lang.String metricName) |
void |
dispatcherTransactionFinished(TransactionData transactionData,
TransactionStats transactionStats)
Called after a dispatcher transaction finishes on the request thread.
|
protected void |
doStart()
Register appropriate listeners.
|
protected void |
doStop()
Unregister listeners and clear state.
|
DistributedSamplingPriorityQueue<TransactionEvent> |
getDistributedSamplingReservoir(java.lang.String appName) |
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.
|
DistributedSamplingPriorityQueue<TransactionEvent> |
getOrCreateDistributedSamplingReservoir(java.lang.String appName) |
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)
Update the current limit of events to store per harvest interval.
|
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 TransactionEventsService(TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics)
public void addHarvestableToService(java.lang.String appName)
public void clearReservoir()
EventService
clearReservoir
in interface EventService
public final 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 int getMaxSamplesStored()
EventService
getMaxSamplesStored
in interface EventService
public void setMaxSamplesStored(int maxSamplesStored)
EventService
setMaxSamplesStored
in interface EventService
maxSamplesStored
- the new maximum number of events to store per harvest interval.public 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 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 TransactionEvent createEvent(TransactionData transactionData, TransactionStats transactionStats, java.lang.String metricName)
public void configChanged(java.lang.String appName, AgentConfig agentConfig)
configChanged
in interface AgentConfigListener
public DistributedSamplingPriorityQueue<TransactionEvent> getDistributedSamplingReservoir(java.lang.String appName)
public DistributedSamplingPriorityQueue<TransactionEvent> getOrCreateDistributedSamplingReservoir(java.lang.String appName)