33## Data Sending (Beacon sending)
44
55All data sending, including synchronization with the backend (Dynatrace SaaS/Dynatrace Managed/AppMon)
6- happens asynchronously by starting an own Thread when OpenKit is initialized.
6+ happens asynchronously by starting an own thread when OpenKit is initialized.
77
8- This sending thread runs through several states, before sending data actually happens.
9-
10- The following diagram illustrates these states. Each of them, including transitions, is explained later.
8+ Beacon sending in OpenKit is implemented using a state pattern. The following
9+ diagram illustrates the states.
1110
1211![ diagram] ( ./pics/OpenKit-state_diagram.svg )
1312
@@ -19,30 +18,27 @@ delays between consecutive retries.
1918If the server returned a status response a state transition to TimeSync is performed, otherwise
2019OpenKit stays in the Initialize state, but sleeps some time until the next status request is sent.
2120
22- In case the application developer calls ` OpenKit.shutdown() ` while in Init state, an immediate
23- transition to the Terminal state is performed.
21+ If ` OpenKit.shutdown() ` is called while OpenKit is in the Init state,
22+ a transition to the Terminal state is performed.
2423
2524## TimeSync
2625
2726In the TimeSync state (class ` BeaconSendingTimeSyncState ` ) 5 time sync timestamp pairs, in total
28- 10 timestamps, are fetched from the server to calculate the time offset to the backend. To retrieve
29- a pair of timestamps one time sync request is sent with a maximum amount of retries
27+ 10 timestamps, are fetched. The timestamps are used to calculate the time offset to the backend.
28+ To retrieve a pair of timestamps one time sync request is sent with a maximum amount of retries
3029(by default 5 retries, therefore in total 6 requests for one timestamp pair).
31- If a server does not support time sync (e.g. AppMon), indicated by at least one negative timestamp
32- returned in a time sync response, all further retries are skipped and no further time sync will happen.
33- In this case a transition to either CaptureOn state or CaptureOff state is performed, based on the
34- initial configuration obtained in Init state.
30+ If a server does not support time sync (e.g. AppMon) all further retries are skipped and no
31+ further time sync will happen. In this case a transition to either CaptureOn state or CaptureOff
32+ state is performed, based on the initial configuration obtained in Init state.
3533If the number of time sync retries is exceeded the time sync is unsuccessful and therefore a
3634transition to CaptureOff is performed.
37- In case the time sync was successful a transition to either CaptureOn state or CaptureOff
38- state is performed, based on the initial configuration obtained in Init state.
3935
4036The algorithm used to compute the cluster time offset is similar to the algorithm used by
4137[ NTP] ( https://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm ) .
4238
43- In case the application developer calls ` OpenKit.shutdown() ` while in TimeSync state a transition
44- to TerminalState is performed if it's the initial time sync, otherwise a transition to
45- FlushSessions state is done .
39+ If ` OpenKit.shutdown() ` is called while OpenKit is in the TimeSync state, a transition to either
40+ Terminal state or FlushSession state is performed. The transition to the Terminal state
41+ is only performed if the initial time sync was not completed before the call to ` shutdown() ` .
4642
4743## CaptureOff
4844
@@ -51,7 +47,7 @@ status request was sent to the server and sleeps some time before performing the
5147request.
5248If time sync is supported by the server and the initial time sync failed a state transition
5349to time sync is performed.
54- In case an initial time sync is not needed any more a transition to CaptureOn state is performed
50+ If the initial time sync was successfully performed, a transition to CaptureOn state is performed
5551if capturing was enabled by the server's status response. If capturing is disabled
5652then no transition is performed and the state machine stays in CaptureOff state.
5753
@@ -78,4 +74,4 @@ data which has not been transferred so far to the server.
7874
7975The Terminal state (class ` BeaconSendingTerminalState ` ) is the last state in OpenKit's internal
8076state machine. After this state is reached the background thread responsible for sending data
81- will end itself .
77+ is terminated gracefully .
0 commit comments