Skip to content

Commit 6d9b253

Browse files
committed
CS review
1 parent a811079 commit 6d9b253

File tree

7 files changed

+36
-73
lines changed

7 files changed

+36
-73
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
# Dynatrace OneAgent SDK for Java
44

5-
This SDK allows Dynatrace customers to instrument java applications. This is useful to enhance the visibility for prioritary frameworks or custom framework not directly supported by Dynatrace OneAgent out of the box.
5+
This SDK allows Dynatrace customers to instrument java applications. This is useful to enhance the visibility for proprietary frameworks or custom frameworks not directly supported by Dynatrace OneAgent out-of-the-box.
66

7-
It provides the java implementation of the [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK).
7+
It provides the Java implementation of the [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK).
88

99
## Package contents
1010

1111
- `samples`: contains sample application, which demonstrates the usage of the SDK. see readme inside the samples directory for more details
1212
- `LICENSE`: license under which the whole SDK and sample applications are published
1313

1414
## Features
15-
Dynatrace OneAgent SDK for Java adds support for following features (corresponding to features specified in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK)):
16-
- outgoing and incoming remote call
15+
Dynatrace OneAgent SDK for Java currently implements support for the following features (corresponding to features specified in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK)):
16+
- outgoing and incoming remote calls
1717

1818
## Integrating into your application
1919

@@ -34,11 +34,11 @@ If you prefer to integrate the SDK using plain jar file, just download them from
3434
The Dynatrace OneAgent SDK for Java has no further dependencies.
3535

3636
### Troubleshooting
37-
If the SDK can't connect to the OneAgent (see usage of SDKState in samples) or you you don't see the desired result in the Dynatrace UI, you might set the following system property to print debug information to standard out:
37+
If the SDK can't connect to the OneAgent (see usage of SDKState in samples) or you you don't see the desired result in the Dynatrace UI, you can set the following system property to print debug information to standard out:
3838

3939
-Dcom.dynatrace.oneagent.sdk.debug=true
4040

41-
This will provide SDK related debug information in agent log. Additionally ensure, that you have set an `LoggingCallback` in your application. For usage see class `StdErrLoggingCallback` in `remotecall-server` module (in samples/remotecall folder).
41+
Additionally you should/have to ensure, that you have set a `LoggingCallback`. For usage see class `StdErrLoggingCallback` in `remotecall-server` module (in samples/remotecall folder).
4242

4343
## OneAgent SDK for Java Requirements
4444

@@ -52,7 +52,7 @@ This will provide SDK related debug information in agent log. Additionally ensur
5252

5353
## Feedback
5454

