Skip to content

Commit e34dc80

Browse files
committed
add support for custom request attributes
1 parent 1350b5e commit e34dc80

File tree

8 files changed

+40
-26
lines changed

8 files changed

+40
-26
lines changed

README.md

+28-9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This is the official Java implementation of the [Dynatrace OneAgent SDK](https:/
1919
* [Features](#features)
2020
* [Trace incoming and outgoing remote calls](#remoting)
2121
* [In process linking](#inprocess)
22+
* [Add custom request attributes](#scav)
2223
* [Further reading](#furtherreading)
2324
* [Help & Support](#help)
2425
* [Release notes](#releasenotes)
@@ -39,9 +40,10 @@ This is the official Java implementation of the [Dynatrace OneAgent SDK](https:/
3940
- Dynatrace OneAgent (required versions see below)
4041

4142
|OneAgent SDK for Java|Required OneAgent version|
42-
|:------|:--------|
43-
|1.1.0 |>=1.143 |
44-
|1.0.3 |>=1.135 |
43+
|:--------------------|:------------------------|
44+
|1.2.0 |>=1.147 |
45+
|1.1.0 |>=1.143 |
46+
|1.0.3 |>=1.135 |
4547

4648
<a name="integration" />
4749

@@ -55,7 +57,7 @@ If you want to integrate the OneAgent SDK into your application, just add the fo
5557
<dependency>
5658
<groupId>com.dynatrace.oneagent.sdk.java</groupId>
5759
<artifactId>oneagent-sdk</artifactId>
58-
<version>1.1.0</version>
60+
<version>1.2.0</version>
5961
<scope>compile</scope>
6062
</dependency>
6163

@@ -124,10 +126,11 @@ The feature sets differ slightly with each language implementation. More functio
124126

125127
A more detailed specification of the features can be found in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK#features).
126128

127-
|Feature|Required OneAgent SDK for Java version|
128-
|:------|:--------|
129-
|In process linking |>=1.1.0 |
130-
|Trace incoming and outgoing remote calls |>=1.0.3 |
129+
|Feature |Required OneAgent SDK for Java version|
130+
|:-----------------------------------------|:-------------------------------------|
131+
|Custom request attributes |>=1.2.0 |
132+
|In process linking |>=1.1.0 |
133+
|Trace incoming and outgoing remote calls |>=1.0.3 |
131134

132135
<a name="remoting" />
133136

@@ -195,6 +198,21 @@ try {
195198
}
196199
```
197200

201+
<a name="scav" />
202+
203+
### Add custom request attributes
204+
205+
You can use the SDK to add custom request attributes to current traced service. Custom request attributes allow you to do easier/better filtering of your requests in Dynatrace.
206+
207+
Adding custom request attributes to the currently traced service call is pretty simple. Just call one of the addCustomRequestAttribute methods with your key and value:
208+
209+
```Java
210+
oneAgentSDK.addCustomRequestAttribute("region", "EMEA");
211+
oneAgentSDK.addCustomRequestAttribute("salesAmount", 2500);
212+
```
213+
214+
When no service call is being traced, the custom request attributes are dropped.
215+
198216
<a name="furtherreading" />
199217

200218
## Further readings
@@ -232,7 +250,8 @@ SLAs apply according to the customer's support level.
232250

233251
see also https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases
234252

235-
|Version|Description|Links|
253+
|Version|Description |Links |
236254
|:------|:--------------------------------------|:----------------------------------------|
255+
|1.2.0 |Added support for in-process-linking |note released|
237256
|1.1.0 |Added support for in-process-linking |[binary](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.1.0/oneagent-sdk-1.1.0.jar) [source](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.1.0/oneagent-sdk-1.1.0-sources.jar) [javadoc](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.1.0/oneagent-sdk-1.1.0-javadoc.jar)|
238257
|1.0.3 |Initial release |[binary](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3.jar) [source](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3-sources.jar) [javadoc](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3-javadoc.jar)|

samples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Check your Dynatrace environment for newly created service like that:
2525
![remotecall-server](img/remotecall-service.png)
2626

2727
### Run InProcessLinking sample application
28-
This Application shows how to in-process-linking is being sued. To run this sample you need to create a custom service for your tenant. and of course Dynatrace OneAgent must be installed.
28+
This Application shows how to in-process-linking and custom service attributes are being used. To run this sample you need to create a custom service for your tenant - and of course Dynatrace OneAgent must be installed.
2929

3030
- ensure you have custom service for method `startAsyncOperation` in class `com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp`
3131
- run sample: `mvn exec:exec`

samples/in-process-linking/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
<groupId>com.dynatrace.oneagent.sdk.samples.inprocesslinking</groupId>
88
<artifactId>in-process-linking-sample</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<packaging>jar</packaging>
1111

1212
<dependencies>
1313
<dependency>
1414
<groupId>com.dynatrace.oneagent.sdk.java</groupId>
1515
<artifactId>oneagent-sdk</artifactId>
16-
<version>1.1.0</version>
16+
<version>1.2.0</version>
1717
<scope>compile</scope>
1818
</dependency>
1919
</dependencies>

samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/InProcessLinkingApp.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.dynatrace.oneagent.sdk.samples.inprocesslinking;
22

3-
import java.io.BufferedReader;
4-
53
/*
64
* Copyright 2018 Dynatrace LLC
75
*
@@ -19,13 +17,8 @@
1917
*/
2018

2119
import java.io.IOException;
22-
import java.io.InputStream;
23-
import java.io.InputStreamReader;
2420
import java.net.URL;
2521
import java.sql.SQLException;
26-
import java.util.List;
27-
import java.util.Map;
28-
import java.util.Map.Entry;
2922
import java.util.concurrent.ArrayBlockingQueue;
3023
import java.util.concurrent.BlockingQueue;
3124

@@ -107,7 +100,10 @@ private String startAsyncOperation() throws IOException, ClassNotFoundException,
107100

108101
// e. g.: https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/tag/v1.0.3
109102
String location = url.getHeaderField("Location");
110-
String latestVersion = location.substring(location.lastIndexOf('/')+1);
103+
String latestVersion = location.substring(location.lastIndexOf('/') + 1);
104+
105+
// tag this request using the found SDK version:
106+
oneAgentSdk.addCustomRequestAttribute("oneagentsdk.java.version", latestVersion);
111107

112108
// download the big release archive asynchronously ...
113109
UrlDownloadItem asyncWorkItem = new UrlDownloadItem(

samples/remotecall/parent/pom.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
<groupId>com.dynatrace.oneagent.sdk.samples.remoting</groupId>
88
<artifactId>parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<packaging>pom</packaging>
1111
<!-- Dynatrace OneAgent SDK can be found in jcentral: -->
12-
<!-- FIXME: add coordinates to jcentral -->
1312
<dependencies>
1413
<dependency>
1514
<groupId>com.dynatrace.oneagent.sdk.java</groupId>
1615
<artifactId>oneagent-sdk</artifactId>
17-
<version>1.1.0</version>
16+
<version>1.2.0</version>
1817
<scope>compile</scope>
1918
</dependency>
2019
</dependencies>

samples/remotecall/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.dynatrace.oneagent.sdk.samples.remoting</groupId>
88
<artifactId>remotecall-sample</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<packaging>pom</packaging>
1111

1212
<modules>

samples/remotecall/remotecall-client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.dynatrace.oneagent.sdk.samples.remoting</groupId>
99
<artifactId>parent</artifactId>
10-
<version>1.1.0</version>
10+
<version>1.2.0</version>
1111
<relativePath>../parent/pom.xml</relativePath>
1212
</parent>
1313

samples/remotecall/remotecall-server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.dynatrace.oneagent.sdk.samples.remoting</groupId>
99
<artifactId>parent</artifactId>
10-
<version>1.1.0</version>
10+
<version>1.2.0</version>
1111
<relativePath>../parent/pom.xml</relativePath>
1212
</parent>
1313

0 commit comments

Comments
 (0)