public class Beacon
extends java.lang.Object
| Constructor and Description |
|---|
Beacon(Logger logger,
BeaconCacheImpl beaconCache,
Configuration configuration,
java.lang.String clientIPAddress,
ThreadIDProvider threadIDProvider,
TimingProvider timingProvider)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAction(ActionImpl action)
Add
ActionImpl to Beacon. |
void |
addWebRequest(int parentActionID,
WebRequestTracerBaseImpl webRequestTracer)
Add web request to Beacon.
|
void |
clearData()
Clears all previously collected data for this Beacon.
|
int |
createID()
Create a unique identifier.
|
int |
createSequenceNumber()
Create a unique sequence number.
|
java.lang.String |
createTag(int parentActionID,
int sequenceNo)
Create a web request tag.
|
void |
endSession(SessionImpl session)
Add
SessionImpl to Beacon when session is ended. |
BeaconConfiguration |
getBeaconConfiguration()
Get the Beacon configuration.
|
long |
getCurrentTimestamp()
Get the current timestamp in milliseconds by delegating to TimingProvider
|
long |
getDeviceID()
Get a visitor ID for the current data collection level
in case of level 2 (USER_BEHAVIOR) the value from the configuration is used
in case of level 1 (PERFORMANCE) or 0 (OFF) a random number in the positive Long range is used
|
int |
getSessionNumber()
Get a session ID for the current data collection level
in case of level 2 (
DataCollectionLevel.USER_BEHAVIOR) the value from the session id provider is used
in case of level 1 (DataCollectionLevel.PERFORMANCE) or 0 (DataCollectionLevel.OFF) a random positive int value is used |
void |
identifyUser(java.lang.String userTag)
Add user identification to Beacon.
|
boolean |
isEmpty()
Tests if the Beacon is empty.
|
void |
reportCrash(java.lang.String errorName,
java.lang.String reason,
java.lang.String stacktrace)
Add crash to Beacon.
|
void |
reportError(ActionImpl parentAction,
java.lang.String errorName,
int errorCode,
java.lang.String reason)
Add error to Beacon.
|
void |
reportEvent(ActionImpl parentAction,
java.lang.String eventName)
Add event (aka.
|
void |
reportValue(ActionImpl parentAction,
java.lang.String valueName,
double value)
Add key-value-pair to Beacon.
|
void |
reportValue(ActionImpl parentAction,
java.lang.String valueName,
int value)
Add key-value-pair to Beacon.
|
void |
reportValue(ActionImpl parentAction,
java.lang.String valueName,
java.lang.String value)
Add key-value-pair to Beacon.
|
StatusResponse |
send(HTTPClientProvider provider)
Send current state of Beacon.
|
void |
setBeaconConfiguration(BeaconConfiguration beaconConfiguration)
Sets the Beacon configuration.
|
void |
startSession()
Add start session event to Beacon.
|
public Beacon(Logger logger, BeaconCacheImpl beaconCache, Configuration configuration, java.lang.String clientIPAddress, ThreadIDProvider threadIDProvider, TimingProvider timingProvider)
logger - Logger for logging messages.beaconCache - Cache storing beacon related data.configuration - OpenKit related configuration.clientIPAddress - The client's IP address.threadIDProvider - Provider for retrieving thread id.timingProvider - Provider for time related methods.public int createID()
The identifier returned is only unique per Beacon. Calling this method on two different Beacon instances, might give the same result.
public long getCurrentTimestamp()
public int createSequenceNumber()
The sequence number returned is only unique per Beacon. Calling this method on two different Beacon instances, might give the same result.
public java.lang.String createTag(int parentActionID,
int sequenceNo)
Web request tags can be attached as HTTP header for web request tracing.
If data collection level is 0 (DataCollectionLevel.OFF) an empty tag is returned.
parentActionID - The ID of the Action for which to create a web request tag
or 0 if no parent action exists.sequenceNo - Sequence number of the WebRequestTracer.public void addAction(ActionImpl action)
ActionImpl to Beacon.
The serialized data is added to BeaconCache.
action - The action to add.public void startSession()
The serialized data is added to BeaconCache.
public void endSession(SessionImpl session)
SessionImpl to Beacon when session is ended.
The serialized data is added to BeaconCache.
session - The session to add.public void reportValue(ActionImpl parentAction, java.lang.String valueName, int value)
The serialized data is added to BeaconCache.
parentAction - The Action on which this value was reported.valueName - Value's name.value - Actual value to report.public void reportValue(ActionImpl parentAction, java.lang.String valueName, double value)
The serialized data is added to BeaconCache.
parentAction - The Action on which this value was reported.valueName - Value's name.value - Actual value to report.public void reportValue(ActionImpl parentAction, java.lang.String valueName, java.lang.String value)
The serialized data is added to BeaconCache.
parentAction - The Action on which this value was reported.valueName - Value's name.value - Actual value to report.public void reportEvent(ActionImpl parentAction, java.lang.String eventName)
The serialized data is added to BeaconCache.
parentAction - The Action on which this event was reported.eventName - Event's name.public void reportError(ActionImpl parentAction, java.lang.String errorName, int errorCode, java.lang.String reason)
The serialized data is added to BeaconCache.
parentAction - The Action on which this error was reported.errorName - Error's name.errorCode - Some error code.reason - Reason for that error.public void reportCrash(java.lang.String errorName,
java.lang.String reason,
java.lang.String stacktrace)
The serialized data is added to BeaconCache.
errorName - Error's name.reason - Reason for that error.stacktrace - Crash stacktrace.public void addWebRequest(int parentActionID,
WebRequestTracerBaseImpl webRequestTracer)
The serialized data is added to BeaconCache.
parentActionID - The id of the parent Action on which this web request was reported.webRequestTracer - Web request tracer to serialize.public void identifyUser(java.lang.String userTag)
The serialized data is added to BeaconCache.
userTag - User tag containing data to serialize.public StatusResponse send(HTTPClientProvider provider)
This method tries to send all so far collected and serialized data.
provider - Provider for getting an HTTPClient required to send the data.null if an error occurred.public void clearData()
This only affects the so far serialized data, which gets removed from the cache.
public long getDeviceID()
public int getSessionNumber()
DataCollectionLevel.USER_BEHAVIOR) the value from the session id provider is used
in case of level 1 (DataCollectionLevel.PERFORMANCE) or 0 (DataCollectionLevel.OFF) a random positive int value is used1 if data collection level is not equal to DataCollectionLevel.USER_BEHAVIOR.public boolean isEmpty()
A beacon is considered to be empty, if it does not contain any action or event data.
true if the beacon is empty, false otherwise.public void setBeaconConfiguration(BeaconConfiguration beaconConfiguration)
beaconConfiguration - The new beacon configuration to set.public BeaconConfiguration getBeaconConfiguration()