Skip to content

Commit 838fab3

Browse files
committed
Merge branch 'master' into bug/TimeSync_State_Shutdown_State_Fix
2 parents 9de6ec0 + 78b940b commit 838fab3

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ requested from an `Action`.
114114

115115
A named `Event` is attached to an `Action` and contains a name.
116116

117-
### Key-Value pairs
117+
### Key-Value Pairs
118118

119119
For an `Action` key-value pairs can also be reported. The key is always a String
120120
and the value may be an Integer (int), a floating point (double) or a String.

docs/example.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Dynatrace OpenKit - Java example
1+
# Dynatrace OpenKit - Java Example
22

3-
The following document shall provide an in depth overview, how OpenKit can be used from
3+
The following document provides an in depth overview, how OpenKit can be used from
44
developer's point of view. It explains the usage of all the API methods.
55

6-
## Obtaining an OpenKit instance
6+
## Obtaining an OpenKit Instance
77

88
OpenKit instances are obtained from the `OpenKitFactory` class.
99
Depending on the used backend system (Dynatrace SaaS/Dynatrace Managed/AppMon), the factory provides
@@ -135,7 +135,7 @@ long timeoutInMilliseconds = 10 * 1000;
135135
boolean success = openKit.waitForInitCompletion(timeoutInMilliseconds);
136136
```
137137

138-
The method returns `false` in case the timeout expired or `shutdown` has been invoked in the mean time
138+
The method returns `false` in case the timeout expired or `shutdown` has been invoked in the meantime
139139
and `true` to indicate successful initialization.
140140

141141
To verify if OpenKit has been initialized, use the `isInitialized` method as shown in the example below.
@@ -148,7 +148,7 @@ if (isInitialized) {
148148
}
149149
```
150150

151-
## Providing further Application information
151+
## Providing further Application Information
152152

153153
If multiple version's of the same applications are monitored by OpenKit, it's quite useful
154154
to set the application's version in OpenKit.
@@ -158,7 +158,7 @@ String applicationVersion = "1.2.3.4";
158158
openKit.setApplicationVersion(applicationVersion);
159159
```
160160

161-
## Providing Device specific information
161+
## Providing Device specific Information
162162

163163
Sometimes it might also be quite useful to provide information about the device the application
164164
is running on. The example below shows how to achieve this.
@@ -243,7 +243,7 @@ RootAction rootAction = session.enterAction(rootActionName);
243243
Since `RootAction` extends the `Action` interface all further methods are the same for both interfaces, except
244244
for creating child actions, which can only be done with a `RootAction`.
245245

246-
## Entering a child Action
246+
## Entering a Child Action
247247

248248
To start a child `Action` from a previously started `RootAction` use the `enterAction` method from
249249
`RootAction`, as demonstrated below.
@@ -274,7 +274,7 @@ action.reportEvent(eventName);
274274
rootAction.reportEvent(eventName);
275275
```
276276

277-
## Report Key-value pairs
277+
## Report Key-Value Pairs
278278

279279
Key-value pairs can also be reported via an `Action` as shown in the example below.
280280
Overloaded methods exist for the following value types:
@@ -314,7 +314,7 @@ action.reportError(errorName, errorCode, reason);
314314

315315
One of the most powerful OpenKit features is web request tracing. When the application starts a web
316316
request (e.g. HTTP GET) a special tag can be attached to the header. This special header allows
317-
Dynatrace SaaS/Dynatrace Managed/AppMon to correlate with a server side PurePath.
317+
Dynatrace SaaS/Dynatrace Managed/AppMon to correlate actions with a server side PurePath.
318318

319319
An example is shown below.
320320
```java
@@ -364,7 +364,7 @@ webRequestTracer.stopTiming();
364364
```
365365

366366

367-
## Terminating the OpenKit instance
367+
## Terminating the OpenKit Instance
368368

369369
When an OpenKit instance is no longer needed (e.g. the application using OpenKit is shut down), the previously
370370
obtained instance can be cleared by invoking the `shutdown` method.

docs/internals.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
## Data Sending (Beacon sending)
44

55
All 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.
1918
If the server returned a status response a state transition to TimeSync is performed, otherwise
2019
OpenKit 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

2726
In 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.
3533
If the number of time sync retries is exceeded the time sync is unsuccessful and therefore a
3634
transition 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

4036
The 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
5147
request.
5248
If time sync is supported by the server and the initial time sync failed a state transition
5349
to 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
5551
if capturing was enabled by the server's status response. If capturing is disabled
5652
then 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

7975
The Terminal state (class `BeaconSendingTerminalState`) is the last state in OpenKit's internal
8076
state machine. After this state is reached the background thread responsible for sending data
81-
will end itself.
77+
is terminated gracefully.

0 commit comments

Comments
 (0)