├── .gitignore ├── LICENSE ├── README.md ├── docs ├── META-INF │ └── MANIFEST.MF ├── allclasses-frame.html ├── allclasses-noframe.html ├── com │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ ├── OneAgentSDKFactory.html │ │ ├── api │ │ ├── CustomServiceTracer.html │ │ ├── DatabaseRequestTracer.html │ │ ├── InProcessLink.html │ │ ├── InProcessLinkTracer.html │ │ ├── IncomingMessageProcessTracer.html │ │ ├── IncomingMessageReceiveTracer.html │ │ ├── IncomingRemoteCallTracer.html │ │ ├── IncomingTaggable.html │ │ ├── IncomingWebRequestTracer.html │ │ ├── LoggingCallback.html │ │ ├── OneAgentSDK.html │ │ ├── OutgoingMessageTracer.html │ │ ├── OutgoingRemoteCallTracer.html │ │ ├── OutgoingTaggable.html │ │ ├── OutgoingWebRequestTracer.html │ │ ├── Tracer.html │ │ ├── enums │ │ │ ├── ChannelType.html │ │ │ ├── DatabaseVendor.html │ │ │ ├── MessageDestinationType.html │ │ │ ├── MessageSystemVendor.html │ │ │ ├── SDKState.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ └── package-tree.html │ │ ├── infos │ │ │ ├── DatabaseInfo.html │ │ │ ├── MessagingSystemInfo.html │ │ │ ├── TraceContextInfo.html │ │ │ ├── WebApplicationInfo.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ └── package-tree.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html ├── constant-values.html ├── deprecated-list.html ├── help-doc.html ├── index-all.html ├── index.html ├── overview-frame.html ├── overview-summary.html ├── overview-tree.html ├── package-list ├── resources │ └── inherit.gif └── stylesheet.css ├── samples ├── README.md ├── custom-service │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ └── samples │ │ └── customservice │ │ ├── CustomServiceApp.java │ │ └── StdErrLoggingCallback.java ├── database │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ └── samples │ │ └── database │ │ ├── DatabaseApp.java │ │ └── StdErrLoggingCallback.java ├── img │ ├── in-process-linking-service.png │ ├── remotecall-service.png │ └── webrequest-service.png ├── in-process-linking │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ └── samples │ │ └── inprocesslinking │ │ ├── InProcessLinkingApp.java │ │ ├── StdErrLoggingCallback.java │ │ ├── UrlDownloadItem.java │ │ └── UrlDownloaderThread.java ├── messaging │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ └── samples │ │ └── messaging │ │ ├── FakedQueueManager.java │ │ ├── Message.java │ │ ├── MessageListener.java │ │ ├── MessagingApp.java │ │ └── StdErrLoggingCallback.java ├── remotecall │ ├── parent │ │ └── pom.xml │ ├── pom.xml │ ├── remotecall-client │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── dynatrace │ │ │ └── oneagent │ │ │ └── sdk │ │ │ └── samples │ │ │ └── remoting │ │ │ └── ClientApp.java │ └── remotecall-server │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── dynatrace │ │ └── oneagent │ │ └── sdk │ │ └── samples │ │ └── remoting │ │ ├── ServerApp.java │ │ └── StdErrLoggingCallback.java └── webrequest │ ├── .gitignore │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── dynatrace │ └── oneagent │ └── sdk │ └── samples │ └── webrequest │ ├── FakedHttpClient.java │ ├── FakedWebserver.java │ ├── StdErrLoggingCallback.java │ └── WebRequestApp.java └── src ├── main └── java │ └── com │ └── dynatrace │ └── oneagent │ └── sdk │ ├── OneAgentSDKFactory.java │ ├── api │ ├── CustomServiceTracer.java │ ├── DatabaseRequestTracer.java │ ├── InProcessLink.java │ ├── InProcessLinkTracer.java │ ├── IncomingMessageProcessTracer.java │ ├── IncomingMessageReceiveTracer.java │ ├── IncomingRemoteCallTracer.java │ ├── IncomingTaggable.java │ ├── IncomingWebRequestTracer.java │ ├── LoggingCallback.java │ ├── OneAgentSDK.java │ ├── OutgoingMessageTracer.java │ ├── OutgoingRemoteCallTracer.java │ ├── OutgoingTaggable.java │ ├── OutgoingWebRequestTracer.java │ ├── Tracer.java │ ├── enums │ │ ├── ChannelType.java │ │ ├── DatabaseVendor.java │ │ ├── MessageDestinationType.java │ │ ├── MessageSystemVendor.java │ │ └── SDKState.java │ └── infos │ │ ├── DatabaseInfo.java │ │ ├── MessagingSystemInfo.java │ │ ├── TraceContextInfo.java │ │ └── WebApplicationInfo.java │ └── impl │ ├── OneAgentSDKFactoryImpl.java │ ├── SDKInstanceProvider.java │ ├── noop │ ├── CustomServiceTracerNoop.java │ ├── DatabaseInfoNoop.java │ ├── DatabaseRequestTracerNoop.java │ ├── InProcessLinkNoop.java │ ├── InProcessLinkTracerNoop.java │ ├── IncomingMessageProcessTracerNoop.java │ ├── IncomingMessageReceiveTracerNoop.java │ ├── IncomingWebRequestTracerNoop.java │ ├── MessagingSystemInfoNoop.java │ ├── NodeNoop.java │ ├── OneAgentSDKNoop.java │ ├── OutgoingMessageTracerNoop.java │ ├── OutgoingWebRequestTracerNoop.java │ ├── RemoteCallClientTracerNoop.java │ ├── RemoteCallServerTracerNoop.java │ ├── TraceContextInfoNoop.java │ └── WebApplicationInfoNoop.java │ └── proxy │ ├── CustomServiceTracerProxy.java │ ├── DatabaseInfoImpl.java │ ├── DatabaseRequestTracerProxy.java │ ├── InProcessLinkImpl.java │ ├── InProcessLinkTracerProxy.java │ ├── IncomingMessageProcessTracerProxy.java │ ├── IncomingMessageReceiveTracerProxy.java │ ├── IncomingWebRequestProxy.java │ ├── MessagingSystemInfoImpl.java │ ├── OneAgentSDKProxy.java │ ├── OutgoingMessageTracerProxy.java │ ├── OutgoingWebRequestTracerProxy.java │ ├── RemoteCallClientProxy.java │ ├── RemoteCallServerProxy.java │ ├── SDK2AgentInternalApiProxy.java │ ├── TraceContextInfoImpl.java │ ├── TraceableProxy.java │ ├── WebApplicationInfoImpl.java │ └── package-info.java └── test └── java └── com └── dynatrace └── oneagent └── sdk └── impl ├── OneAgentSDKFactoryImplTest.java └── SDKInstanceProviderTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | target 5 | -------------------------------------------------------------------------------- /docs/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /docs/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 77 | 78 |
ChannelType 25 |
26 | CustomServiceTracer 27 |
28 | DatabaseInfo 29 |
30 | DatabaseRequestTracer 31 |
32 | DatabaseVendor 33 |
34 | IncomingMessageProcessTracer 35 |
36 | IncomingMessageReceiveTracer 37 |
38 | IncomingRemoteCallTracer 39 |
40 | IncomingTaggable 41 |
42 | IncomingWebRequestTracer 43 |
44 | InProcessLink 45 |
46 | InProcessLinkTracer 47 |
48 | LoggingCallback 49 |
50 | MessageDestinationType 51 |
52 | MessageSystemVendor 53 |
54 | MessagingSystemInfo 55 |
56 | OneAgentSDK 57 |
58 | OneAgentSDKFactory 59 |
60 | OutgoingMessageTracer 61 |
62 | OutgoingRemoteCallTracer 63 |
64 | OutgoingTaggable 65 |
66 | OutgoingWebRequestTracer 67 |
68 | SDKState 69 |
70 | TraceContextInfo 71 |
72 | Tracer 73 |
74 | WebApplicationInfo 75 |
76 |
79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 77 | 78 |
ChannelType 25 |
26 | CustomServiceTracer 27 |
28 | DatabaseInfo 29 |
30 | DatabaseRequestTracer 31 |
32 | DatabaseVendor 33 |
34 | IncomingMessageProcessTracer 35 |
36 | IncomingMessageReceiveTracer 37 |
38 | IncomingRemoteCallTracer 39 |
40 | IncomingTaggable 41 |
42 | IncomingWebRequestTracer 43 |
44 | InProcessLink 45 |
46 | InProcessLinkTracer 47 |
48 | LoggingCallback 49 |
50 | MessageDestinationType 51 |
52 | MessageSystemVendor 53 |
54 | MessagingSystemInfo 55 |
56 | OneAgentSDK 57 |
58 | OneAgentSDKFactory 59 |
60 | OutgoingMessageTracer 61 |
62 | OutgoingRemoteCallTracer 63 |
64 | OutgoingTaggable 65 |
66 | OutgoingWebRequestTracer 67 |
68 | SDKState 69 |
70 | TraceContextInfo 71 |
72 | Tracer 73 |
74 | WebApplicationInfo 75 |
76 |
79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/com/dynatrace/oneagent/sdk/api/enums/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.dynatrace.oneagent.sdk.api.enums (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.dynatrace.oneagent.sdk.api.enums 20 | 21 | 22 | 35 | 36 |
23 | Enums  24 | 25 |
26 | ChannelType 27 |
28 | DatabaseVendor 29 |
30 | MessageDestinationType 31 |
32 | MessageSystemVendor 33 |
34 | SDKState
37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/com/dynatrace/oneagent/sdk/api/infos/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.dynatrace.oneagent.sdk.api.infos (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.dynatrace.oneagent.sdk.api.infos 20 | 21 | 22 | 33 | 34 |
23 | Interfaces  24 | 25 |
26 | DatabaseInfo 27 |
28 | MessagingSystemInfo 29 |
30 | TraceContextInfo 31 |
32 | WebApplicationInfo
35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/com/dynatrace/oneagent/sdk/api/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.dynatrace.oneagent.sdk.api (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.dynatrace.oneagent.sdk.api 20 | 21 | 22 | 57 | 58 |
23 | Interfaces  24 | 25 |
26 | CustomServiceTracer 27 |
28 | DatabaseRequestTracer 29 |
30 | IncomingMessageProcessTracer 31 |
32 | IncomingMessageReceiveTracer 33 |
34 | IncomingRemoteCallTracer 35 |
36 | IncomingTaggable 37 |
38 | IncomingWebRequestTracer 39 |
40 | InProcessLink 41 |
42 | InProcessLinkTracer 43 |
44 | LoggingCallback 45 |
46 | OneAgentSDK 47 |
48 | OutgoingMessageTracer 49 |
50 | OutgoingRemoteCallTracer 51 |
52 | OutgoingTaggable 53 |
54 | OutgoingWebRequestTracer 55 |
56 | Tracer
59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /docs/com/dynatrace/oneagent/sdk/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.dynatrace.oneagent.sdk (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.dynatrace.oneagent.sdk 20 | 21 | 22 | 27 | 28 |
23 | Classes  24 | 25 |
26 | OneAgentSDKFactory
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/com/dynatrace/oneagent/sdk/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.dynatrace.oneagent.sdk Class Hierarchy (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Hierarchy For Package com.dynatrace.oneagent.sdk 84 |

85 |
86 |
87 |
Package Hierarchies:
All Packages
88 |
89 |

90 | Class Hierarchy 91 |

92 | 96 |
97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 118 | 121 | 122 | 123 | 124 | 127 | 143 | 144 |
119 | 120 |
145 | 146 | 147 | 148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /docs/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Deprecated API

84 |
85 |
86 | Contents 88 | 89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | sdk 1.9.0 API 8 | 9 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | <H2> 65 | Frame Alert</H2> 66 | 67 | <P> 68 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 69 | <BR> 70 | Link to<A HREF="overview-summary.html">Non-frame version.</A> 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /docs/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (sdk 1.9.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
22 |
25 | 26 | 27 | 28 | 42 | 43 |
All Classes 29 |

30 | 31 | Packages 32 |
33 | com.dynatrace.oneagent.sdk 34 |
35 | com.dynatrace.oneagent.sdk.api 36 |
37 | com.dynatrace.oneagent.sdk.api.enums 38 |
39 | com.dynatrace.oneagent.sdk.api.infos 40 |
41 |

44 | 45 |

46 |   47 | 48 | 49 | -------------------------------------------------------------------------------- /docs/package-list: -------------------------------------------------------------------------------- 1 | com.dynatrace.oneagent.sdk 2 | com.dynatrace.oneagent.sdk.api 3 | com.dynatrace.oneagent.sdk.api.enums 4 | com.dynatrace.oneagent.sdk.api.infos 5 | -------------------------------------------------------------------------------- /docs/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dynatrace/OneAgent-SDK-for-Java/9ac8eee0c0f319a303dd2bd08cbee17afa16c7c1/docs/resources/inherit.gif -------------------------------------------------------------------------------- /docs/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | # Sample applications for OneAgent SDK for Java 2 | 3 | Sample applications showing how to use Dynatrace OneAgent SDK for Java to create custom specific PurePaths and service calls. 4 | 5 | ## Contents 6 | 7 | - `remotecall`: shows usage of remote call API. Allows you to tag remote calls in the same or between different JVMs. 8 | - `in-process-linking`: shows usage of in-process-linking API. Allows you to tag eg. asynchronous execution inside the same process. 9 | - `webrequest`: shows usage of outgoing and incoming web request tracing 10 | - `messaging`: shows usage of messaging 11 | - `database`: shows usage of database request tracing 12 | 13 | ## Build and prepare running sample applications 14 | 15 | - ensure you have Apache Maven 3.5 installed, see: [Apache Maven](https://maven.apache.org/) 16 | - ensure Dynatrace OneAgent is installed. If not see our [free Trial](https://www.dynatrace.com/trial/?vehicle_name=https://github.com/Dynatrace/OneAgent-SDK-for-Java) 17 | - clone this repository 18 | - run `mvn package` in root directory of the desired sample 19 | 20 | ### Run RemoteCall sample application 21 | 22 | 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. 23 | 24 | - Server: `mvn -pl remotecall-server exec:exec` 25 | 26 | - Client: `mvn -pl remotecall-client exec:exec` 27 | 28 | Check your Dynatrace environment for newly created service like that: 29 | ![remotecall-server](img/remotecall-service.png) 30 | 31 | ### Run InProcessLinking sample application 32 | 33 | 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. 34 | 35 | - ensure you have custom service for method `startAsyncOperation` in class `com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp` 36 | - run sample: `mvn exec:exec` 37 | 38 | Check your Dynatrace environment for newly created services like that: 39 | ![in-process-linking-service](img/in-process-linking-service.png) 40 | 41 | ### Run WebRequest sample application 42 | 43 | This Application shows how to trace outgoing- and incoming webrequests. To run this sample you just go into the sample directory and run the sample by typing: 44 | 45 | - run sample: `mvn exec:exec` 46 | 47 | ### Run Messaging sample application 48 | 49 | This Application shows how to trace outgoing, receiving and processing of incoming messages. To run this sample you just go into the sample directory and run the sample by typing: 50 | 51 | - run sample: `mvn exec:exec` 52 | 53 | ### Run DatabaseRequest sample application 54 | 55 | This Application shows how to trace database requests. To run this sample you just go into the sample directory and run the sample by typing: 56 | 57 | - run sample: `mvn exec:exec` 58 | 59 | To run this sample you need to create a custom service for your tenant. See source of sample app for details. 60 | 61 | ### Run custom service sample application 62 | 63 | This Application shows how to trace a custom service. 64 | To run this sample, go into the sample directory and run the sample by typing: 65 | 66 | - run sample: `mvn exec:exec` 67 | 68 | -------------------------------------------------------------------------------- /samples/custom-service/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.customservice 8 | custom-service-sample 9 | 1.8.0 10 | jar 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.8.0 17 | compile 18 | 19 | 20 | 21 | https://github.com/Dynatrace/OneAgent-SDK-Java 22 | Dynatrace OneAgent SDK Java custom service sample 23 | 24 | Dynatrace 25 | http://www.dynatrace.com 26 | 27 | 28 | 29 | 1.6 30 | 1.6 31 | UTF-8 32 | UTF-8 33 | 34 | 35 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.4 51 | 52 | 53 | 54 | true 55 | com.dynatrace.oneagent.sdk.samples.customservice.CustomServiceApp 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | exec-maven-plugin 63 | 1.6.0 64 | 65 | 66 | 67 | exec 68 | 69 | 70 | 71 | 72 | java 73 | 74 | ${agent.agentpath} 75 | -classpath 76 | 77 | com.dynatrace.oneagent.sdk.samples.customservice.CustomServiceApp 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/CustomServiceApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.customservice; 2 | 3 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 4 | import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; 5 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 6 | 7 | /** 8 | * Sample application that shows how a custom service should be traced. 9 | * 10 | * @author wolfgang.ziegler@dynatrace.com 11 | * 12 | */ 13 | public class CustomServiceApp { 14 | 15 | private final OneAgentSDK oneAgentSdk; 16 | 17 | static CustomServiceApp instance; 18 | 19 | private CustomServiceApp() { 20 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 21 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 22 | switch (oneAgentSdk.getCurrentState()) { 23 | case ACTIVE: 24 | System.out.println("SDK is active and capturing."); 25 | break; 26 | case PERMANENTLY_INACTIVE: 27 | System.err.println( 28 | "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 29 | break; 30 | case TEMPORARILY_INACTIVE: 31 | System.err.println( 32 | "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 33 | break; 34 | default: 35 | System.err.println("SDK is in unknown state."); 36 | break; 37 | } 38 | instance = this; 39 | } 40 | 41 | public static void main(String args[]) { 42 | System.out.println("*************************************************************"); 43 | System.out.println("** Running custom service request sample **"); 44 | System.out.println("*************************************************************"); 45 | try { 46 | CustomServiceApp app = new CustomServiceApp(); 47 | 48 | app.traceCustomService(); 49 | 50 | System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); 51 | Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server 52 | } catch (Exception e) { 53 | System.err.println("custom service request sample failed: " + e.getMessage()); 54 | e.printStackTrace(); 55 | System.exit(-1); 56 | } 57 | } 58 | 59 | private void traceCustomService() throws Exception { 60 | String serviceMethod = "onTimer"; 61 | String serviceName = "PeriodicCleanupTask"; 62 | CustomServiceTracer tracer = oneAgentSdk.traceCustomService(serviceMethod, serviceName); 63 | tracer.start(); 64 | try { 65 | doOtherThings(); 66 | } catch (Exception e) { 67 | tracer.error(e.getMessage()); 68 | throw e; 69 | } finally { 70 | tracer.end(); 71 | } 72 | } 73 | 74 | private void doOtherThings() { 75 | // ... 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.customservice; 2 | 3 | /* 4 | * Copyright 2021 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/database/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.messaging 8 | messaging-sample 9 | 1.7.0 10 | jar 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.7.0 17 | compile 18 | 19 | 20 | 21 | https://github.com/Dynatrace/OneAgent-SDK-Java 22 | Dynatrace OneAgent SDK Java database request sample 23 | 24 | Dynatrace 25 | http://www.dynatrace.com 26 | 27 | 28 | 29 | 1.6 30 | 1.6 31 | UTF-8 32 | UTF-8 33 | 34 | 35 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.4 51 | 52 | 53 | 54 | true 55 | com.dynatrace.oneagent.sdk.samples.database.DatabaseApp 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | exec-maven-plugin 63 | 1.6.0 64 | 65 | 66 | 67 | exec 68 | 69 | 70 | 71 | 72 | java 73 | 74 | ${agent.agentpath} 75 | -classpath 76 | 77 | com.dynatrace.oneagent.sdk.samples.database.DatabaseApp 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/DatabaseApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.database; 2 | 3 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 4 | import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; 5 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 6 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 7 | import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; 8 | 9 | /** 10 | * Sample application shows how database requests should be traced. 11 | * 12 | * @author Alram.Lechner 13 | * 14 | */ 15 | public class DatabaseApp { 16 | 17 | private final OneAgentSDK oneAgentSdk; 18 | 19 | static DatabaseApp instance; 20 | 21 | private DatabaseApp() { 22 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 23 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 24 | switch (oneAgentSdk.getCurrentState()) { 25 | case ACTIVE: 26 | System.out.println("SDK is active and capturing."); 27 | break; 28 | case PERMANENTLY_INACTIVE: 29 | System.err.println( 30 | "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 31 | break; 32 | case TEMPORARILY_INACTIVE: 33 | System.err.println( 34 | "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 35 | break; 36 | default: 37 | System.err.println("SDK is in unknown state."); 38 | break; 39 | } 40 | instance = this; 41 | } 42 | 43 | public static void main(String args[]) { 44 | System.out.println("*************************************************************"); 45 | System.out.println("** Running database request sample **"); 46 | System.out.println("*************************************************************"); 47 | try { 48 | DatabaseApp app = new DatabaseApp(); 49 | 50 | app.traceSqlRequest("Select * from anyTable"); 51 | 52 | System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); 53 | Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server 54 | } catch (Exception e) { 55 | System.err.println("database request sample failed: " + e.getMessage()); 56 | e.printStackTrace(); 57 | System.exit(-1); 58 | } 59 | } 60 | 61 | /** 62 | * You need to add a custom service for this method. a database request will only be captured, if it s part of an already 63 | * started transaction. 64 | * see Dynatrace help 65 | * for more information about a custom service. 66 | */ 67 | private void traceSqlRequest(String sql) { 68 | DatabaseInfo databaseInfo = oneAgentSdk.createDatabaseInfo("myCoolDatabase", "UnsupportedDatabaseVendor", ChannelType.TCP_IP, "theDbHost.localdomain:3434"); 69 | DatabaseRequestTracer databaseRequestTracer = oneAgentSdk.traceSqlDatabaseRequest(databaseInfo, sql); 70 | databaseRequestTracer.start(); 71 | try { 72 | executeRequest(sql); 73 | } catch(Exception e) { 74 | databaseRequestTracer.error(e); 75 | // handle or re-throw exception! 76 | } finally { 77 | databaseRequestTracer.end(); 78 | } 79 | } 80 | 81 | private void executeRequest(String sql) { 82 | // run the sql against the db ... 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.database; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/img/in-process-linking-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dynatrace/OneAgent-SDK-for-Java/9ac8eee0c0f319a303dd2bd08cbee17afa16c7c1/samples/img/in-process-linking-service.png -------------------------------------------------------------------------------- /samples/img/remotecall-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dynatrace/OneAgent-SDK-for-Java/9ac8eee0c0f319a303dd2bd08cbee17afa16c7c1/samples/img/remotecall-service.png -------------------------------------------------------------------------------- /samples/img/webrequest-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dynatrace/OneAgent-SDK-for-Java/9ac8eee0c0f319a303dd2bd08cbee17afa16c7c1/samples/img/webrequest-service.png -------------------------------------------------------------------------------- /samples/in-process-linking/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /samples/in-process-linking/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.inprocesslinking 8 | in-process-linking-sample 9 | 1.2.0 10 | jar 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.2.0 17 | compile 18 | 19 | 20 | 21 | https://github.com/Dynatrace/OneAgent-SDK-Java 22 | Dynatrace OneAgent SDK Java In-Process-Linking sample 23 | 24 | Dynatrace 25 | http://www.dynatrace.com 26 | 27 | 28 | 29 | 1.6 30 | 1.6 31 | UTF-8 32 | UTF-8 33 | 34 | 35 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.4 51 | 52 | 53 | 54 | true 55 | com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | exec-maven-plugin 63 | 1.6.0 64 | 65 | 66 | 67 | exec 68 | 69 | 70 | 71 | 72 | java 73 | 74 | ${agent.agentpath} 75 | -classpath 76 | 77 | com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/InProcessLinkingApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.inprocesslinking; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import java.io.IOException; 20 | import java.net.URL; 21 | import java.sql.SQLException; 22 | import java.util.concurrent.ArrayBlockingQueue; 23 | import java.util.concurrent.BlockingQueue; 24 | 25 | import javax.net.ssl.HttpsURLConnection; 26 | 27 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 28 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 29 | 30 | /** 31 | * ServerApp is listing for remote call requests from remote-call client. 32 | * 33 | * @author Alram.Lechner 34 | * 35 | */ 36 | public class InProcessLinkingApp { 37 | 38 | private final OneAgentSDK oneAgentSdk; 39 | 40 | private BlockingQueue blockingQueue = new ArrayBlockingQueue(5); 41 | 42 | private InProcessLinkingApp() { 43 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 44 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 45 | switch (oneAgentSdk.getCurrentState()) { 46 | case ACTIVE: 47 | System.out.println("SDK is active and capturing."); 48 | break; 49 | case PERMANENTLY_INACTIVE: 50 | System.err.println( 51 | "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 52 | break; 53 | case TEMPORARILY_INACTIVE: 54 | System.err.println( 55 | "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 56 | break; 57 | default: 58 | System.err.println("SDK is in unknown state."); 59 | break; 60 | } 61 | } 62 | 63 | public static void main(String args[]) { 64 | System.out.println("*************************************************************"); 65 | System.out.println("** Running in-process-linking sample **"); 66 | System.out.println("*************************************************************"); 67 | try { 68 | InProcessLinkingApp app = new InProcessLinkingApp(); 69 | // start worker thread, responsible for downloading files in background. thread waits on provided blocking queue. 70 | new UrlDownloaderThread(app.blockingQueue).start(); 71 | String latestVersion = app.startAsyncOperation(); 72 | System.err.println("Found latest OneAgent SDK for Java: " + latestVersion); 73 | System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); 74 | Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server 75 | app.end(); 76 | } catch (Exception e) { 77 | System.err.println("in-process-linking sample failed: " + e.getMessage()); 78 | e.printStackTrace(); 79 | System.exit(-1); 80 | } 81 | } 82 | 83 | /** 84 | * TODO: add custom service for this method 85 | * check for latest version and start downloading them asynchronously. 86 | */ 87 | private String startAsyncOperation() throws IOException, ClassNotFoundException, InterruptedException, SQLException { 88 | System.out.println("Executor started ..."); 89 | 90 | // do some sync work - eg. check for latest version: 91 | HttpsURLConnection url = (HttpsURLConnection) new URL("https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/latest").openConnection(); 92 | 93 | // we expect redirect to latest release url: 94 | url.setInstanceFollowRedirects(false); 95 | int responseStatus = url.getResponseCode(); 96 | if (responseStatus != 302) { 97 | System.out.println("no redirect retrieved!"); 98 | return null; 99 | } 100 | 101 | // e. g.: https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/tag/v1.0.3 102 | String location = url.getHeaderField("Location"); 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); 107 | 108 | // download the big release archive asynchronously ... 109 | UrlDownloadItem asyncWorkItem = new UrlDownloadItem( 110 | "https://github.com/Dynatrace/OneAgent-SDK-for-Java/archive/" + latestVersion + ".zip", 111 | oneAgentSdk.createInProcessLink()); 112 | blockingQueue.put(asyncWorkItem); 113 | 114 | return latestVersion; 115 | } 116 | 117 | private void end() { 118 | blockingQueue.offer(UrlDownloadItem.END); 119 | } 120 | 121 | } -------------------------------------------------------------------------------- /samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.inprocesslinking; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloadItem.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.inprocesslinking; 2 | 3 | import com.dynatrace.oneagent.sdk.api.InProcessLink; 4 | 5 | public class UrlDownloadItem { 6 | 7 | public static final UrlDownloadItem END = new UrlDownloadItem("END", null); 8 | 9 | // async operation - eg. URL to download 10 | private String url; 11 | 12 | // trace to link async execution with dynatrace 13 | private InProcessLink link; 14 | 15 | public UrlDownloadItem(String url, InProcessLink link) { 16 | this.url = url; 17 | this.link = link; 18 | } 19 | 20 | public String getUrl() { 21 | return url; 22 | } 23 | 24 | public InProcessLink getLink() { 25 | return link; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloaderThread.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.inprocesslinking; 2 | 3 | import java.io.InputStream; 4 | import java.net.URL; 5 | import java.util.concurrent.BlockingQueue; 6 | 7 | import javax.net.ssl.HttpsURLConnection; 8 | 9 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 10 | import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; 11 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 12 | 13 | public class UrlDownloaderThread extends Thread { 14 | 15 | private BlockingQueue queue; 16 | private OneAgentSDK oneAgentSdk; 17 | 18 | UrlDownloaderThread(BlockingQueue queue) { 19 | this.queue = queue; 20 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 21 | setDaemon(true); 22 | } 23 | 24 | @Override 25 | public void run() { 26 | try { 27 | while (true) { 28 | UrlDownloadItem item = queue.take(); 29 | if (item == UrlDownloadItem.END) { 30 | System.out.println("[DBWorker] retrieved end - exiting"); 31 | return; 32 | } 33 | System.out.println("[UrlDownloaderThread] retrieved item: " + item.getUrl()); 34 | 35 | // trace the execution of retrieved SQL: 36 | InProcessLinkTracer inProcessLinkTracer = oneAgentSdk.traceInProcessLink(item.getLink()); 37 | inProcessLinkTracer.start(); 38 | HttpsURLConnection connection = (HttpsURLConnection) new URL(item.getUrl()).openConnection(); 39 | try { 40 | System.out.println("[UrlDownloaderThread] HTTP status code: " + connection.getResponseCode()); 41 | InputStream inputStream = connection.getInputStream(); 42 | int bytesRetrieved = 0; 43 | try { 44 | byte buffer[] = new byte[1024*10]; 45 | while(true) { 46 | int read = inputStream.read(buffer); 47 | if (read < 0) { 48 | break; 49 | } 50 | bytesRetrieved += read; 51 | } 52 | System.out.println("[UrlDownloaderThread] retrieved " + bytesRetrieved + " bytes"); 53 | } finally { 54 | inputStream.close(); 55 | } 56 | } catch (Exception e) { 57 | inProcessLinkTracer.error(e); 58 | System.out.println("[UrlDownloaderThread] *** download operation failed: " + e.getClass().getName() + ": " + e.getMessage()); 59 | } finally { 60 | inProcessLinkTracer.end(); 61 | } 62 | } 63 | } catch (Exception e) { 64 | e.printStackTrace(); 65 | System.exit(-2); 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /samples/messaging/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.messaging 8 | messaging-sample 9 | 1.6.0 10 | jar 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.6.0 17 | compile 18 | 19 | 20 | 21 | https://github.com/Dynatrace/OneAgent-SDK-Java 22 | Dynatrace OneAgent SDK Java WebRequest sample 23 | 24 | Dynatrace 25 | http://www.dynatrace.com 26 | 27 | 28 | 29 | 1.6 30 | 1.6 31 | UTF-8 32 | UTF-8 33 | 34 | 35 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.4 51 | 52 | 53 | 54 | true 55 | com.dynatrace.oneagent.sdk.samples.messaging.MessagingApp 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | exec-maven-plugin 63 | 1.6.0 64 | 65 | 66 | 67 | exec 68 | 69 | 70 | 71 | 72 | java 73 | 74 | ${agent.agentpath} 75 | -classpath 76 | 77 | com.dynatrace.oneagent.sdk.samples.messaging.MessagingApp 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/FakedQueueManager.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.messaging; 2 | 3 | import java.util.concurrent.ArrayBlockingQueue; 4 | import java.util.concurrent.BlockingQueue; 5 | 6 | public class FakedQueueManager { 7 | 8 | private BlockingQueue queue = new ArrayBlockingQueue(10); 9 | private MessageListener messageListener; 10 | 11 | public FakedQueueManager() { 12 | } 13 | 14 | private class QueueManagerThread extends Thread { 15 | private QueueManagerThread() { 16 | super("QueueManager"); 17 | setDaemon(true); 18 | } 19 | 20 | @Override 21 | public void run() { 22 | while (true) { 23 | Message incomingMessage; 24 | try { 25 | incomingMessage = queue.take(); 26 | messageListener.onMessage(incomingMessage); 27 | } catch (InterruptedException e) { 28 | e.printStackTrace(); 29 | return; 30 | } 31 | } 32 | } 33 | } 34 | 35 | public void registerMessageListener(MessageListener listener) { 36 | this.messageListener = listener; 37 | new QueueManagerThread().start(); 38 | } 39 | 40 | 41 | public void send(String queueName, Message message) { 42 | try { 43 | queue.put(message); 44 | } catch (InterruptedException e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | public Message receive(String queueName) { 50 | try { 51 | return queue.take(); 52 | } catch (InterruptedException e) { 53 | e.printStackTrace(); 54 | return null; 55 | } 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/Message.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.messaging; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Message { 7 | 8 | private Map properties = new HashMap(); 9 | private String vendorMessageId = null; 10 | private String correlationId = null; 11 | 12 | public void addProperty(String propertyName, String propertyValue) { 13 | properties.put(propertyName, propertyValue); 14 | } 15 | 16 | public String getProperty(String propertyName) { 17 | return properties.get(propertyName); 18 | } 19 | 20 | public String getVendorMessageId() { 21 | return vendorMessageId; 22 | } 23 | 24 | public void setVendorMessageId(String vendorMessageId) { 25 | this.vendorMessageId = vendorMessageId; 26 | } 27 | 28 | public String getCorrelationId() { 29 | return correlationId; 30 | } 31 | 32 | public void setCorrelationId(String correlationId) { 33 | this.correlationId = correlationId; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessageListener.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.messaging; 2 | 3 | public interface MessageListener { 4 | 5 | public void onMessage(Message message); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessagingApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.messaging; 2 | 3 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 4 | import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; 5 | import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; 6 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 7 | import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; 8 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 9 | import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; 10 | import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; 11 | 12 | /** 13 | * Sample application shows how incoming/outgoing messages should be traced. 14 | * 15 | * @author Alram.Lechner 16 | * 17 | */ 18 | public class MessagingApp { 19 | 20 | private final OneAgentSDK oneAgentSdk; 21 | final FakedQueueManager queueManager; 22 | 23 | static MessagingApp instance; 24 | 25 | 26 | private MessagingApp() { 27 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 28 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 29 | switch (oneAgentSdk.getCurrentState()) { 30 | case ACTIVE: 31 | System.out.println("SDK is active and capturing."); 32 | break; 33 | case PERMANENTLY_INACTIVE: 34 | System.err.println( 35 | "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 36 | break; 37 | case TEMPORARILY_INACTIVE: 38 | System.err.println( 39 | "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 40 | break; 41 | default: 42 | System.err.println("SDK is in unknown state."); 43 | break; 44 | } 45 | queueManager = new FakedQueueManager(); 46 | instance = this; 47 | } 48 | 49 | public static void main(String args[]) { 50 | System.out.println("*************************************************************"); 51 | System.out.println("** Running messaging sample **"); 52 | System.out.println("*************************************************************"); 53 | try { 54 | MessagingApp app = new MessagingApp(); 55 | 56 | // sending and blocking receive ... 57 | app.sendMessage(); 58 | app.receiveMessage(); 59 | 60 | // or sending and event based receive: 61 | app.registerMessageListener(); 62 | app.sendMessage(); 63 | 64 | System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); 65 | Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server 66 | } catch (Exception e) { 67 | System.err.println("messaging sample failed: " + e.getMessage()); 68 | e.printStackTrace(); 69 | System.exit(-1); 70 | } 71 | } 72 | 73 | private void registerMessageListener() { 74 | queueManager.registerMessageListener(new MessageListener() { 75 | @Override 76 | public void onMessage(Message message) { 77 | MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); 78 | IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk.traceIncomingMessageProcess(messagingSystemInfo); 79 | // store incoming tag to tracer: 80 | incomingMessageProcessTracer.setDynatraceStringTag(message.getProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); 81 | incomingMessageProcessTracer.setVendorMessageId(message.getVendorMessageId()); 82 | incomingMessageProcessTracer.start(); 83 | try { 84 | // do something with the message ... 85 | System.out.println("Message received: " + message.toString()); 86 | } catch (Exception e) { 87 | incomingMessageProcessTracer.error(e); 88 | } finally { 89 | incomingMessageProcessTracer.end(); 90 | } 91 | } 92 | }); 93 | 94 | } 95 | 96 | private void sendMessage() { 97 | MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); 98 | OutgoingMessageTracer outgoingMessageTracer = oneAgentSdk.traceOutgoingMessage(messagingSystemInfo); 99 | 100 | outgoingMessageTracer.start(); 101 | try { 102 | Message messageToSend = new Message(); 103 | 104 | // add dynatrace tag as property to message ... 105 | messageToSend.addProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME, outgoingMessageTracer.getDynatraceStringTag()); 106 | 107 | queueManager.send("theQueue", messageToSend); 108 | 109 | // in case queueManager provided messageId: 110 | if (messageToSend.getVendorMessageId() != null) { 111 | outgoingMessageTracer.setVendorMessageId(messageToSend.getVendorMessageId()); 112 | } 113 | 114 | } catch (Exception e) { 115 | outgoingMessageTracer.error(e); 116 | } finally { 117 | outgoingMessageTracer.end(); 118 | } 119 | } 120 | 121 | /** shows how to trace a blocking receive of a message */ 122 | private void receiveMessage() { 123 | MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); 124 | IncomingMessageReceiveTracer incomingMessageReceiveTracer = oneAgentSdk.traceIncomingMessageReceive(messagingSystemInfo); 125 | incomingMessageReceiveTracer.start(); 126 | try { 127 | Message msg = queueManager.receive("theQeue"); 128 | if (msg == null) { 129 | return; // no message received 130 | } 131 | IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk.traceIncomingMessageProcess(messagingSystemInfo); 132 | // store incoming tag to tracer: 133 | incomingMessageProcessTracer.setDynatraceStringTag(msg.getProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); 134 | incomingMessageProcessTracer.setVendorMessageId(msg.getVendorMessageId()); 135 | incomingMessageProcessTracer.start(); 136 | try { 137 | // do something with the message ... 138 | System.out.println("Message received: " + msg.toString()); 139 | } catch (Exception e) { 140 | incomingMessageProcessTracer.error(e); 141 | } finally { 142 | incomingMessageProcessTracer.end(); 143 | } 144 | 145 | 146 | } catch (Exception e) { 147 | incomingMessageReceiveTracer.error(e); 148 | } finally { 149 | incomingMessageReceiveTracer.end(); 150 | } 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.messaging; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/remotecall/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.remoting 8 | parent 9 | 1.2.0 10 | pom 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.2.0 17 | compile 18 | 19 | 20 | 21 | 22 | 1.6 23 | 1.6 24 | UTF-8 25 | UTF-8 26 | 27 | 28 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /samples/remotecall/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.remoting 8 | remotecall-sample 9 | 1.2.0 10 | pom 11 | 12 | 13 | parent 14 | remotecall-client 15 | remotecall-server 16 | 17 | 18 | https://github.com/Dynatrace/OneAgent-SDK-Java 19 | Dynatrace OneAgent SDK Java RemoteCall sample 20 | 21 | Dynatrace 22 | http://www.dynatrace.com 23 | 24 | -------------------------------------------------------------------------------- /samples/remotecall/remotecall-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /samples/remotecall/remotecall-client/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | 8 | com.dynatrace.oneagent.sdk.samples.remoting 9 | parent 10 | 1.2.0 11 | ../parent/pom.xml 12 | 13 | 14 | remotecall-client 15 | jar 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-jar-plugin 22 | 2.4 23 | 24 | 25 | 26 | true 27 | com.dynatrace.oneagent.sdk.samples.remoting.ClientApp 28 | 29 | 30 | 31 | 32 | 33 | org.codehaus.mojo 34 | exec-maven-plugin 35 | 1.6.0 36 | 37 | 38 | 39 | exec 40 | 41 | 42 | 43 | 44 | java 45 | 46 | ${agent.agentpath} 47 | -classpath 48 | 49 | com.dynatrace.oneagent.sdk.samples.remoting.ClientApp 50 | ${sample.mode} 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ClientApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.remoting; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import java.io.IOException; 20 | import java.io.ObjectOutputStream; 21 | import java.net.Socket; 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 26 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 27 | import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; 28 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 29 | 30 | public class ClientApp { 31 | 32 | private final OneAgentSDK oneAgentSdk; 33 | private final Logger logger = Logger.getLogger("ClientApp"); 34 | 35 | private ClientApp() { 36 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 37 | switch (oneAgentSdk.getCurrentState()) { 38 | case ACTIVE: 39 | System.out.println("SDK is active and capturing."); 40 | break; 41 | case PERMANENTLY_INACTIVE: 42 | System.err.println( 43 | "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 44 | break; 45 | case TEMPORARILY_INACTIVE: 46 | System.err.println("SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 47 | break; 48 | default: 49 | System.err.println("SDK is in unknown state."); 50 | break; 51 | } 52 | } 53 | 54 | public static void main(String args[]) { 55 | System.out.println("*************************************************************"); 56 | System.out.println("** Running remote call client **"); 57 | System.out.println("*************************************************************"); 58 | int port = 33744; 59 | boolean endlessmode = false; 60 | for (String arg : args) { 61 | if (arg.startsWith("port=")) { 62 | port = Integer.parseInt(arg.substring("port=".length())); 63 | } else if (arg.startsWith("endlessmode")) { 64 | endlessmode = true; 65 | } else { 66 | System.err.println("unknown argument: " + arg); 67 | } 68 | } 69 | try { 70 | ClientApp clientApp = new ClientApp(); 71 | do { 72 | clientApp.run(port); 73 | Thread.sleep(10000); 74 | } while (endlessmode); 75 | } catch (Exception e) { 76 | System.err.println("remote call client failed: " + e.getMessage()); 77 | e.printStackTrace(); 78 | System.exit(1); 79 | } 80 | } 81 | 82 | private void run(int port) throws IOException, ClassNotFoundException { 83 | System.out.println("clients connecting to server on port " + port); 84 | Socket socket = new Socket((String) null, port); 85 | try { 86 | System.out.println("Connected to " + socket.getInetAddress().getHostName() + ":" + socket.getPort() 87 | + " connected"); 88 | ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); 89 | traceCallToServer(out, port); 90 | } finally { 91 | socket.close(); 92 | } 93 | } 94 | 95 | private void traceCallToServer(ObjectOutputStream out, int port) throws IOException { 96 | OutgoingRemoteCallTracer outgoingRemoteCall = oneAgentSdk.traceOutgoingRemoteCall("myMethod", "myService", "endpoint", ChannelType.TCP_IP, "localhost:" + port); 97 | outgoingRemoteCall.start(); 98 | try { 99 | String outgoingTag = outgoingRemoteCall.getDynatraceStringTag(); 100 | System.out.println("send tag to server: " + outgoingTag); 101 | invokeCallToServer(out, outgoingTag); 102 | } catch (Exception e) { 103 | outgoingRemoteCall.error(e); 104 | logger.log(Level.WARNING, "remotecall failed", e); 105 | } finally { 106 | outgoingRemoteCall.end(); 107 | } 108 | } 109 | 110 | private void invokeCallToServer(ObjectOutputStream out, String outgoingTag) throws IOException { 111 | // call the server and send the tag 112 | out.writeObject(outgoingTag); 113 | out.writeObject("the top secret message"); 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /samples/remotecall/remotecall-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /samples/remotecall/remotecall-server/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | 8 | com.dynatrace.oneagent.sdk.samples.remoting 9 | parent 10 | 1.2.0 11 | ../parent/pom.xml 12 | 13 | 14 | remotecall-server 15 | jar 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-jar-plugin 22 | 2.4 23 | 24 | 25 | 26 | true 27 | com.dynatrace.oneagent.sdk.samples.remoting.ServerApp 28 | 29 | 30 | 31 | 32 | 33 | org.codehaus.mojo 34 | exec-maven-plugin 35 | 1.6.0 36 | 37 | 38 | 39 | exec 40 | 41 | 42 | 43 | 44 | java 45 | 46 | ${agent.agentpath} 47 | -classpath 48 | 49 | com.dynatrace.oneagent.sdk.samples.remoting.ServerApp 50 | ${sample.mode} 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ServerApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.remoting; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import java.io.IOException; 20 | import java.io.ObjectInputStream; 21 | import java.net.ServerSocket; 22 | import java.net.Socket; 23 | import java.util.logging.Level; 24 | import java.util.logging.Logger; 25 | 26 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 27 | import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; 28 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 29 | 30 | /** 31 | * ServerApp is listing for remote call requests from remote-call client. 32 | * 33 | * @author Alram.Lechner 34 | * 35 | */ 36 | public class ServerApp { 37 | 38 | private final OneAgentSDK oneAgentSdk; 39 | private final Logger logger = Logger.getLogger("ServerApp"); 40 | 41 | private ServerApp() { 42 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 43 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 44 | switch (oneAgentSdk.getCurrentState()) { 45 | case ACTIVE: 46 | System.out.println("SDK is active and capturing."); 47 | break; 48 | case PERMANENTLY_INACTIVE: 49 | System.err.println( 50 | "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 51 | break; 52 | case TEMPORARILY_INACTIVE: 53 | System.err.println( 54 | "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 55 | break; 56 | default: 57 | System.err.println("SDK is in unknown state."); 58 | break; 59 | } 60 | } 61 | 62 | public static void main(String args[]) { 63 | System.out.println("*************************************************************"); 64 | System.out.println("** Running remote call server **"); 65 | System.out.println("*************************************************************"); 66 | int port = 33744; // default port 67 | boolean endlessmode = false; 68 | for (String arg : args) { 69 | if (arg.startsWith("port=")) { 70 | port = Integer.parseInt(arg.substring("port=".length())); 71 | } else if (arg.startsWith("endlessmode")) { 72 | endlessmode = true; 73 | } else { 74 | System.err.println("unknown argument: " + arg); 75 | } 76 | } 77 | try { 78 | new ServerApp().run(port, endlessmode); 79 | System.out.println( 80 | "remote call server stopped. sleeping a while, so OneAgent is able to send data to server ..."); 81 | Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server. 82 | } catch (Exception e) { 83 | System.err.println("remote call server failed: " + e.getMessage()); 84 | e.printStackTrace(); 85 | System.exit(-1); 86 | } 87 | } 88 | 89 | private void run(int port, boolean endlessmode) throws IOException, ClassNotFoundException { 90 | ServerSocket serverSocket = new ServerSocket(port); 91 | try { 92 | do { 93 | System.out.println("Waiting for clients on port " + serverSocket.getInetAddress().getHostName() + ":" 94 | + serverSocket.getLocalPort()); 95 | Socket client = serverSocket.accept(); 96 | try { 97 | System.out.println( 98 | "Client " + client.getInetAddress().getHostName() + ":" + client.getPort() + " connected"); 99 | ObjectInputStream in = new ObjectInputStream(client.getInputStream()); 100 | 101 | Object receivedTag = in.readObject(); 102 | String receivedMessage = (String) in.readObject(); 103 | System.out.println("received tag: " + receivedTag.toString()); 104 | traceCallFromClient(receivedTag, receivedMessage); 105 | } finally { 106 | client.close(); 107 | } 108 | } while (endlessmode); 109 | } finally { 110 | serverSocket.close(); 111 | } 112 | } 113 | 114 | private void traceCallFromClient(Object receivedTag, String receivedMessage) { 115 | IncomingRemoteCallTracer incomingRemoteCall = oneAgentSdk.traceIncomingRemoteCall("myMethod", "myService", 116 | "endpoint"); 117 | if (receivedTag instanceof String) { 118 | incomingRemoteCall.setDynatraceStringTag((String) receivedTag); 119 | } else if (receivedTag instanceof byte[]) { 120 | incomingRemoteCall.setDynatraceByteTag((byte[]) receivedTag); 121 | } else { 122 | System.err.println("invalid tag received: " + receivedTag.getClass().toString()); 123 | } 124 | 125 | incomingRemoteCall.start(); 126 | try { 127 | handleCallFromClient(receivedMessage); 128 | } catch (Exception e) { 129 | incomingRemoteCall.error(e); 130 | logger.log(Level.WARNING, "handling of remotecall failed", e); 131 | } finally { 132 | incomingRemoteCall.end(); 133 | } 134 | 135 | } 136 | 137 | private void handleCallFromClient(String receivedMessage) { 138 | // do whatever the server should do ... 139 | System.out.println("Received message from client: " + receivedMessage); 140 | } 141 | 142 | } -------------------------------------------------------------------------------- /samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.remoting; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/webrequest/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /samples/webrequest/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.dynatrace.oneagent.sdk.samples.webrequest 8 | webrequest-sample 9 | 1.4.0 10 | jar 11 | 12 | 13 | 14 | com.dynatrace.oneagent.sdk.java 15 | oneagent-sdk 16 | 1.4.0 17 | compile 18 | 19 | 20 | 21 | https://github.com/Dynatrace/OneAgent-SDK-Java 22 | Dynatrace OneAgent SDK Java WebRequest sample 23 | 24 | Dynatrace 25 | http://www.dynatrace.com 26 | 27 | 28 | 29 | 1.6 30 | 1.6 31 | UTF-8 32 | UTF-8 33 | 34 | 35 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.4 51 | 52 | 53 | 54 | true 55 | com.dynatrace.oneagent.sdk.samples.webrequest.WebRequestApp 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | exec-maven-plugin 63 | 1.6.0 64 | 65 | 66 | 67 | exec 68 | 69 | 70 | 71 | 72 | java 73 | 74 | ${agent.agentpath} 75 | -classpath 76 | 77 | com.dynatrace.oneagent.sdk.samples.webrequest.WebRequestApp 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedHttpClient.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.webrequest; 2 | 3 | import java.net.InetAddress; 4 | import java.net.MalformedURLException; 5 | import java.net.URL; 6 | import java.net.UnknownHostException; 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | import com.dynatrace.oneagent.sdk.samples.webrequest.FakedWebserver.HttpRequest; 13 | import com.dynatrace.oneagent.sdk.samples.webrequest.FakedWebserver.HttpResponse; 14 | 15 | public class FakedHttpClient implements HttpResponse { 16 | 17 | // REQUEST 18 | private URL url; 19 | private String method; 20 | private Map> requestHeaders = new HashMap>(); 21 | 22 | // RESPONSE 23 | private int statusCode; 24 | private Map> responseHeaders = new HashMap>(); 25 | 26 | public FakedHttpClient(String url, String method) throws MalformedURLException { 27 | this.method = method; 28 | this.url = new URL(url); 29 | } 30 | 31 | public void addRequestHeader(String requestHeader, String value) { 32 | List values = requestHeaders.get(requestHeader); 33 | if (values == null) { 34 | values = new ArrayList(); 35 | requestHeaders.put(requestHeader, values); 36 | } 37 | values.add(value); 38 | } 39 | 40 | public void addResponseHeader(String headerField, String value) { 41 | List values = responseHeaders.get(headerField); 42 | if (values == null) { 43 | values = new ArrayList(); 44 | responseHeaders.put(headerField, values); 45 | } 46 | values.add(value); 47 | } 48 | 49 | public void executeRequest() { 50 | // a normal HTTP client should open plain tcp socket and send the request now ... 51 | // ... but we are putting them into non-blocking queue: 52 | 53 | // build the request object, as a standard web container would provide it ... 54 | HttpRequest httpRequest; 55 | String clientIp; 56 | try { 57 | clientIp = InetAddress.getLocalHost().getHostAddress(); 58 | } catch (UnknownHostException e) { 59 | clientIp = "192.168.4.5"; // fake IP 60 | } 61 | httpRequest = new HttpRequest(url.getPath() + "?" + url.getQuery(), method, clientIp, requestHeaders); 62 | 63 | // ... and queue it for processing: 64 | WebRequestApp.instance.webServer.enqeueHttpRequestForProcessing(httpRequest, this); 65 | } 66 | 67 | public Map> getRequestHeaders() { 68 | return requestHeaders; 69 | } 70 | 71 | public Map> getResponseHeaders() { 72 | return responseHeaders; 73 | } 74 | 75 | public int getStatusCode() { 76 | return statusCode; 77 | } 78 | 79 | public void setResponseHeaders(Map> responseHeaders) { 80 | this.responseHeaders = responseHeaders; 81 | } 82 | 83 | @Override 84 | public void setStatusCode(int statusCode) { 85 | this.statusCode = statusCode; 86 | } 87 | 88 | @Override 89 | public void setContent(byte[] content) { 90 | // ignore the content we got from server 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.webrequest; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Map.Entry; 7 | import java.util.concurrent.ArrayBlockingQueue; 8 | import java.util.concurrent.BlockingQueue; 9 | 10 | import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; 11 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 12 | import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; 13 | 14 | public class FakedWebserver { 15 | 16 | private final OneAgentSDK oneAgentSDK; 17 | private final WebApplicationInfo webAppInfo; 18 | 19 | private final BlockingQueue requestQueue = new ArrayBlockingQueue(10); 20 | 21 | public FakedWebserver(OneAgentSDK oneAgentSDK) { 22 | this.oneAgentSDK = oneAgentSDK; 23 | webAppInfo = oneAgentSDK.createWebApplicationInfo("servername", "BillingService", "/billing"); 24 | new RequestProcessor().start(); 25 | } 26 | 27 | private class RequestProcessor extends Thread { 28 | private RequestProcessor() { 29 | super("Webserver-Worker"); 30 | setDaemon(true); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | while (true) { 36 | Pair incomingRequest; 37 | try { 38 | incomingRequest = requestQueue.take(); 39 | } catch (InterruptedException e) { 40 | e.printStackTrace(); 41 | return; 42 | } 43 | serve(incomingRequest.httpRequest, incomingRequest.httpResponse); 44 | } 45 | } 46 | } 47 | 48 | private class Pair { 49 | public HttpRequest httpRequest; 50 | public HttpResponse httpResponse; 51 | 52 | public Pair(HttpRequest httpRequest, HttpResponse httpResponse) { 53 | this.httpRequest = httpRequest; 54 | this.httpResponse = httpResponse; 55 | } 56 | } 57 | 58 | public void enqeueHttpRequestForProcessing(HttpRequest httpRequest, HttpResponse httpResponse) { 59 | try { 60 | requestQueue.put(new Pair(httpRequest,httpResponse)); 61 | } catch (InterruptedException e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | public static interface HttpResponse { 67 | 68 | public void setStatusCode(int statusCode); 69 | 70 | public void addResponseHeader(String headerField, String value); 71 | 72 | public void setContent(byte[] content); 73 | } 74 | 75 | public static class HttpRequest { 76 | private final String remoteIpAddress; 77 | private final String uri; 78 | private final String method; 79 | private final Map> requestHeaders; 80 | 81 | public HttpRequest(String uri, String method, String remoteIpAddress, Map> requestHeaders) { 82 | this.uri = uri; 83 | this.method = method; 84 | this.remoteIpAddress = remoteIpAddress; 85 | this.requestHeaders = requestHeaders; 86 | } 87 | 88 | public String getUri() { 89 | return uri; 90 | } 91 | 92 | public String getMethod() { 93 | return method; 94 | } 95 | 96 | public Map> getHeaders() { 97 | return requestHeaders; 98 | } 99 | 100 | public Map> getParameters() { 101 | return new HashMap>(); 102 | } 103 | 104 | public String getRemoteIpAddress() { 105 | return remoteIpAddress; 106 | } 107 | } 108 | 109 | /** faked http request handling. shows usage of OneAgent SDK's incoming webrequest API */ 110 | private void serve(HttpRequest request, HttpResponse response) { 111 | String url = request.getUri(); 112 | System.out.println("[Server] serve " + url); 113 | IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK.traceIncomingWebRequest(webAppInfo, url, request.getMethod()); 114 | 115 | // add request header, parameter and remote address before start: 116 | for (Entry> headerField : request.getHeaders().entrySet()) { 117 | for (String value : headerField.getValue()) { 118 | incomingWebrequestTracer.addRequestHeader(headerField.getKey(), value); 119 | } 120 | } 121 | for (Entry> parameter : request.getParameters().entrySet()) { 122 | for (String value : parameter.getValue()) { 123 | incomingWebrequestTracer.addParameter(parameter.getKey(), value); 124 | } 125 | } 126 | incomingWebrequestTracer.setRemoteAddress(request.getRemoteIpAddress()); 127 | 128 | incomingWebrequestTracer.start(); 129 | try { 130 | response.setContent("Hello world!".getBytes()); 131 | response.setStatusCode(200); 132 | incomingWebrequestTracer.setStatusCode(200); 133 | } catch (Exception e) { 134 | // we assume, container is sending http 500 in case of exception is thrown while serving an request: 135 | incomingWebrequestTracer.error(e); 136 | e.printStackTrace(); 137 | throw new RuntimeException(e); 138 | } finally { 139 | incomingWebrequestTracer.end(); 140 | } 141 | } 142 | 143 | 144 | } 145 | -------------------------------------------------------------------------------- /samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/StdErrLoggingCallback.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.webrequest; 2 | 3 | /* 4 | * Copyright 2018 Dynatrace LLC 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 20 | 21 | /** 22 | * Implementation of OneAgent Logging Callback. Just printing output messages to 23 | * std err. 24 | */ 25 | public class StdErrLoggingCallback implements LoggingCallback { 26 | 27 | @Override 28 | public void error(String message) { 29 | System.err.println("[OneAgent SDK ERROR]: " + message); 30 | } 31 | 32 | @Override 33 | public void warn(String message) { 34 | System.err.println("[OneAgent SDK WARNING]: " + message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/WebRequestApp.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.samples.webrequest; 2 | 3 | import java.util.List; 4 | import java.util.Map.Entry; 5 | 6 | import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; 7 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 8 | import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; 9 | 10 | /** 11 | * Sample application shows how incoming webrequests should be traced. 12 | * 13 | * @author Alram.Lechner 14 | * 15 | */ 16 | public class WebRequestApp { 17 | 18 | private final OneAgentSDK oneAgentSdk; 19 | final FakedWebserver webServer; 20 | 21 | static WebRequestApp instance; 22 | 23 | 24 | private WebRequestApp() { 25 | oneAgentSdk = OneAgentSDKFactory.createInstance(); 26 | oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); 27 | switch (oneAgentSdk.getCurrentState()) { 28 | case ACTIVE: 29 | System.out.println("SDK is active and capturing."); 30 | break; 31 | case PERMANENTLY_INACTIVE: 32 | System.err.println( 33 | "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); 34 | break; 35 | case TEMPORARILY_INACTIVE: 36 | System.err.println( 37 | "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); 38 | break; 39 | default: 40 | System.err.println("SDK is in unknown state."); 41 | break; 42 | } 43 | webServer = new FakedWebserver(oneAgentSdk); 44 | instance = this; 45 | } 46 | 47 | public static void main(String args[]) { 48 | System.out.println("*************************************************************"); 49 | System.out.println("** Running webrequest sample **"); 50 | System.out.println("*************************************************************"); 51 | try { 52 | WebRequestApp app = new WebRequestApp(); 53 | app.runFakedWebrequest(); 54 | // app.runIncomingWebrequest(); 55 | System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); 56 | Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server 57 | } catch (Exception e) { 58 | System.err.println("webrequest sample failed: " + e.getMessage()); 59 | e.printStackTrace(); 60 | System.exit(-1); 61 | } 62 | } 63 | 64 | private void runFakedWebrequest() { 65 | String url = "http://localhost:80/billing/my/path?param1=value1¶m2=value2"; 66 | System.out.println("[Client] request " + url); 67 | OutgoingWebRequestTracer outgoingWebRequestTracer = oneAgentSdk.traceOutgoingWebRequest(url, "GET"); 68 | outgoingWebRequestTracer.start(); 69 | try { 70 | FakedHttpClient httpClient = new FakedHttpClient(url, "GET"); 71 | 72 | // add link to headers ... 73 | httpClient.addRequestHeader(OneAgentSDK.DYNATRACE_HTTP_HEADERNAME, outgoingWebRequestTracer.getDynatraceStringTag()); 74 | 75 | httpClient.executeRequest(); 76 | 77 | // add response headers to tracer: 78 | for (Entry> entry : httpClient.getResponseHeaders().entrySet()) { 79 | for (String value : entry.getValue()) { 80 | outgoingWebRequestTracer.addResponseHeader(entry.getKey(), value); 81 | } 82 | } 83 | 84 | outgoingWebRequestTracer.setStatusCode(httpClient.getStatusCode()); 85 | } catch (Exception e) { 86 | outgoingWebRequestTracer.error(e); 87 | } finally { 88 | outgoingWebRequestTracer.end(); 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; 20 | 21 | /** 22 | * Entry point for customer application. 23 | */ 24 | public class OneAgentSDKFactory { 25 | 26 | /** 27 | * Provides a {@link OneAgentSDK} instance, that has to be used to create 28 | * transactions. It is safe to use returned {@link OneAgentSDK} instance in 29 | * multiple threads. Every application should only create one single SDK 30 | * instance during its lifetime. 31 | * 32 | * @return never null. if no OneAgent present, NOOP implementation gets 33 | * returned. 34 | */ 35 | public static OneAgentSDK createInstance() { 36 | return OneAgentSDKFactoryImpl.createInstance(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for tracing custom services. 20 | * https://github.com/Dynatrace/OneAgent-SDK#customservice 21 | * 22 | * @since 1.8.0 23 | */ 24 | public interface CustomServiceTracer extends Tracer { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for outgoing database tracer. 20 | * https://github.com/Dynatrace/OneAgent-SDK#database 21 | * 22 | * @since 1.7.0 23 | */ 24 | public interface DatabaseRequestTracer extends Tracer { 25 | 26 | /** 27 | * Adds optional information about retrieved rows of the traced database request. 28 | * 29 | * @param returnedRowCount number of rows returned by this traced database request. Only positive values are allowed. 30 | * @since 1.7.0 31 | */ 32 | public void setReturnedRowCount(int returnedRowCount); 33 | 34 | /** 35 | * Adds optional information about round-trip count to database server. 36 | * 37 | * @param roundTripCount count of round-trips that took place. Only positive values are allowed. 38 | * @since 1.7.0 39 | */ 40 | public void setRoundTripCount(int roundTripCount); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Represents link used for in-process-tagging. See 20 | * {@link OneAgentSDK#createInProcessLink()} and 21 | * {@link OneAgentSDK#traceInProcessLink(InProcessLink)} for more details. 22 | * 23 | * @since 1.1 24 | */ 25 | public interface InProcessLink { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Tracer used to trace in-process-linking. See 20 | * {@link OneAgentSDK#createInProcessLink()} and 21 | * {@link OneAgentSDK#traceInProcessLink(InProcessLink)} for more details. 22 | * 23 | * @since 1.1 24 | */ 25 | public interface InProcessLinkTracer extends Tracer { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for processing message tracer. 20 | * https://github.com/Dynatrace/OneAgent-SDK#messaging 21 | * 22 | * @since 1.5 23 | */ 24 | public interface IncomingMessageProcessTracer extends IncomingTaggable, Tracer { 25 | 26 | /** 27 | * Adds optional information about a traced message: message id provided by messaging system. 28 | * 29 | * @param vendorMessageId the messageId 30 | */ 31 | public void setVendorMessageId(String vendorMessageId); 32 | 33 | /** 34 | * Adds optional information about a traced message: correlation id used by messaging system. 35 | * 36 | * @param correlationId correlationId 37 | */ 38 | public void setCorrelationId(String correlationId); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for receiving message tracer. 20 | * https://github.com/Dynatrace/OneAgent-SDK#messaging 21 | * 22 | * @since 1.5 23 | */ 24 | public interface IncomingMessageReceiveTracer extends Tracer { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Represents the server side of a remote call. This Interface extends 20 | * {@link Tracer} - it is important to respect the mentioned requirements when 21 | * working with {@link IncomingRemoteCallTracer}. 22 | * 23 | */ 24 | 25 | public interface IncomingRemoteCallTracer extends Tracer, IncomingTaggable { 26 | 27 | /** 28 | * Sets the name of the used remoting protocol. 29 | * 30 | * @param protocolName 31 | * protocol name 32 | * @since 1.0 33 | */ 34 | void setProtocolName(String protocolName); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/IncomingTaggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Common interface for server-tagging-related methods. Not to be directly used 20 | * by SDK user. 21 | */ 22 | public interface IncomingTaggable { 23 | 24 | /** 25 | * Consumes a tag to continue a pure path. Must be set before a node is being 26 | * started.
27 | * See {@link OutgoingTaggable} to determine how to create a tag. 28 | * 29 | * @param tag 30 | * the tag in String representation - must not be null. 31 | * @since 1.0 32 | */ 33 | void setDynatraceStringTag(String tag); 34 | 35 | /** 36 | * Same as {@link #setDynatraceStringTag(String)} but consumes binary 37 | * representation of tag. 38 | * 39 | * @param tag 40 | * the tag in binary representation - must not be null. 41 | * @since 1.0 42 | */ 43 | void setDynatraceByteTag(byte[] tag); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for incoming webrequest tracer. https://github.com/Dynatrace/OneAgent-SDK#webrequests 21 | * 22 | * @since 1.3 23 | */ 24 | public interface IncomingWebRequestTracer extends Tracer, IncomingTaggable { 25 | 26 | /** 27 | * Validates and sets the remote IP address of the incoming web request. This 28 | * information is very useful to gain information about Load balancers, Proxies 29 | * and ultimately the end user that is sending the request. 30 | * 31 | * @param remoteAddress 32 | * remote IP address 33 | */ 34 | void setRemoteAddress(String remoteAddress); 35 | 36 | /** 37 | * All HTTP request headers should be provided to this method. Selective 38 | * capturing will be done based on sensor configuration. 39 | * 40 | * @param name 41 | * HTTP request header field name 42 | * @param value 43 | * HTTP request header field value 44 | */ 45 | void addRequestHeader(String name, String value); 46 | 47 | /** 48 | * All HTTP parameters should be provided to this method. Selective capturing 49 | * will be done based on sensor configuration. 50 | * 51 | * @param name 52 | * HTTP parameter name 53 | * @param value 54 | * HTTP parameter value 55 | */ 56 | void addParameter(String name, String value); 57 | 58 | /** 59 | * All HTTP response headers should be provided to this method. Selective 60 | * capturing will be done based on sensor configuration. 61 | * 62 | * @param name 63 | * HTTP response header field name 64 | * @param value 65 | * HTTP response header field value 66 | */ 67 | void addResponseHeader(String name, String value); 68 | 69 | /** 70 | * Sets the HTTP response status code. 71 | * 72 | * @param statusCode 73 | * HTTP status code returned to client 74 | */ 75 | void setStatusCode(int statusCode); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/LoggingCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * LoggingCallback gets called only inside a OneAgentSDK API call when an 20 | * error/warning has occurred.
21 | * Never call any SDK API inside one of these callback methods. 22 | */ 23 | public interface LoggingCallback { 24 | 25 | /** 26 | * Just a warning. Something is missing, but OneAgent is working normal. 27 | * 28 | * @param message 29 | * message text. never null. 30 | * @since 1.0 31 | */ 32 | void warn(String message); 33 | 34 | /** 35 | * Something that should be done can't be done. (e. g. PurePath could not be 36 | * started) 37 | * 38 | * @param message 39 | * message text. never null. 40 | * @since 1.0 41 | */ 42 | void error(String message); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Interface for outgoing message tracer. 20 | * https://github.com/Dynatrace/OneAgent-SDK#messaging 21 | * 22 | * @since 1.5 23 | */ 24 | public interface OutgoingMessageTracer extends Tracer, OutgoingTaggable { 25 | 26 | /** 27 | * Adds optional information about a traced message: message id provided by messaging system. 28 | * 29 | * @param vendorMessageId the messageId 30 | */ 31 | public void setVendorMessageId(String vendorMessageId); 32 | 33 | /** 34 | * Adds optional information about a traced message: correlation id used by messaging system. 35 | * 36 | * @param correlationId correlationId 37 | */ 38 | public void setCorrelationId(String correlationId); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Represents the client side of a remote call. 20 | * 21 | * This Interface extends {@link Tracer} - it is important to respect the 22 | * mentioned requirements when working with {@link OutgoingRemoteCallTracer}. 23 | * 24 | */ 25 | public interface OutgoingRemoteCallTracer extends Tracer, OutgoingTaggable { 26 | 27 | /** 28 | * Sets the name of the used remoting protocol. Setting the protocol name is 29 | * optional. 30 | * 31 | * @param protocolName 32 | * protocol name. null value is ignored. 33 | * @since 1.0 34 | */ 35 | void setProtocolName(String protocolName); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Common interface for client-tagging-related methods. Not to be directly used 20 | * by SDK user. 21 | */ 22 | public interface OutgoingTaggable { 23 | 24 | /** 25 | * Creates a Dynatrace tag and returns the String representation of it. This tag 26 | * has to be transported with the remoting protocol to the destination.
27 | * See {@link IncomingTaggable} how to continue a path with provided tag on the 28 | * server side. 29 | * 30 | * @return the tag - never null. 31 | * @since 1.0 32 | */ 33 | String getDynatraceStringTag(); 34 | 35 | /** 36 | * Same as {@link #getDynatraceStringTag()}, but returning the tag as binary 37 | * representation. 38 | * 39 | * @return the tag - never null. 40 | * @since 1.0 41 | */ 42 | byte[] getDynatraceByteTag(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Represents client side of an outgoing webrequest. 20 | * 21 | * @since 1.4 22 | * 23 | */ 24 | public interface OutgoingWebRequestTracer extends Tracer, OutgoingTaggable { 25 | 26 | /** 27 | * All HTTP request headers should be provided to this method. Selective 28 | * capturing will be done based on sensor configuration. 29 | * 30 | * @param name 31 | * HTTP request header field name 32 | * @param value 33 | * HTTP request header field value 34 | */ 35 | void addRequestHeader(String name, String value); 36 | 37 | /** 38 | * All HTTP response headers returned by the server should be provided to this 39 | * method. Selective capturing will be done based on sensor configuration. 40 | * 41 | * @param name 42 | * HTTP response header field name 43 | * @param value 44 | * HTTP response header field value 45 | */ 46 | void addResponseHeader(String name, String value); 47 | 48 | /** 49 | * Sets the HTTP response status code. 50 | * 51 | * @param statusCode 52 | * HTTP status code retrieved from server 53 | */ 54 | void setStatusCode(int statusCode); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/Tracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api; 17 | 18 | /** 19 | * Common interface for timing-related methods. Not to be directly used by SDK 20 | * user. 21 | */ 22 | public interface Tracer { 23 | 24 | /** 25 | * starts timing of a node. Every node that has been started, must be ended with 26 | * {@link #end()} method. Consider using the following pattern: 27 | * 28 | *

29 | 	 * {@code
30 | 	 *   tracer.start();
31 | 	 *   try {
32 | 	 *     // do your work
33 | 	 *   } catch (Exception e) {
34 | 	 *     tracer.error(e);
35 | 	 *   } finally {
36 | 	 *     tracer.end();
37 | 	 *   }
38 | 	 * }
39 | 	 * 
40 | * 41 | * {@link #start()}, {@link #end()}, {@link #error(String)}, 42 | * {@link #error(Throwable)} are not thread-safe. They must be called from the 43 | * same thread where {@link #start()} has been invoked. 44 | * 45 | * @since 1.0 46 | */ 47 | void start(); 48 | 49 | /** 50 | * Ends timing of a node. Typically this method is called via finally block. 51 | *
52 | * {@link #start()}, {@link #end()}, {@link #error(String)}, 53 | * {@link #error(Throwable)} are not thread-safe. They must be called from the 54 | * same thread where {@link #start()} has been invoked. 55 | * 56 | * @since 1.0 57 | */ 58 | void end(); 59 | 60 | /** 61 | * Marks the node as 'exited by exception'. An additional error message can be 62 | * provided as String.
63 | * {@link #start()}, {@link #end()}, {@link #error(String)}, 64 | * {@link #error(Throwable)} are not thread-safe. They must be called from the 65 | * same thread where {@link #start()} has been invoked. 66 | * 67 | * @param message 68 | * error message with details about occurred error (eg. return code). 69 | * must not be null. 70 | * @since 1.0 71 | */ 72 | void error(String message); 73 | 74 | /** 75 | * Marks the node as 'exited by exception'.Additional information can be 76 | * provided as Throwable.
77 | * {@link #start()}, {@link #end()}, {@link #error(String)}, 78 | * {@link #error(Throwable)} are not thread-safe. They must be called from the 79 | * same thread where {@link #start()} has been invoked. 80 | * 81 | * @param throwable 82 | * exception, that occurred. must not null. 83 | * @since 1.0 84 | */ 85 | void error(Throwable throwable); 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/enums/ChannelType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.enums; 17 | 18 | /** 19 | * Defines the type of communication channel being used. 20 | * 21 | * @author Alram.Lechner 22 | * 23 | */ 24 | public enum ChannelType { 25 | 26 | OTHER(0), TCP_IP(1), UNIX_DOMAIN_SOCKET(2), NAMED_PIPE(3), IN_PROCESS(4); 27 | 28 | /** constant is being used in API call to OneAgent. don't change it! */ 29 | private final int sdkConstant; 30 | 31 | private ChannelType(int sdkConstant) { 32 | this.sdkConstant = sdkConstant; 33 | } 34 | 35 | public int getSDKConstant() { 36 | return sdkConstant; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.enums; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Enumerates all well-known database vendors. See {@link OneAgentSDK#createDatabaseInfo(String, String, ChannelType, String)}. 22 | * Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. 23 | * @since 1.7.0 24 | */ 25 | public enum DatabaseVendor { 26 | 27 | APACHE_HIVE("ApacheHive"), 28 | CLOUDSCAPE("Cloudscape"), 29 | HSQLDB("HSQLDB"), 30 | PROGRESS("Progress"), 31 | MAXDB("MaxDB"), 32 | HANADB("HanaDB"), 33 | INGRES("Ingres"), 34 | FIRST_SQL("FirstSQL"), 35 | ENTERPRISE_DB("EnterpriseDB"), 36 | CACHE("Cache"), 37 | ADABAS("Adabas"), 38 | FIREBIRD("Firebird"), 39 | DB2("DB2"), 40 | DERBY_CLIENT("Derby Client"), 41 | DERBY_EMBEDDED("Derby Embedded"), 42 | FILEMAKER("Filemaker"), 43 | INFORMIX("Informix"), 44 | INSTANT_DB("InstantDb"), 45 | INTERBASE("Interbase"), 46 | MYSQL("MySQL"), 47 | MARIADB("MariaDB"), 48 | NETEZZA("Netezza"), 49 | ORACLE("Oracle"), 50 | PERVASIVE("Pervasive"), 51 | POINTBASE("Pointbase"), 52 | POSTGRESQL("PostgreSQL"), 53 | SQLSERVER("SQL Server"), 54 | SQLITE("sqlite"), 55 | SYBASE("Sybase"), 56 | TERADATA("Teradata"), 57 | VERTICA("Vertica"), 58 | CASSANDRA("Cassandra"), 59 | H2("H2"), 60 | COLDFUSION_IMQ("ColdFusion IMQ"), 61 | REDSHIFT("Amazon Redshift"), 62 | COUCHBASE("Couchbase"); 63 | 64 | private final String vendorName; 65 | 66 | private DatabaseVendor(String vendorName) { 67 | this.vendorName = vendorName; 68 | } 69 | 70 | public String getVendorName() { 71 | return vendorName; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return vendorName; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.enums; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Enumerates all well-known messaging destination types. See 22 | * {@link OneAgentSDK#createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String)} 23 | * 24 | * @since 1.5 25 | */ 26 | public enum MessageDestinationType { 27 | 28 | QUEUE("Queue"), 29 | TOPIC("Topic"); 30 | 31 | private final String name; 32 | 33 | private MessageDestinationType(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.enums; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Enumerates all well-known messaging systems. See {@link OneAgentSDK#createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String)}. 22 | * Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. 23 | * 24 | * @since 1.5 25 | */ 26 | public enum MessageSystemVendor { 27 | 28 | HORNETQ("HornetQ"), 29 | ACTIVE_MQ("ActiveMQ"), 30 | RABBIT_MQ("RabbitMQ"), 31 | ARTEMIS("Artemis"), 32 | WEBSPHERE("WebSphere"), 33 | MQSERIES_JMS("MQSeries JMS"), 34 | MQSERIES("MQSeries"), 35 | TIBCO("Tibco"); 36 | 37 | private final String vendorName; 38 | 39 | private MessageSystemVendor(String vendorName) { 40 | this.vendorName = vendorName; 41 | } 42 | 43 | public String getVendorName() { 44 | return vendorName; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return vendorName; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/enums/SDKState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.enums; 17 | 18 | /** 19 | * Defines the possible states of the SDK. 20 | */ 21 | public enum SDKState { 22 | 23 | /** 24 | * SDK is connected to OneAgent and capturing data. 25 | * 26 | * @since 1.0 27 | */ 28 | ACTIVE, 29 | 30 | /** 31 | * SDK is connected to OneAgent, but capturing is disabled.It is good practice 32 | * to skip creating SDK transactions to save resources. The SDK state should be 33 | * checked regularly as it may change at every point in time. 34 | * 35 | * @since 1.0 36 | */ 37 | TEMPORARILY_INACTIVE, 38 | 39 | /** 40 | * SDK isn't connected to OneAgent, so it will never capture data. This SDK 41 | * state will never change during the lifetime of a JVM. It is good practice to 42 | * never call any SDK API to save resources. 43 | * 44 | * @since 1.0 45 | */ 46 | PERMANENTLY_INACTIVE; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.infos; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Type returned by {@link OneAgentSDK#createDatabaseInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)} 22 | * @since 1.7.0 23 | */ 24 | public interface DatabaseInfo { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.infos; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Type returned by {@link OneAgentSDK#createMessagingSystemInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)} 22 | * 23 | * @since 1.5 24 | */ 25 | public interface MessagingSystemInfo { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.infos; 17 | 18 | /** 19 | * Provides information about a PurePath node using the TraceContext (Trace-Id, Span-Id) model as defined in 20 | * These are a few common reasons for why you may be unable to get a valid trace context: 48 | *

49 | * */ 50 | boolean isValid(); 51 | 52 | /** The W3C trace ID hex string (never empty or null, but might be all-zero if {@link #isValid()}) is false) */ 53 | String getTraceId(); 54 | 55 | /** The W3C span ID hex string (never empty or null, but might be all-zero if {@link #isValid()}) is false) */ 56 | String getSpanId(); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.api.infos; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | 20 | /** 21 | * Type returned by 22 | * {@link OneAgentSDK#createWebApplicationInfo(String, String, String)} 23 | * 24 | * @since 1.3 25 | * 26 | */ 27 | public interface WebApplicationInfo { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 19 | import com.dynatrace.oneagent.sdk.impl.noop.OneAgentSDKNoop; 20 | import com.dynatrace.oneagent.sdk.impl.proxy.OneAgentSDKProxy; 21 | import com.dynatrace.oneagent.sdk.impl.proxy.SDK2AgentInternalApiProxy; 22 | 23 | /** 24 | * Entry point for customer application. 25 | */ 26 | public class OneAgentSDKFactoryImpl { 27 | 28 | /* 29 | * increase version with every change. in case of non breaking change (to 30 | * OneAgent), increase oneSdkFix only. 31 | */ 32 | static final int oneSdkMajor = 1; 33 | static final int oneSdkMinor = 9; 34 | static final int oneSdkFix = 0; 35 | 36 | public static final boolean debugOneAgentSdkStub = Boolean.parseBoolean(System.getProperty("com.dynatrace.oneagent.sdk.debug", "false")); 37 | 38 | private static OneAgentSDK createOneSDK() { 39 | Object agentApiImpl = SDKInstanceProvider.create(oneSdkMajor, oneSdkMinor, oneSdkFix); 40 | if (agentApiImpl == null) { 41 | // OneAgent not present or not compatible 42 | if (debugOneAgentSdkStub) { 43 | logDebug("- no OneAgent present or OneAgent declined to work with OneAgentSdk version " + oneSdkMajor 44 | + "." + oneSdkMinor + "." + oneSdkFix); 45 | } 46 | return new OneAgentSDKNoop(); 47 | } 48 | try { 49 | SDK2AgentInternalApiProxy agentApi = new SDK2AgentInternalApiProxy(agentApiImpl); 50 | Object agentSdkImpl = agentApi.oneAgentSDKFactory_createSdk(); 51 | if (agentSdkImpl != null) { 52 | return new OneAgentSDKProxy(agentApi, agentSdkImpl); 53 | } 54 | if (debugOneAgentSdkStub) { 55 | logDebug("- OneAgent failed to provide sdk object."); 56 | } 57 | return new OneAgentSDKNoop(); 58 | } catch (Throwable e) { 59 | if (debugOneAgentSdkStub) { 60 | logDebug("- failed to contact OneAgent: " + e.getClass().getName() + ": " + e.getMessage()); 61 | } 62 | return new OneAgentSDKNoop(); 63 | } 64 | } 65 | 66 | public static OneAgentSDK createInstance() { 67 | return createOneSDK(); 68 | } 69 | 70 | public static void logDebug(String msg) { 71 | System.out.println("[onesdk ] " + msg); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl; 17 | 18 | /** class gets replaced by OneAgent, if OneAgent is loaded. */ 19 | class SDKInstanceProvider { 20 | 21 | /** 22 | * @return SDK Object provided by OneAgent. null if no OneAgent is loaded or 23 | * declines to work with current SDK. 24 | */ 25 | static Object create(int onesdkmajor, int onesdkminor, int onesdkfix) { 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/CustomServiceTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; 19 | 20 | public final class CustomServiceTracerNoop extends NodeNoop implements CustomServiceTracer { 21 | 22 | public static final CustomServiceTracer INSTANCE = new CustomServiceTracerNoop(); 23 | 24 | private CustomServiceTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void start() { 29 | } 30 | 31 | @Override 32 | public void end() { 33 | } 34 | 35 | @Override 36 | public void error(String message) { 37 | } 38 | 39 | @Override 40 | public void error(Throwable throwable) { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseInfoNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; 19 | 20 | public final class DatabaseInfoNoop implements DatabaseInfo { 21 | public static final DatabaseInfo INSTANCE = new DatabaseInfoNoop(); 22 | 23 | private DatabaseInfoNoop() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseRequestTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; 19 | 20 | public final class DatabaseRequestTracerNoop extends NodeNoop implements DatabaseRequestTracer { 21 | 22 | public static final DatabaseRequestTracerNoop INSTANCE = new DatabaseRequestTracerNoop(); 23 | 24 | private DatabaseRequestTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void start() { 29 | } 30 | 31 | @Override 32 | public void end() { 33 | } 34 | 35 | @Override 36 | public void error(String message) { 37 | } 38 | 39 | @Override 40 | public void error(Throwable throwable) { 41 | } 42 | 43 | @Override 44 | public void setReturnedRowCount(int rowsReturned) { 45 | } 46 | 47 | @Override 48 | public void setRoundTripCount(int roundTripCount) { 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.InProcessLink; 19 | 20 | public final class InProcessLinkNoop implements InProcessLink { 21 | 22 | public final static InProcessLink INSTANCE = new InProcessLinkNoop(); 23 | 24 | private InProcessLinkNoop() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; 19 | 20 | public final class InProcessLinkTracerNoop extends NodeNoop implements InProcessLinkTracer { 21 | 22 | public final static InProcessLinkTracer INSTANCE = new InProcessLinkTracerNoop(); 23 | 24 | private InProcessLinkTracerNoop() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageProcessTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; 19 | 20 | public final class IncomingMessageProcessTracerNoop extends NodeNoop implements IncomingMessageProcessTracer { 21 | 22 | public static final IncomingMessageProcessTracerNoop INSTANCE = new IncomingMessageProcessTracerNoop(); 23 | 24 | private IncomingMessageProcessTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void setDynatraceStringTag(String tag) { 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | } 34 | 35 | @Override 36 | public void setVendorMessageId(String vendorMessageId) { 37 | } 38 | 39 | @Override 40 | public void setCorrelationId(String correlationId) { 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageReceiveTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; 19 | 20 | public final class IncomingMessageReceiveTracerNoop extends NodeNoop implements IncomingMessageReceiveTracer { 21 | 22 | public static final IncomingMessageReceiveTracerNoop INSTANCE = new IncomingMessageReceiveTracerNoop(); 23 | 24 | private IncomingMessageReceiveTracerNoop() { 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingWebRequestTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; 19 | 20 | public final class IncomingWebRequestTracerNoop extends NodeNoop implements IncomingWebRequestTracer { 21 | 22 | public static final IncomingWebRequestTracer INSTANCE = new IncomingWebRequestTracerNoop(); 23 | 24 | private IncomingWebRequestTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void setDynatraceStringTag(String tag) { 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | } 34 | 35 | @Override 36 | public void setRemoteAddress(String remoteAddress) { 37 | 38 | } 39 | 40 | @Override 41 | public void addRequestHeader(String name, String value) { 42 | 43 | } 44 | 45 | @Override 46 | public void addParameter(String name, String value) { 47 | 48 | } 49 | 50 | @Override 51 | public void addResponseHeader(String name, String value) { 52 | 53 | } 54 | 55 | @Override 56 | public void setStatusCode(int statusCode) { 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/MessagingSystemInfoNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; 19 | 20 | public final class MessagingSystemInfoNoop implements MessagingSystemInfo { 21 | 22 | public static final MessagingSystemInfoNoop INSTANCE = new MessagingSystemInfoNoop(); 23 | 24 | private MessagingSystemInfoNoop() { 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/NodeNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.Tracer; 19 | 20 | abstract class NodeNoop implements Tracer { 21 | 22 | protected static final byte[] NO_TAG_BLOB = new byte[] {}; 23 | protected static final String NO_TAG_STRING = ""; 24 | 25 | @Override 26 | public void start() { 27 | } 28 | 29 | @Override 30 | public void end() { 31 | } 32 | 33 | @Override 34 | public void error(String message) { 35 | } 36 | 37 | @Override 38 | public void error(Throwable throwable) { 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OneAgentSDKNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; 19 | import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; 20 | import com.dynatrace.oneagent.sdk.api.InProcessLink; 21 | import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; 22 | import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; 23 | import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; 24 | import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; 25 | import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; 26 | import com.dynatrace.oneagent.sdk.api.LoggingCallback; 27 | import com.dynatrace.oneagent.sdk.api.OneAgentSDK; 28 | import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; 29 | import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; 30 | import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; 31 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 32 | import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; 33 | import com.dynatrace.oneagent.sdk.api.enums.SDKState; 34 | import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; 35 | import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; 36 | import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; 37 | import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; 38 | 39 | /** 40 | * This class provides an empty (NOOP) implementation of the {@link OneAgentSDK} 41 | * interface. 42 | * 43 | * @author Alram.Lechner 44 | * 45 | */ 46 | public final class OneAgentSDKNoop implements OneAgentSDK { 47 | 48 | // ***** Webrequests (incoming) ***** 49 | @Override 50 | public WebApplicationInfo createWebApplicationInfo(String webServerName, String applicationID, String contextRoot) { 51 | return WebApplicationInfoNoop.INSTANCE; 52 | } 53 | 54 | @Override 55 | public IncomingWebRequestTracer traceIncomingWebRequest(WebApplicationInfo webApplicationInfo, String url, 56 | String method) { 57 | return IncomingWebRequestTracerNoop.INSTANCE; 58 | } 59 | 60 | // ***** Remote Calls (outgoing & incoming) ***** 61 | @Override 62 | public IncomingRemoteCallTracer traceIncomingRemoteCall(String remoteMethod, String remoteService, 63 | String clientEndpoint) { 64 | return RemoteCallServerTracerNoop.INSTANCE; 65 | } 66 | 67 | @Override 68 | public OutgoingRemoteCallTracer traceOutgoingRemoteCall(String remoteMethod, String remoteService, 69 | String serviceEndpoint, ChannelType channelType, String channelEndpoint) { 70 | return RemoteCallClientTracerNoop.INSTANCE; 71 | } 72 | 73 | // ***** Common ***** 74 | 75 | @Override 76 | public void setLoggingCallback(LoggingCallback loggingCallback) { 77 | } 78 | 79 | @Override 80 | public SDKState getCurrentState() { 81 | return SDKState.PERMANENTLY_INACTIVE; 82 | } 83 | 84 | @Override 85 | public InProcessLink createInProcessLink() { 86 | return InProcessLinkNoop.INSTANCE; 87 | } 88 | 89 | @Override 90 | public InProcessLinkTracer traceInProcessLink(InProcessLink inProcessLink) { 91 | return InProcessLinkTracerNoop.INSTANCE; 92 | } 93 | 94 | @Override 95 | public void addCustomRequestAttribute(String key, String value) { 96 | } 97 | 98 | @Override 99 | public void addCustomRequestAttribute(String key, long value) { 100 | } 101 | 102 | @Override 103 | public void addCustomRequestAttribute(String key, double value) { 104 | } 105 | 106 | @Override 107 | public OutgoingWebRequestTracer traceOutgoingWebRequest(String url, String method) { 108 | return OutgoingWebRequestTracerNoop.INSTANCE; 109 | } 110 | 111 | @Override 112 | public MessagingSystemInfo createMessagingSystemInfo(String vendorName, String destinationName, 113 | MessageDestinationType destinationType, ChannelType channelType, String channelEndpoint) { 114 | return MessagingSystemInfoNoop.INSTANCE; 115 | } 116 | 117 | @Override 118 | public OutgoingMessageTracer traceOutgoingMessage(MessagingSystemInfo messagingSystem) { 119 | return OutgoingMessageTracerNoop.INSTANCE; 120 | } 121 | 122 | @Override 123 | public IncomingMessageReceiveTracer traceIncomingMessageReceive(MessagingSystemInfo messagingSystem) { 124 | return IncomingMessageReceiveTracerNoop.INSTANCE; 125 | } 126 | 127 | @Override 128 | public IncomingMessageProcessTracer traceIncomingMessageProcess(MessagingSystemInfo messagingSystem) { 129 | return IncomingMessageProcessTracerNoop.INSTANCE; 130 | } 131 | 132 | @Override 133 | public DatabaseInfo createDatabaseInfo(String name, String vendor, ChannelType channelType, 134 | String channelEndpoint) { 135 | return DatabaseInfoNoop.INSTANCE; 136 | } 137 | 138 | @Override 139 | public DatabaseRequestTracer traceSqlDatabaseRequest(DatabaseInfo databaseInfo, String statement) { 140 | return DatabaseRequestTracerNoop.INSTANCE; 141 | } 142 | 143 | @Override 144 | public CustomServiceTracer traceCustomService(String serviceMethod, String serviceName) { 145 | return CustomServiceTracerNoop.INSTANCE; 146 | } 147 | 148 | @Override 149 | public TraceContextInfo getTraceContextInfo() { 150 | return TraceContextInfoNoop.INSTANCE; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingMessageTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; 19 | 20 | public final class OutgoingMessageTracerNoop extends NodeNoop implements OutgoingMessageTracer { 21 | 22 | public static final OutgoingMessageTracerNoop INSTANCE = new OutgoingMessageTracerNoop(); 23 | 24 | private OutgoingMessageTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void start() { 29 | } 30 | 31 | @Override 32 | public void end() { 33 | } 34 | 35 | @Override 36 | public void error(String message) { 37 | } 38 | 39 | @Override 40 | public void error(Throwable throwable) { 41 | } 42 | 43 | @Override 44 | public String getDynatraceStringTag() { 45 | return NO_TAG_STRING; 46 | } 47 | 48 | @Override 49 | public byte[] getDynatraceByteTag() { 50 | return NO_TAG_BLOB; 51 | } 52 | 53 | @Override 54 | public void setVendorMessageId(String vendorMessageId) { 55 | 56 | } 57 | 58 | @Override 59 | public void setCorrelationId(String correlationId) { 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingWebRequestTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; 19 | 20 | public final class OutgoingWebRequestTracerNoop extends NodeNoop implements OutgoingWebRequestTracer { 21 | public static final OutgoingWebRequestTracerNoop INSTANCE = new OutgoingWebRequestTracerNoop(); 22 | 23 | private OutgoingWebRequestTracerNoop() { 24 | } 25 | 26 | @Override 27 | public String getDynatraceStringTag() { 28 | return NO_TAG_STRING; 29 | } 30 | 31 | @Override 32 | public byte[] getDynatraceByteTag() { 33 | return NO_TAG_BLOB; 34 | } 35 | 36 | @Override 37 | public void addRequestHeader(String name, String value) { 38 | } 39 | 40 | @Override 41 | public void addResponseHeader(String name, String value) { 42 | } 43 | 44 | @Override 45 | public void setStatusCode(int statusCode) { 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallClientTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; 19 | 20 | public final class RemoteCallClientTracerNoop extends NodeNoop implements OutgoingRemoteCallTracer { 21 | 22 | public static final OutgoingRemoteCallTracer INSTANCE = new RemoteCallClientTracerNoop(); 23 | 24 | private RemoteCallClientTracerNoop() { 25 | } 26 | 27 | @Override 28 | public String getDynatraceStringTag() { 29 | return NO_TAG_STRING; 30 | } 31 | 32 | @Override 33 | public byte[] getDynatraceByteTag() { 34 | return NO_TAG_BLOB; 35 | } 36 | 37 | @Override 38 | public void setProtocolName(String protocolName) { 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallServerTracerNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; 19 | 20 | public final class RemoteCallServerTracerNoop extends NodeNoop implements IncomingRemoteCallTracer { 21 | 22 | public static final IncomingRemoteCallTracer INSTANCE = new RemoteCallServerTracerNoop(); 23 | 24 | private RemoteCallServerTracerNoop() { 25 | } 26 | 27 | @Override 28 | public void setDynatraceStringTag(String tag) { 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | } 34 | 35 | @Override 36 | public void setProtocolName(String protocolName) { 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/TraceContextInfoNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; 19 | 20 | public final class TraceContextInfoNoop implements TraceContextInfo { 21 | public static final TraceContextInfoNoop INSTANCE = new TraceContextInfoNoop(); 22 | 23 | private TraceContextInfoNoop() {} 24 | 25 | @Override 26 | public boolean isValid() { 27 | return false; 28 | } 29 | 30 | @Override 31 | public String getTraceId() { 32 | return INVALID_TRACE_ID; 33 | } 34 | 35 | @Override 36 | public String getSpanId() { 37 | return INVALID_SPAN_ID; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/noop/WebApplicationInfoNoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.noop; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; 19 | 20 | public final class WebApplicationInfoNoop implements WebApplicationInfo { 21 | 22 | public static final WebApplicationInfo INSTANCE = new WebApplicationInfoNoop(); 23 | 24 | private WebApplicationInfoNoop() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/CustomServiceTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; 19 | 20 | final class CustomServiceTracerProxy extends TraceableProxy implements CustomServiceTracer { 21 | 22 | CustomServiceTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object customServiceTracer) { 23 | super(apiProxy, customServiceTracer); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 19 | import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; 20 | 21 | final class DatabaseInfoImpl implements DatabaseInfo { 22 | 23 | private final String name; 24 | private final String vendor; 25 | private final ChannelType channelType; 26 | private final String channelEndpoint; 27 | 28 | DatabaseInfoImpl(String name, String vendor, ChannelType channelType, String channelEndpoint) { 29 | this.name = name; 30 | this.vendor = vendor; 31 | this.channelType = channelType; 32 | this.channelEndpoint = channelEndpoint; 33 | } 34 | 35 | String getName() { 36 | return name; 37 | } 38 | 39 | String getVendor() { 40 | return vendor; 41 | } 42 | 43 | ChannelType getChannelType() { 44 | return channelType; 45 | } 46 | 47 | String getChannelEndpoint() { 48 | return channelEndpoint; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseRequestTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; 19 | 20 | final class DatabaseRequestTracerProxy extends TraceableProxy implements DatabaseRequestTracer { 21 | 22 | DatabaseRequestTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object outgoingMessageTracer) { 23 | super(apiProxy, outgoingMessageTracer); 24 | } 25 | 26 | @Override 27 | public void setReturnedRowCount(int rowsReturned) { 28 | apiProxy.databaseRequestTracer_setRowsReturned(agentsNodeObject, rowsReturned); 29 | } 30 | 31 | @Override 32 | public void setRoundTripCount(int roundTripCount) { 33 | apiProxy.databaseRequestTracer_setRoundTripCount(agentsNodeObject, roundTripCount); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.InProcessLink; 19 | 20 | final class InProcessLinkImpl implements InProcessLink { 21 | 22 | private final Object agentProvidedLink; 23 | 24 | InProcessLinkImpl(Object agentProvidedLink) { 25 | this.agentProvidedLink = agentProvidedLink; 26 | } 27 | 28 | Object getAgentProvidedLink() { 29 | return agentProvidedLink; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; 19 | 20 | final class InProcessLinkTracerProxy extends TraceableProxy implements InProcessLinkTracer { 21 | 22 | InProcessLinkTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object node) { 23 | super(apiProxy, node); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageProcessTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; 19 | 20 | final class IncomingMessageProcessTracerProxy extends TraceableProxy implements IncomingMessageProcessTracer { 21 | 22 | IncomingMessageProcessTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { 23 | super(apiProxy, agentObject); 24 | } 25 | 26 | @Override 27 | public void setDynatraceStringTag(String tag) { 28 | apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); 34 | } 35 | 36 | @Override 37 | public void setVendorMessageId(String vendorMessageId) { 38 | apiProxy.messageTracer_setVendorMessageId(agentsNodeObject, vendorMessageId); 39 | } 40 | 41 | @Override 42 | public void setCorrelationId(String correlationId) { 43 | apiProxy.messageTracer_setCorrelationId(agentsNodeObject, correlationId); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageReceiveTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; 19 | 20 | final class IncomingMessageReceiveTracerProxy extends TraceableProxy implements IncomingMessageReceiveTracer { 21 | 22 | IncomingMessageReceiveTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { 23 | super(apiProxy, agentObject); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingWebRequestProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; 19 | 20 | final class IncomingWebRequestProxy extends TraceableProxy implements IncomingWebRequestTracer { 21 | 22 | IncomingWebRequestProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { 23 | super(apiProxy, agentObject); 24 | } 25 | 26 | @Override 27 | public void setDynatraceStringTag(String tag) { 28 | apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); 34 | } 35 | 36 | @Override 37 | public void setRemoteAddress(String remoteAddress) { 38 | apiProxy.incomingWebRequestTracer_setRemoteAddress(agentsNodeObject, remoteAddress); 39 | 40 | } 41 | 42 | @Override 43 | public void addRequestHeader(String name, String value) { 44 | apiProxy.webRequestTracer_addRequestHeader(agentsNodeObject, name, value); 45 | } 46 | 47 | @Override 48 | public void addParameter(String name, String value) { 49 | apiProxy.incomingWebRequestTracer_addParameter(agentsNodeObject, name, value); 50 | } 51 | 52 | @Override 53 | public void addResponseHeader(String name, String value) { 54 | apiProxy.webRequestTracer_addResponseHeader(agentsNodeObject, name, value); 55 | } 56 | 57 | @Override 58 | public void setStatusCode(int statusCode) { 59 | apiProxy.webRequestTracer_setStatusCode(agentsNodeObject, statusCode); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/MessagingSystemInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.enums.ChannelType; 19 | import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; 20 | 21 | final class MessagingSystemInfoImpl implements com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo { 22 | 23 | private final String vendorName; 24 | private final String destinationName; 25 | private final MessageDestinationType destinationType; 26 | private final ChannelType channelType; 27 | private final String channelEndpoint; 28 | 29 | MessagingSystemInfoImpl(String vendorName, String destinationName, MessageDestinationType destinationType, 30 | ChannelType channelType, String channelEndpoint) { 31 | this.vendorName = vendorName; 32 | this.destinationName = destinationName; 33 | this.destinationType = destinationType; 34 | this.channelType = channelType; 35 | this.channelEndpoint = channelEndpoint; 36 | } 37 | 38 | String getVendorName() { 39 | return vendorName; 40 | } 41 | 42 | String getDestinationName() { 43 | return destinationName; 44 | } 45 | 46 | MessageDestinationType getDestinationType() { 47 | return destinationType; 48 | } 49 | 50 | ChannelType getChannelType() { 51 | return channelType; 52 | } 53 | 54 | String getChannelEndpoint() { 55 | return channelEndpoint; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingMessageTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; 19 | 20 | final class OutgoingMessageTracerProxy extends TraceableProxy implements OutgoingMessageTracer { 21 | 22 | OutgoingMessageTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object outgoingMessageTracer) { 23 | super(apiProxy, outgoingMessageTracer); 24 | } 25 | 26 | @Override 27 | public String getDynatraceStringTag() { 28 | return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); 29 | } 30 | 31 | @Override 32 | public byte[] getDynatraceByteTag() { 33 | return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); 34 | } 35 | 36 | @Override 37 | public void setVendorMessageId(String vendorMessageId) { 38 | apiProxy.messageTracer_setVendorMessageId(agentsNodeObject, vendorMessageId); 39 | } 40 | 41 | @Override 42 | public void setCorrelationId(String correlationId) { 43 | apiProxy.messageTracer_setCorrelationId(agentsNodeObject, correlationId); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingWebRequestTracerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; 19 | 20 | final class OutgoingWebRequestTracerProxy extends TraceableProxy implements OutgoingWebRequestTracer { 21 | 22 | OutgoingWebRequestTracerProxy(SDK2AgentInternalApiProxy apiProxy, 23 | Object oneAgentSDK_createOutgoingWebreqeustTracer) { 24 | super(apiProxy, oneAgentSDK_createOutgoingWebreqeustTracer); 25 | } 26 | 27 | @Override 28 | public String getDynatraceStringTag() { 29 | return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); 30 | } 31 | 32 | @Override 33 | public byte[] getDynatraceByteTag() { 34 | return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); 35 | } 36 | 37 | @Override 38 | public void addRequestHeader(String name, String value) { 39 | apiProxy.webRequestTracer_addRequestHeader(agentsNodeObject, name, value); 40 | } 41 | 42 | @Override 43 | public void addResponseHeader(String name, String value) { 44 | apiProxy.webRequestTracer_addResponseHeader(agentsNodeObject, name, value); 45 | } 46 | 47 | @Override 48 | public void setStatusCode(int statusCode) { 49 | apiProxy.webRequestTracer_setStatusCode(agentsNodeObject, statusCode); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallClientProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; 19 | 20 | final class RemoteCallClientProxy extends TraceableProxy implements OutgoingRemoteCallTracer { 21 | 22 | RemoteCallClientProxy(SDK2AgentInternalApiProxy apiProxy, Object oneAgentSDK_createLocalOutgoingRemoteCall) { 23 | super(apiProxy, oneAgentSDK_createLocalOutgoingRemoteCall); 24 | } 25 | 26 | @Override 27 | public String getDynatraceStringTag() { 28 | return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); 29 | } 30 | 31 | @Override 32 | public byte[] getDynatraceByteTag() { 33 | return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); 34 | } 35 | 36 | @Override 37 | public void setProtocolName(String protocolName) { 38 | apiProxy.outgoingRemoteCallTracer_setProtocolName(agentsNodeObject, protocolName); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallServerProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; 19 | 20 | final class RemoteCallServerProxy extends TraceableProxy implements IncomingRemoteCallTracer { 21 | 22 | RemoteCallServerProxy(SDK2AgentInternalApiProxy apiProxy, Object remoteCallObject) { 23 | super(apiProxy, remoteCallObject); 24 | } 25 | 26 | @Override 27 | public void setDynatraceStringTag(String tag) { 28 | apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); 29 | } 30 | 31 | @Override 32 | public void setDynatraceByteTag(byte[] tag) { 33 | apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); 34 | } 35 | 36 | @Override 37 | public void setProtocolName(String protocolName) { 38 | apiProxy.incomingRemoteCallTracer_setProtocolName(agentsNodeObject, protocolName); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceContextInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; 19 | 20 | final class TraceContextInfoImpl implements TraceContextInfo { 21 | 22 | private final String traceId; 23 | private final String spanId; 24 | 25 | public TraceContextInfoImpl(String traceId, String spanId) { 26 | this.traceId = traceId; 27 | this.spanId = spanId; 28 | } 29 | 30 | @Override 31 | public boolean isValid() { 32 | // Always true; for the invalid trace context, TraceContextInfoNoop is used. 33 | return true; 34 | } 35 | 36 | @Override 37 | public String getTraceId() { 38 | return traceId; 39 | } 40 | 41 | @Override 42 | public String getSpanId() { 43 | return spanId; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceableProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.Tracer; 19 | 20 | abstract class TraceableProxy implements Tracer { 21 | 22 | protected final SDK2AgentInternalApiProxy apiProxy; 23 | protected final Object agentsNodeObject; 24 | 25 | TraceableProxy(SDK2AgentInternalApiProxy apiProxy, Object agentsNodeObject) { 26 | this.apiProxy = apiProxy; 27 | this.agentsNodeObject = agentsNodeObject; 28 | } 29 | 30 | @Override 31 | public void start() { 32 | apiProxy.tracer_start(agentsNodeObject); 33 | 34 | } 35 | 36 | @Override 37 | public void end() { 38 | apiProxy.tracer_end(agentsNodeObject); 39 | 40 | } 41 | 42 | @Override 43 | public void error(String message) { 44 | apiProxy.tracer_error(agentsNodeObject, message); 45 | 46 | } 47 | 48 | @Override 49 | public void error(Throwable throwable) { 50 | apiProxy.tracer_error(agentsNodeObject, throwable); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/WebApplicationInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dynatrace.oneagent.sdk.impl.proxy; 17 | 18 | import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; 19 | 20 | final class WebApplicationInfoImpl implements WebApplicationInfo { 21 | 22 | private final String webServerName; 23 | private final String applicationID; 24 | private final String contextRoot; 25 | 26 | WebApplicationInfoImpl(String webServerName, String applicationID, String contextRoot) { 27 | this.webServerName = webServerName; 28 | this.applicationID = applicationID; 29 | this.contextRoot = contextRoot; 30 | } 31 | 32 | String getWebServerName() { 33 | return webServerName; 34 | } 35 | 36 | String getApplicationID() { 37 | return applicationID; 38 | } 39 | 40 | String getContextRoot() { 41 | return contextRoot; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Dynatrace LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * internal SDK implementation. direct usage is forbidden. package provides 18 | * proxy classes for forwarding requests to OneAgent. 19 | */ 20 | package com.dynatrace.oneagent.sdk.impl.proxy; 21 | -------------------------------------------------------------------------------- /src/test/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImplTest.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.impl; 2 | 3 | import org.assertj.core.api.Assertions; 4 | import org.junit.Test; 5 | 6 | import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; 7 | 8 | public class OneAgentSDKFactoryImplTest { 9 | 10 | @Test 11 | public void versionCheckTest() { 12 | // *** public version of SDK 13 | String buildVersion = System.getProperty("sdk.version"); 14 | Assertions.assertThat(buildVersion).isEqualTo("1.9.0"); 15 | 16 | // *** internal version (between SDK and agent) 17 | String[] splitted = buildVersion.split("\\."); 18 | int major = Integer.parseInt(splitted[0]); 19 | int minor = Integer.parseInt(splitted[1]); 20 | int fix = Integer.parseInt(splitted[2]); 21 | 22 | Assertions.assertThat(major).isEqualTo(OneAgentSDKFactoryImpl.oneSdkMajor); 23 | Assertions.assertThat(minor).isEqualTo(OneAgentSDKFactoryImpl.oneSdkMinor); 24 | Assertions.assertThat(fix).isEqualTo(OneAgentSDKFactoryImpl.oneSdkFix); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.dynatrace.oneagent.sdk.impl; 2 | 3 | import static org.junit.Assert.assertThat; 4 | 5 | import org.hamcrest.core.IsEqual; 6 | import org.junit.Test; 7 | 8 | import com.dynatrace.oneagent.sdk.impl.SDKInstanceProvider; 9 | 10 | public class SDKInstanceProviderTest { 11 | 12 | @Test 13 | public void testClassName() { 14 | assertThat("class name changed. incompatible with older agents.", SDKInstanceProvider.class.getName(), 15 | IsEqual.equalTo("com.dynatrace.oneagent.sdk.impl.SDKInstanceProvider")); 16 | } 17 | 18 | } 19 | --------------------------------------------------------------------------------