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, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLogger, getName, isStarted, isStartedOrStarting, isStopped, isStoppedOrStopping, start, stoppublic TransactionEventsService(TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics)
public void addHarvestableToService(java.lang.String appName)
public void clearReservoir()
EventServiceclearReservoir in interface EventServicepublic final boolean isEnabled()
Serviceprotected void doStart()
throws java.lang.Exception
doStart in class AbstractServicejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
doStop in class AbstractServicejava.lang.Exceptionpublic int getMaxSamplesStored()
EventServicegetMaxSamplesStored in interface EventServicepublic void setMaxSamplesStored(int maxSamplesStored)
EventServicesetMaxSamplesStored in interface EventServicemaxSamplesStored - the new maximum number of events to store per harvest interval.public void harvestEvents(java.lang.String appName)
EventServiceharvestEvents in interface EventServiceappName - the application to harvest forpublic java.lang.String getEventHarvestIntervalMetric()
EventServicegetEventHarvestIntervalMetric in interface EventServicepublic java.lang.String getReportPeriodInSecondsMetric()
EventServicegetReportPeriodInSecondsMetric in interface EventServicepublic java.lang.String getEventHarvestLimitMetric()
EventServicegetEventHarvestLimitMetric in interface EventServicepublic void dispatcherTransactionFinished(TransactionData transactionData, TransactionStats transactionStats)
TransactionListenerdispatcherTransactionFinished in interface TransactionListenertransactionData - 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 AgentConfigListenerpublic DistributedSamplingPriorityQueue<TransactionEvent> getDistributedSamplingReservoir(java.lang.String appName)
public DistributedSamplingPriorityQueue<TransactionEvent> getOrCreateDistributedSamplingReservoir(java.lang.String appName)