55-
In case of questions, issues or feature requests feel free to contact [Michael Kopp](https://github.com/mikopp) or [Alram Lechner](https://github.com/AlramLechnerDynatrace). Your feedback is welcome!
55+
In case of questions, issues or feature requests feel free to contact [Michael Kopp](https://github.com/mikopp), [Alram Lechner](https://github.com/AlramLechnerDynatrace) or file an issue. Your feedback is welcome!
5656

5757

5858
## OneAgent SDK for Java release notes

samples/README.md

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Sample applications showing how to use Dynatrace OneAgent SDK for Java to create
44

55
## Contents
66

7-
- `remotecall`: shows usage of remote call API. Allows you to tag remote calls in same or between different JVM's.
7+
- `remotecall`: shows usage of remote call API. Allows you to tag remote calls in the same or between different JVMs.
88

99
## Build and prepare running sample applications
1010

@@ -14,49 +14,10 @@ Sample applications showing how to use Dynatrace OneAgent SDK for Java to create
1414
- run `mvn package` in root directory of the desired sample
1515

1616
### Run RemoteCall sample application
17-
This Application shows how to trace remote calls and tag them. To run this sample you need to start a server and client sample application - both with Dynatrace agent injected.
17+
This Application shows how to trace remote calls and tag them. To run this sample you need to start a server and client sample application - both with Dynatrace OneAgent injected.
1818

1919
- Server: `mvn -pl remotecall-server exec:exec`
2020

2121
- Client: `mvn -pl remotecall-client exec:exec`
2222

23-
Check your Dynatrace environment for newly created services.
24-
25-
## Integrating into your application
26-
If you want to integrate the OneAgent SDK into your application, just add the following maven dependency:
27-
28-
<dependency>
29-
<groupId>com.dynatrace.oneagent.sdk.java</groupId>
30-
<artifactId>oneagent-sdk</artifactId>
31-
<version>1.0.1</version>
32-
<scope>compile</scope>
33-
</dependency>
34-
35-
If you prefer to integrate the SDK using plain jar file, just download them from mavenCentral: FIXME: add link to mavenCentral
36-
37-
## Troubleshooting
38-
As long as the SDK can't connect to agent (see output of sample), you might set the following system property to print debug information to standard out:
39-
40-
-Dcom.dynatrace.oneagent.sdk.debug=true
41-
42-
As soon as SDK is active, but no paths are shown in Dynatrace UI, enable the agent debug flag:
43-
44-
debugOneAgentSdkJava=true
45-
46-
This will provide additional debug information in agent log.
47-
48-
Additionally ensure, that you have set an `LoggingCallback` in your application. For usage see class `StdErrLoggingCallback` in `remotecall-server` module.
49-
50-
## OneAgent SDK for Java Requirements
51-
- JRE 1.6 or higher
52-
- Dynatrace OneAgent Java (supported versions see below)
53-
54-
## Compatibility OneAgent SDK for Java releases with OneAgent for Java releases
55-
|OneAgent SDK for Java|Dynatrace OneAgent Java|
56-
|:------|:--------|
57-
|1.0.1 |>=1.135 |
58-
59-
## Release Notes (OneAgent SDK for Java)
60-
|Version|Date|Description|
61-
|:------|:----------|:--------------|
62-
|1.0.1 |01.2018 |Initial release|
23+
Check your Dynatrace environment for newly created services.

samples/remotecall/remotecall-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<archive>
2525
<manifest>
2626
<addClasspath>true</addClasspath>
27-
<mainClass>com.dynatrace.sample.oneagent.sdk.ClientApp</mainClass>
27+
<mainClass>com.dynatrace.oneagent.sdk.samples.ClientApp</mainClass>
2828
</manifest>
2929
</archive>
3030
</configuration>

samples/remotecall/remotecall-client/src/main/java/com/dynatrace/sample/oneagent/sdk/ClientApp.java renamed to samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/ClientApp.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dynatrace.sample.oneagent.sdk;
1+
package com.dynatrace.oneagent.sdk.samples;
22

33
/*
44
* Copyright 2018 Dynatrace LLC
@@ -37,10 +37,10 @@ private ClientApp() {
3737
break;
3838
case PERMANENTLY_INACTIVE:
3939
System.err.println(
40-
"SDK is PERMANENTLY_INACTIVE; Probably no agent injected or agent is incompatible with SDK.");
40+
"SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK.");
4141
break;
4242
case TEMPORARILY_INACTIVE:
43-
System.err.println("SDK is TEMPORARILY_INACTIVE; Agent has been deactived - check agent configuration.");
43+
System.err.println("SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration.");
4444
break;
4545
default:
4646
System.err.println("SDK is in unknown state.");
@@ -62,12 +62,12 @@ public static void main(String args[]) {
6262
}
6363
try {
6464
new ClientApp().run(port);
65-
System.out.println("remote call client finished. sleeping a while, so agent is able to send data to server ...");
66-
Thread.sleep(15000); // we have to wait - so agent is able to send data to server.
65+
System.out.println("remote call client finished. sleeping a while, so OneAgent is able to send data to server ...");
66+
Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server.
6767
} catch (Exception e) {
6868
System.err.println("remote call client failed: " + e.getMessage());
6969
e.printStackTrace();
70-
System.exit(-1);
70+
System.exit(1);
7171
}
7272
}
7373

@@ -79,7 +79,6 @@ private void run(int port) throws IOException, ClassNotFoundException {
7979
+ " connected");
8080
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
8181
traceCallToServer(out, port);
82-
8382
} finally {
8483
socket.close();
8584
}
@@ -102,6 +101,7 @@ private void traceCallToServer(ObjectOutputStream out, int port) throws IOExcept
102101
private void invokeCallToServer(ObjectOutputStream out, String outgoingTag) throws IOException {
103102
// call the server and send the tag
104103
out.writeObject(outgoingTag);
104+
out.writeObject("the top secret message");
105105
}
106106

107107
}

samples/remotecall/remotecall-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<archive>
2525
<manifest>
2626
<addClasspath>true</addClasspath>
27-
<mainClass>com.dynatrace.sample.oneagent.sdk.ServerApp</mainClass>
27+
<mainClass>com.dynatrace.oneagent.sdk.samples.ServerApp</mainClass>
2828
</manifest>
2929
</archive>
3030
</configuration>

samples/remotecall/remotecall-server/src/main/java/com/dynatrace/sample/oneagent/sdk/ServerApp.java renamed to samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/ServerApp.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dynatrace.sample.oneagent.sdk;
1+
package com.dynatrace.oneagent.sdk.samples;
22

33
/*
44
* Copyright 2018 Dynatrace LLC
@@ -26,13 +26,12 @@
2626
import com.dynatrace.oneagent.sdk.api.OneAgentSDK;
2727

2828
/**
29-
* ServerApp is listing for
29+
* ServerApp is listing for remote call requests from remote-call client.
3030
*
3131
* @author Alram.Lechner
3232
*
3333
*/
3434
public class ServerApp {
35-
3635

3736
private final OneAgentSDK oneAgentSdk;
3837

@@ -45,10 +44,10 @@ private ServerApp() {
4544
break;
4645
case PERMANENTLY_INACTIVE:
4746
System.err.println(
48-
"SDK is PERMANENT_INACTIVE; Probably no agent injected or agent is incompatible with SDK.");
47+
"SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK.");
4948
break;
5049
case TEMPORARILY_INACTIVE:
51-
System.err.println("SDK is TEMPORARY_INACTIVE; Agent has been deactived - check agent configuration.");
50+
System.err.println("SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration.");
5251
break;
5352
default:
5453
System.err.println("SDK is in unknown state.");
@@ -70,8 +69,8 @@ public static void main(String args[]) {
7069
}
7170
try {
7271
new ServerApp().run(port);
73-
System.out.println("remote call server stopped. sleeping a while, so agent is able to send data to server ...");
74-
Thread.sleep(15000); // we have to wait - so agent is able to send data to server.
72+
System.out.println("remote call server stopped. sleeping a while, so OneAgent is able to send data to server ...");
73+
Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server.
7574
} catch (Exception e) {
7675
System.err.println("remote call server failed: " + e.getMessage());
7776
e.printStackTrace();
@@ -82,16 +81,18 @@ public static void main(String args[]) {
8281
private void run(int port) throws IOException, ClassNotFoundException {
8382
ServerSocket serverSocket = new ServerSocket(port);
8483
try {
85-
System.out.println("Waiting for clients no port " + serverSocket.getInetAddress().getHostName() + ":"
84+
System.out.println("Waiting for clients on port " + serverSocket.getInetAddress().getHostName() + ":"
8685
+ serverSocket.getLocalPort());
8786
Socket client = serverSocket.accept();
8887
try {
8988
System.out.println(
9089
"Client " + client.getInetAddress().getHostName() + ":" + client.getPort() + " connected");
9190
ObjectInputStream in = new ObjectInputStream(client.getInputStream());
92-
Object receviedTag = in.readObject();
93-
System.out.println("received tag: " + receviedTag.toString());
94-
traceClientRequest(receviedTag);
91+
92+
Object receivedTag = in.readObject();
93+
String receivedMessage = (String) in.readObject();
94+
System.out.println("received tag: " + receivedTag.toString());
95+
traceCallFromClient(receivedTag, receivedMessage);
9596
} finally {
9697
client.close();
9798
}
@@ -100,7 +101,7 @@ private void run(int port) throws IOException, ClassNotFoundException {
100101
}
101102
}
102103

103-
private void traceClientRequest(Object receivedTag) {
104+
private void traceCallFromClient(Object receivedTag, String receivedMessage) {
104105
IncomingRemoteCallTracer incomingRemoteCall = oneAgentSdk.traceIncomingRemoteCall("myMethod", "myService", "endpoint");
105106
if (receivedTag instanceof String) {
106107
incomingRemoteCall.setDynatraceStringTag((String) receivedTag);
@@ -112,7 +113,7 @@ private void traceClientRequest(Object receivedTag) {
112113

113114
incomingRemoteCall.start();
114115
try {
115-
handleClientRequest();
116+
handleCallFromClient(receivedMessage);
116117
} catch (Exception e) {
117118
incomingRemoteCall.error(e);
118119
} finally {
@@ -121,8 +122,9 @@ private void traceClientRequest(Object receivedTag) {
121122

122123
}
123124

124-
private void handleClientRequest() {
125+
private void handleCallFromClient(String receivedMessage) {
125126
// do whatever the server should do ...
127+
System.out.println("Received message from client: " + receivedMessage);
126128
}
127129

128130
}

samples/remotecall/remotecall-server/src/main/java/com/dynatrace/sample/oneagent/sdk/StdErrLoggingCallback.java renamed to samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/StdErrLoggingCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dynatrace.sample.oneagent.sdk;
1+
package com.dynatrace.oneagent.sdk.samples;
22

33
/*
44
* Copyright 2018 Dynatrace LLC

0 commit comments

Comments
 (0)