diff --git a/.gitignore b/.gitignore index f9a50e1..f69f244 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .project .settings .classpath +target diff --git a/LICENSE b/LICENSE index 8dada3e..9060297 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright 2018 Dynatrace LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md old mode 100644 new mode 100755 index abb82c6..06a4e61 --- a/README.md +++ b/README.md @@ -1,76 +1,149 @@ -**Disclaimer: This SDK is currently in early access and still work in progress.** - # Dynatrace OneAgent SDK for Java -This SDK allows Dynatrace customers to instrument java applications. This is useful to enhance the visibility for proprietary frameworks or custom frameworks not directly supported by Dynatrace OneAgent out-of-the-box. - -It provides the Java implementation of the [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK). +This SDK allows Dynatrace customers to instrument java applications. This is useful to enhance the visibility for proprietary frameworks or +custom frameworks not directly supported by Dynatrace OneAgent out-of-the-box. + +This is the official Java implementation of the [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK). + +## Table of Contents + +* [Package contents](#package-contents) +* [Requirements](#requirements) +* [Integration](#integration) + * [Dependencies](#dependencies) + * [Troubleshooting](#troubleshooting) +* [API concepts](#api-concepts) + * [OneAgentSDK object](#oneagentsdk-object) + * [Trace Context](#tracecontext) + * [Tracers](#tracers) +* [Features](#features) + * [Trace incoming and outgoing remote calls](#trace-incoming-and-outgoing-remote-calls) + * [In process linking](#in-process-linking) + * [Add custom request attributes](#add-custom-request-attributes) + * [Custom services](#custom-services) + * [Trace web requests](#trace-web-requests) + * [Trace incoming web requests](#trace-incoming-web-requests) + * [Trace outgoing web requests](#trace-outgoing-web-requests) + * [Trace messaging](#trace-messaging) + * [Trace SQL database requests](#trace-sql-database-requests) +* [Further reading](#further-reading) +* [Help & support](#help-&-support) +* [Release notes](#release-notes) ## Package contents -- `samples`: contains sample application, which demonstrates the usage of the SDK. see readme inside the samples directory for more details -- `LICENSE`: license under which the whole SDK and sample applications are published +* `samples`: contains sample application, which demonstrates the usage of the SDK. See readme inside the samples directory for more details. +* `docs`: contains the reference documentation (javadoc). The most recent version is also available online at [https://dynatrace.github.io/OneAgent-SDK-for-Java/](https://dynatrace.github.io/OneAgent-SDK-for-Java/). +* `LICENSE`: license under which the whole SDK and sample applications are published. -## Features -Dynatrace OneAgent SDK for Java currently implements support for the following features (corresponding to features specified in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK)): -- outgoing and incoming remote calls +## Requirements + +* An JRE that is both supported with a supported version of OneAgent and at least JRE 1.6-compatible. +* Dynatrace OneAgent (for required versions, see table below) +* The OneAgent SDK is not supported on serverless code modules, including those for AWS Lambda. + Consider using [OpenTelemetry](https://www.dynatrace.com/support/help/shortlink/opentel-lambda) + instead in these scenarios. + +|OneAgent SDK for Java|Required OneAgent version|Support status| +|:--------------------|:------------------------|:-------------| +|1.9.0 |>=1.261 |Supported | +|1.8.0 |>=1.201 |Supported | +|1.7.0 |>=1.167 |Deprecated with support ending 2023-09-01 | +|1.6.0 |>=1.161 |Deprecated with support ending 2023-09-01 | +|1.4.0 |>=1.151 |Deprecated with support ending 2023-09-01 | +|1.3.0 |>=1.149 |Deprecated with support ending 2023-09-01 | +|1.2.0 |>=1.147 |Deprecated with support ending 2023-09-01 | +|1.1.0 |>=1.143 |Deprecated with support ending 2023-09-01 | +|1.0.3 |>=1.135 |Deprecated with support ending 2023-09-01 | -## Integrating into your application +## Integration ### Dependencies -If you want to integrate the OneAgent SDK into your application, just add the following maven dependency: - - com.dynatrace.oneagent.sdk.java - oneagent-sdk - 1.0.3 - compile - +If you want to integrate the OneAgent SDK into your application, just add the following Maven dependency: -If you prefer to integrate the SDK using plain jar file, just download them from mavenCentral - Dynatrace OneAgent SDK for Java [binary](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3.jar), [source](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3-sources.jar) and [javadoc](https://search.maven.org/remotecontent?filepath=com/dynatrace/oneagent/sdk/java/oneagent-sdk/1.0.3/oneagent-sdk-1.0.3-javadoc.jar) +```xml + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.9.0 + compile + +``` + +If you prefer to integrate the SDK using plain jar file, just download them from Maven Central, e.g. from +. The Dynatrace OneAgent SDK for Java has no further dependencies. ### Troubleshooting -If the SDK can't connect to the OneAgent (see usage of SDKState in samples) or you you don't see the desired result in the Dynatrace UI, you can set the following system property to print debug information to standard out: - - -Dcom.dynatrace.oneagent.sdk.debug=true -Additionally you should/have to ensure, that you have set a `LoggingCallback`. For usage see class `StdErrLoggingCallback` in `remotecall-server` module (in samples/remotecall folder). +If the SDK can't connect to the OneAgent (see usage of SDKState in samples) or you you don't see the desired result in the Dynatrace UI, +you can set the following system property to print debug information to standard out: -## OneAgent SDK for Java Requirements +```java +-Dcom.dynatrace.oneagent.sdk.debug=true +``` -- JRE 1.6 or higher -- Dynatrace OneAgent Java (supported versions see below) +Additionally you should/have to ensure, that you have set a `LoggingCallback`. For usage see class `StdErrLoggingCallback` in +`remotecall-server` module (in samples/remotecall folder). -# API Concepts +## API concepts -Common concepts of the Dynatrace OneAgent SDK are explained the [Dynatrace OneAgent SDK repository](https://github.com/Dynatrace/OneAgent-SDK). +Common concepts of the Dynatrace OneAgent SDK are explained in the [Dynatrace OneAgent SDK repository](https://github.com/Dynatrace/OneAgent-SDK#apiconcepts). -## Get an Api object +### OneAgentSDK object -Use OneAgentSDKFactory.createInstance() to obtain an OneAgentSDK instance. You should reuse this object over the whole application -and if possible JVM lifetime: +Use OneAgentSDKFactory.createInstance() to obtain an OneAgentSDK instance. You should reuse this object throughout the whole application +and, if possible, JVM lifetime: ```Java OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); switch (oneAgentSdk.getCurrentState()) { case ACTIVE: - break; + break; case PERMANENTLY_INACTIVE: - break; + break; case TEMPORARILY_INACTIVE: - break; + break; default: - break; + break; } ``` -It is good practice to check the SDK state regularly as it may change at every point of time (except PERMANENTLY_INACTIVE never changes over JVM lifetime). +It is good practice to check the SDK state regularly as it may change at any point in time (except for PERMANENTLY_INACTIVE, which never +changes throughout the JVM lifetime). + + + -## Common concepts: Tracers +## Trace Context -To trace any kind of call you first need to create a Tracer. The Tracer object represents the logical and physical endpoint that you want to call. A Tracer serves two purposes. First to time the call (duraction, cpu and more) and report errors. That is why each Tracer has these three methods. The error method must be called only once, and it must be in between start and end. +An instance of the `OneAgentSDK` can be used to get the current `ITraceContextInfo` which holds information +about the *Trace-Id* and *Span-Id* of the current PurePath node. +This information can then be used to provide e.g. additional context in log messages. + +Please note that `TraceContextInfo` is not intended for tagging or context-propagation use cases. +Dedicated APIs (e.g. [remote calls](#remoting) or [web requests](#webrequests)) as well as +built-in OneAgent sensors take care of linking services correctly. + +```Java +TraceContextInfo traceContextInfo = oneAgentSdk.getTraceContextInfo(); +String traceId = traceContextInfo.getTraceId(); +String spanId = traceContextInfo.getSpanId(); +System.out.printf("[!dt dt.trace_id=%s,dt.span_id=%s] sending request... have trace ctx: %s%n", +traceId, spanId, traceContextInfo.isValid()); +``` + +### Tracers + +To trace any kind of call you first need to create a Tracer. The Tracer object represents the logical and physical endpoint that +you want to call. A Tracer serves two purposes. First, to time the call (duration, cpu and more) and report errors. That is why +each Tracer has these three methods. The error method must be called only once, and it must be in between start and end. + +A Tracer instance can only be used from the thread on which it was created. +See [in process linking](#in-process-linking) for tracing across thread boundaries, and see further below in this section +for how to cross process boundaries. ```Java void start(); @@ -79,17 +152,59 @@ void error(String message); void end(); ``` -The second purpose of a Tracer is to allow tracing across process boundaries. To achieve that these kind of traces supply so called tags. Tags are strings or byte arrays that enable Dynatrace to trace a transaction end to end. As such the tag is the one information that you need to transport across these calls yourselfs. +`start()` records the active PurePath node on the current Java thread +as parent (if any; whether created by another Tracer or the OneAgent), creates a new PurePath node +and sets the new one as the currently active one. The OneAgent also requires that a child node ends +before all parent nodes (Stated another way, tracers on the same thread must be ended in the opposite +order of how they were started. While this may sound odd if you hear it the first time, it corresponds +to the most natural usage pattern and you usually don't even need to think about it). + +While the tracer's automatic parent-child relationship works very intuitively in most cases, +it does not work with **asynchronous patterns**, where the same thread handles multiple logically +separate operations in an interleaved way on the same Java thread. If you need to instrument +such patterns, it is recommended to use the OneAgent's [OpenTelemetry interoperability][oa-otel]. + +[oa-otel]: https://www.dynatrace.com/support/help/shortlink/opent-java -## Using the Dynatrace OneAgent SDK to trace remote calls +The second purpose of a Tracer is to allow tracing across process boundaries. To achieve that these kind of traces supply so called +tags. Tags are strings or byte arrays that enable Dynatrace to trace a transaction end to end. As such the tag is the one information +that you need to transport across these calls as an SDK user. + +## Features + +The feature sets differ slightly with each language implementation. More functionality will be added over time, see Planned features for OneAgent SDK +for details on upcoming features. + +A more detailed specification of the features can be found in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK#features). + +|Feature |Required OneAgent SDK for Java version| +|:----------------------------------------------|:-------------------------------------| +|Trace context for log enrichment |>=1.9.0 | +|Custom services |>=1.8.0 | +|Trace database requests |>=1.7.0 | +|Trace messaging |>=1.6.0 | +|Outgoing web requests |>=1.4.0 | +|Incoming web requests |>=1.3.0 | +|Custom request attributes |>=1.2.0 | +|In process linking |>=1.1.0 | +|Trace incoming and outgoing remote calls |>=1.0.3 | -You can use the SDK to trace proprietary IPC communication from one process to the other. This will enable you to see full Service Flow, PurePath and Smartscape topology for remoting technologies that Dynatrace is not aware of. -To trace any kind of remote call you first need to create a Tracer. The Tracer object represents the endpoint that you want to call, as such you need to supply the name of the remote service and remote method. In addition you need to transport the tag in your remote call to the server side if you want to trace it end to end. + + +### Trace incoming and outgoing remote calls + +You can use the SDK to trace proprietary IPC communication from one process to the other. This will enable you to see full Service Flow, PurePath +and Smartscape topology for remoting technologies that Dynatrace is not aware of. + +To trace any kind of remote call you first need to create a Tracer. The Tracer object represents the endpoint that you want to call, as such you +need to supply the name of the remote service and remote method. In addition you need to transport the tag in your remote call to the server side +if you want to trace it end to end. ```Java -OutgoingRemoteCallTracer outgoingRemoteCall = OneAgentSDK.traceOutgoingRemoteCall("remoteMethodToCall", "RemoteServiceName", "rmi://Endpoint/service", ChannelType.TCP_IP, "remoteHost:1234"); +OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); +OutgoingRemoteCallTracer outgoingRemoteCall = oneAgentSdk.traceOutgoingRemoteCall("remoteMethodToCall", "RemoteServiceName", "rmi://Endpoint/service", ChannelType.TCP_IP, "remoteHost:1234"); outgoingRemoteCall.setProtocolName("RMI/custom"); outgoingRemoteCall.start(); try { @@ -97,15 +212,18 @@ try { // make the call and transport the tag across to server } catch (Throwable e) { outgoingRemoteCall.error(e); + // rethrow or add your exception handling } finally { outgoingRemoteCall.end(); } ``` -On the server side you need to wrap the handling and processing of your remote call as well. This will not only trace the server side call and everything that happens, it will also connect it to the calling side. +On the server side you need to wrap the handling and processing of your remote call as well. This will not only trace the server side call and +everything that happens, it will also connect it to the calling side. ```Java -IncomingRemoteCallTracer incomingRemoteCall = OneAgentSDK.traceIncomingRemoteCall("remoteMethodToCall", "RemoteServiceName", "rmi://Endpoint/service"); +OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); +IncomingRemoteCallTracer incomingRemoteCall = oneAgentSdk.traceIncomingRemoteCall("remoteMethodToCall", "RemoteServiceName", "rmi://Endpoint/service"); incomingRemoteCall.setDynatraceStringTag(tag); incomingRemoteCall.start(); try { @@ -113,22 +231,336 @@ try { doSomeWork(); // process the remoteCall } catch (Exception e) { incomingRemoteCall.error(e); -}finally{ + // rethrow or add your exception handling +} finally{ incomingRemoteCall.end(); } ``` -### Compatibility OneAgent SDK for Java releases with OneAgent for Java releases -|OneAgent SDK for Java|Dynatrace OneAgent Java| -|:------|:--------| -|1.0.3 |>=1.135 | +### In process linking + +You can use the SDK to link inside a single process. To link for eg. an asynchronous execution, you need the following code: + +```Java +OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); +InProcessLink inProcessLink = oneAgentSdk.createInProcessLink(); +``` + +Provide the returned ``inProcessLink`` to the code, that does the asynchronous execution: + +```Java +OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); +InProcessLinkTracer inProcessLinkTracer = oneAgentSdk.traceInProcessLink(inProcessLink); +inProcessLinkTracer.start(); +try { + // do the work ... +} catch (Exception e) { + inProcessLinkTracer.error(e); + // rethrow or add your exception handling +} finally { + inProcessLinkTracer.end(); +} +``` + +### Add custom request attributes + +You can use the SDK to add custom request attributes to the current traced service. Custom request attributes allow you to do advanced filtering of +your requests in Dynatrace. + +Adding custom request attributes to the currently traced service call is simple. Just call one of the addCustomRequestAttribute methods with your key and value: + +```Java +oneAgentSDK.addCustomRequestAttribute("region", "EMEA"); +oneAgentSDK.addCustomRequestAttribute("salesAmount", 2500); +``` + +When no service call is being traced, the custom request attributes are dropped. + +### Custom services + +You can use the SDK to trace custom service methods. A custom service method is a meaningful +part of your code that you want to trace but that does not fit any other tracer. +An example could be the callback of a periodic timer. + +```Java +String serviceMethod = "onTimer"; +String serviceName = "PeriodicCleanupTask"; +CustomServiceTracer tracer = oneAgentSDK.traceCustomService(serviceMethod, serviceName); +tracer.start(); +try { + doMyCleanup(); +} catch (Exception e) { + tracer.error(e.getMessage()); + throw e; +} finally { + tracer.end(); +} +``` + + + +### Trace web requests + +#### Trace incoming web requests + +You can use the SDK to trace incoming web requests. This might be useful if Dynatrace does not support the respective web server framework or language +processing the incoming web requests. + +To trace an incoming web request you first need to create a WebApplicationInfo object. The info object represents the endpoint of your web server (web server name, application name and context root). This object should be reused for all traced web requests within for the same application. + +```Java +WebApplicationInfo wsInfo = oneAgentSdk.createWebApplicationInfo("WebShopProduction", "CheckoutService", "/api/service/checkout"); +``` + +To trace a specific incoming web request you then need to create a Tracer object. Make sure you provide all http headers from the request +to the SDK by calling `addRequestHeader(...)`. This ensures that tagging with our built-in sensors will work. + +**Note**: + +* Previous OneAgent versions only supported the proprietary Dynatrace tracing header (`x-dynatrace`). +* Starting with OneAgent version `1.317`, [**W3C Trace Context**](https://www.w3.org/TR/trace-context) headers will be processed as well if they are provided via `addRequestHeader`. + +```Java +IncomingWebRequestTracer tracer = oneAgentSdk.traceIncomingWebRequest(wsInfo,"https://www.oursupershop.com/api/service/checkout/save", "POST") + +for (Entry headerField : httpRequest.getHeaders().entrySet()) { + tracer.addRequestHeader(headerField.getKey(), headerField.getValue()); +} + +for (Entry> parameterEntry : httpRequest.getParameters().entrySet()) { + for (String value : parameterEntry.getValue()) { + tracer.addParameter(parameterEntry.getKey(), value); + } +} + +tracer.setRemoteAddress(httpRequest.getRemoteHostName()); + +tracer.start(); +try { + int statusCodeReturnedToClient = processWebRequest(); + tracer.setStatusCode(statusCodeReturnedToClient); +} catch (Exception e) { + tracer.setStatusCode(500); // we expect that the container sends HTTP 500 status code in case request processing throws an exception + tracer.error(e); + throw e; +} finally { + tracer.end(); +} +``` + +#### Trace outgoing web requests + +You can use the SDK to trace outgoing web requests. This might be useful if Dynatrace does not support the respective http library or +language sending the request. + +To trace an outgoing web request you need to create a Tracer object. It is important to send the Dynatrace Header. This ensures that +tagging with our built-in sensor will work. + +```Java +OutgoingWebRequestTracer outgoingWebRequestTracer = oneAgentSdk.traceOutgoingWebRequest(url, "GET"); + +// provide all request headers to outgoingWebRequestTracer (optional): +for (Entry entry : yourHttpClient.getRequestHeaders().entrySet()) { + outgoingWebRequestTracer.addRequestHeader(entry.getKey(), entry.getValue()); +} + +outgoingWebRequestTracer.start(); +try { + yourHttpClient.setUrl(url); + + // sending HTTP header OneAgentSDK.DYNATRACE_HTTP_HEADERNAME is necessary for tagging: + yourHttpClient.addRequestHeader(OneAgentSDK.DYNATRACE_HTTP_HEADERNAME, outgoingWebRequestTracer.getDynatraceStringTag()); + + yourHttpClient.processHttpRequest(); + + for (Entry> entry : yourHttpClient.getHeaderFields().entrySet()) { + for (String value : entry.getValue()) { + outgoingWebRequestTracer.addResponseHeader(entry.getKey(), value); + } + } + outgoingWebRequestTracer.setStatusCode(yourHttpClient.getResponseCode()); + +} catch (Exception e) { + outgoingWebRequestTracer.error(e); + // rethrow or add your exception handling +} finally { + outgoingWebRequestTracer.end(); +} +``` + +### Trace messaging + +You can use the SDK to trace messages sent or received via messaging & queuing systems. When tracing messages, we distinguish between: + +* sending a message +* receiving a message +* processing a received message + +To trace an outgoing message, you simply need to create a MessagingSystemInfo and call traceOutgoingMessage with that instance: + +```Java +MessagingSystemInfo messagingSystemInfo = oneAgentSDK.createMessagingSystemInfo("myMessagingSystem", + "requestQueue", MessageDestinationType.QUEUE, ChannelType.TCP_IP, "localhost:4711"); +OutgoingMessageTracer outgoingMessageTracer = oneAgentSDK.traceOutgoingMessage(messagingSystemInfo); +outgoingMessageTracer.start(); +try { + // transport the dynatrace tag along with the message: + messageToSend.setHeaderField( + OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME, outgoingMessageTracer.getDynatraceStringTag()); + // optional: add application provided correlationId + outgoingMessageTracer.setCorrelationId(toSend.correlationId); + + theQueue.send(messageToSend); + + // optional: add messageid provided from messaging system + outgoingMessageTracer.setVendorMessageId(toSend.getMessageId()); +} catch (Exception e) { + outgoingMessageTracer.error(e.getMessage()); + // rethrow or add your exception handling +} finally { + outgoingMessageTracer.end(); +} +``` + +On the incoming side, we need to differentiate between the blocking receiving part and processing the received message. Therefore two +different tracers are being used: `IncomingMessageReceiveTracer` and `IncomingMessageProcessTracer`. + +```Java +MessagingSystemInfo messagingSystemInfo = oneAgentSDK.createMessagingSystemInfo("myMessagingSystem", + "requestQueue", MessageDestinationType.QUEUE, ChannelType.TCP_IP, "localhost:4711"); + +// message receiving daemon task: +while(true) { + IncomingMessageReceiveTracer incomingMessageReceiveTracer = + oneAgentSDK.traceIncomingMessageReceive(messagingSystemInfo); + incomingMessageReceiveTracer.start(); + try { + // blocking call - until message is being available: + Message queryMessage = theQueue.receive("client queries"); + IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSDK + .traceIncomingMessageProcess(messagingSystemInfo); + incomingMessageProcessTracer.setDynatraceStringTag( + queryMessage.getHeaderField(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); + incomingMessageProcessTracer.setVendorMessageId(queryMessage.msgId); + incomingMessageProcessTracer.setCorrelationId(queryMessage.correlationId); + incomingMessageProcessTracer.start(); + try { + // do the work ... + } catch (Exception e) { + incomingMessageProcessTracer.error(e.getMessage()); + Logger.logError(e); + } finally { + incomingMessageProcessTracer.end(); + } + } catch (Exception e) { + incomingMessageReceiveTracer.error(e.getMessage()); + // rethrow or add your exception handling + } finally { + incomingMessageReceiveTracer.end(); + } +} +``` + +In case of non-blocking receive (e. g. via event handler), there is no need to use `IncomingMessageReceiveTracer` - just trace processing +of the message by using the `IncomingMessageProcessTracer`: + +```Java +MessagingSystemInfo messagingSystemInfo = oneAgentSDK.createMessagingSystemInfo("myMessagingSystem", + "requestQueue", MessageDestinationType.QUEUE, ChannelType.TCP_IP, "localhost:4711"); + +public void onMessage(Message message) { + IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSDK + .traceIncomingMessageProcess(messagingSystemInfo); + incomingMessageProcessTracer.setDynatraceStringTag((String) + message.getObjectProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); + incomingMessageProcessTracer.setVendorMessageId(queryMessage.msgId); + incomingMessageProcessTracer.setCorrelationId(queryMessage.correlationId); + incomingMessageProcessTracer.start(); + try { + // do the work ... + } catch (Exception e) { + incomingMessageProcessTracer.error(e.getMessage()); + // rethrow or add your exception handling + } finally { + incomingMessageProcessTracer.end(); + } +} +``` + +> Please also see the [documentation on messaging tracers in the specification repository](https://github.com/Dynatrace/OneAgent-SDK#messaging). + +### Trace SQL database requests + +A SQL database request is traced by calling `traceSqlDatabaseRequest`. For details about usage see the [OneAgentSDK specification](https://github.com/Dynatrace/OneAgent-SDK#database) + +```java +String sql = "SELECT * FROM transformationdata WHERE transformation_id = " + id; + +DatabaseInfo databaseInfo = oneAgentSdk.createDatabaseInfo("TransformationDb", DatabaseVendor.FIREBIRD.getVendorName(), ChannelType.TCP_IP, "db-serv01.acme.com:2323"); + +DatabaseRequestTracer databaseTracer = oneAgentSdk.traceSqlDatabaseRequest(databaseInfo, sql); +databaseTracer.start(); +try { + Result result = executeTheDatabaseCall(sql); + databaseTracer.setReturnedRowCount(result.getRows().getLength()); +} catch (InterruptedException e) { + databaseTracer.error(e); + // handle or rethrow +} finally { + databaseTracer.end(); +} +``` + +Please note that SQL database traces are only created if they occur within some other SDK trace (e.g. incoming remote call) +or a OneAgent built-in trace (e.g. incoming web request). + +## Further reading + +* What is the OneAgent SDK? in the Dynatrace documentation +* Feedback & Roadmap thread in AnswerHub +* Blog: Dynatrace OneAgent SDK for Java: End-to-end monitoring for proprietary Java frameworks + +## Help & support + +### Support policy + +The Dynatrace OneAgent SDK for Java has GA status. The features are fully supported by Dynatrace. + +For detailed support policy see [Dynatrace OneAgent SDK help](https://github.com/Dynatrace/OneAgent-SDK#help). + +### Get help + +* Ask a question in the product forums +* Read the product documentation + +**Open a GitHub issue to:** + +* Report minor defects, minor items or typos +* Ask for improvements or changes in the SDK API +* Ask any questions related to the community effort + +SLAs don't apply for GitHub tickets + +**Customers can open a ticket on the Dynatrace support portal to:** + +* Get support from the Dynatrace technical support engineering team +* Manage and resolve product related technical issues + +SLAs apply according to the customer's support level. + +## Release notes + +### Version 1.9.0 + +* [Add support to retrieve W3C trace context information for log enrichment.](#tracecontext) + +### Other announcements -## Feedback +* [**W3C Trace Context**](https://www.w3.org/TR/trace-context/) headers for [incoming web requests](#trace-incoming-web-requests) are +supported with OneAgent versions starting from `1.317`. -In case of questions, issues or feature requests feel free to contact [Michael Kopp](https://github.com/mikopp), [Alram Lechner](https://github.com/AlramLechnerDynatrace) or file an issue. Your feedback is welcome! +* ⚠️ **Deprecation announcement for older SDK versions:** Version 1.7 and all older versions have been put on the path to deprecation and will no longer be supported starting September 1, 2023. We advise customers to upgrade to newest version. Customers need to upgrade to at least 1.8 but are encouraged to upgrade to the newest available version (1.9). +### Older versions -## OneAgent SDK for Java release notes -|Version|Date|Description| -|:------|:----------|:------------------| -|1.0.3 |01.2018 |Initial release | +See for older release notes. diff --git a/docs/META-INF/MANIFEST.MF b/docs/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/docs/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/docs/allclasses-frame.html b/docs/allclasses-frame.html new file mode 100755 index 0000000..51df98b --- /dev/null +++ b/docs/allclasses-frame.html @@ -0,0 +1,81 @@ + + + + + + +All Classes (sdk 1.9.0 API) + + + + + + + + + + + +All Classes +
+ + + + + +
ChannelType +
+CustomServiceTracer +
+DatabaseInfo +
+DatabaseRequestTracer +
+DatabaseVendor +
+IncomingMessageProcessTracer +
+IncomingMessageReceiveTracer +
+IncomingRemoteCallTracer +
+IncomingTaggable +
+IncomingWebRequestTracer +
+InProcessLink +
+InProcessLinkTracer +
+LoggingCallback +
+MessageDestinationType +
+MessageSystemVendor +
+MessagingSystemInfo +
+OneAgentSDK +
+OneAgentSDKFactory +
+OutgoingMessageTracer +
+OutgoingRemoteCallTracer +
+OutgoingTaggable +
+OutgoingWebRequestTracer +
+SDKState +
+TraceContextInfo +
+Tracer +
+WebApplicationInfo +
+
+ + + diff --git a/docs/allclasses-noframe.html b/docs/allclasses-noframe.html new file mode 100755 index 0000000..bc940cb --- /dev/null +++ b/docs/allclasses-noframe.html @@ -0,0 +1,81 @@ + + + + + + +All Classes (sdk 1.9.0 API) + + + + + + + + + + + +All Classes +
+ + + + + +
ChannelType +
+CustomServiceTracer +
+DatabaseInfo +
+DatabaseRequestTracer +
+DatabaseVendor +
+IncomingMessageProcessTracer +
+IncomingMessageReceiveTracer +
+IncomingRemoteCallTracer +
+IncomingTaggable +
+IncomingWebRequestTracer +
+InProcessLink +
+InProcessLinkTracer +
+LoggingCallback +
+MessageDestinationType +
+MessageSystemVendor +
+MessagingSystemInfo +
+OneAgentSDK +
+OneAgentSDKFactory +
+OutgoingMessageTracer +
+OutgoingRemoteCallTracer +
+OutgoingTaggable +
+OutgoingWebRequestTracer +
+SDKState +
+TraceContextInfo +
+Tracer +
+WebApplicationInfo +
+
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.html b/docs/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.html new file mode 100755 index 0000000..2da09d8 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.html @@ -0,0 +1,262 @@ + + + + + + +OneAgentSDKFactory (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk +
+Class OneAgentSDKFactory

+
+java.lang.Object
+  extended by com.dynatrace.oneagent.sdk.OneAgentSDKFactory
+
+
+
+
public class OneAgentSDKFactory
extends java.lang.Object
+ + +

+Entry point for customer application. +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
OneAgentSDKFactory() + +
+           
+  + + + + + + + + + + + +
+Method Summary
+static OneAgentSDKcreateInstance() + +
+          Provides a OneAgentSDK instance, that has to be used to create + transactions.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OneAgentSDKFactory

+
+public OneAgentSDKFactory()
+
+
+ + + + + + + + +
+Method Detail
+ +

+createInstance

+
+public static OneAgentSDK createInstance()
+
+
Provides a OneAgentSDK instance, that has to be used to create + transactions. It is safe to use returned OneAgentSDK instance in + multiple threads. Every application should only create one single SDK + instance during its lifetime. +

+

+ +
Returns:
never null. if no OneAgent present, NOOP implementation gets + returned.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.html b/docs/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.html new file mode 100755 index 0000000..5b135af --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.html @@ -0,0 +1,197 @@ + + + + + + +CustomServiceTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface CustomServiceTracer

+
+
All Superinterfaces:
Tracer
+
+
+
+
public interface CustomServiceTracer
extends Tracer
+ + +

+Interface for tracing custom services. + https://github.com/Dynatrace/OneAgent-SDK#customservice +

+ +

+

+
Since:
+
1.8.0
+
+
+ +

+ + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+  +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.html b/docs/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.html new file mode 100755 index 0000000..41a20c0 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.html @@ -0,0 +1,258 @@ + + + + + + +DatabaseRequestTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface DatabaseRequestTracer

+
+
All Superinterfaces:
Tracer
+
+
+
+
public interface DatabaseRequestTracer
extends Tracer
+ + +

+Interface for outgoing database tracer. + https://github.com/Dynatrace/OneAgent-SDK#database +

+ +

+

+
Since:
+
1.7.0
+
+
+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidsetReturnedRowCount(int returnedRowCount) + +
+          Adds optional information about retrieved rows of the traced database request.
+ voidsetRoundTripCount(int roundTripCount) + +
+          Adds optional information about round-trip count to database server.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+  +

+ + + + + + + + +
+Method Detail
+ +

+setReturnedRowCount

+
+void setReturnedRowCount(int returnedRowCount)
+
+
Adds optional information about retrieved rows of the traced database request. +

+

+
+
+
+
Parameters:
returnedRowCount - number of rows returned by this traced database request. Only positive values are allowed.
Since:
+
1.7.0
+
+
+
+
+ +

+setRoundTripCount

+
+void setRoundTripCount(int roundTripCount)
+
+
Adds optional information about round-trip count to database server. +

+

+
+
+
+
Parameters:
roundTripCount - count of round-trips that took place. Only positive values are allowed.
Since:
+
1.7.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/InProcessLink.html b/docs/com/dynatrace/oneagent/sdk/api/InProcessLink.html new file mode 100755 index 0000000..d854bad --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/InProcessLink.html @@ -0,0 +1,176 @@ + + + + + + +InProcessLink (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface InProcessLink

+
+
+
public interface InProcessLink
+ + +

+Represents link used for in-process-tagging. See + OneAgentSDK.createInProcessLink() and + OneAgentSDK.traceInProcessLink(InProcessLink) for more details. +

+ +

+

+
Since:
+
1.1
+
+
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.html b/docs/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.html new file mode 100755 index 0000000..de2f021 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.html @@ -0,0 +1,198 @@ + + + + + + +InProcessLinkTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface InProcessLinkTracer

+
+
All Superinterfaces:
Tracer
+
+
+
+
public interface InProcessLinkTracer
extends Tracer
+ + +

+Tracer used to trace in-process-linking. See + OneAgentSDK.createInProcessLink() and + OneAgentSDK.traceInProcessLink(InProcessLink) for more details. +

+ +

+

+
Since:
+
1.1
+
+
+ +

+ + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+  +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.html b/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.html new file mode 100755 index 0000000..33f5b2d --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.html @@ -0,0 +1,263 @@ + + + + + + +IncomingMessageProcessTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface IncomingMessageProcessTracer

+
+
All Superinterfaces:
IncomingTaggable, Tracer
+
+
+
+
public interface IncomingMessageProcessTracer
extends IncomingTaggable, Tracer
+ + +

+Interface for processing message tracer. + https://github.com/Dynatrace/OneAgent-SDK#messaging +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidsetCorrelationId(java.lang.String correlationId) + +
+          Adds optional information about a traced message: correlation id used by messaging system.
+ voidsetVendorMessageId(java.lang.String vendorMessageId) + +
+          Adds optional information about a traced message: message id provided by messaging system.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.IncomingTaggable
setDynatraceByteTag, setDynatraceStringTag
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+  +

+ + + + + + + + +
+Method Detail
+ +

+setVendorMessageId

+
+void setVendorMessageId(java.lang.String vendorMessageId)
+
+
Adds optional information about a traced message: message id provided by messaging system. +

+

+
+
+
+
Parameters:
vendorMessageId - the messageId
+
+
+
+ +

+setCorrelationId

+
+void setCorrelationId(java.lang.String correlationId)
+
+
Adds optional information about a traced message: correlation id used by messaging system. +

+

+
+
+
+
Parameters:
correlationId - correlationId
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.html b/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.html new file mode 100755 index 0000000..52e827f --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.html @@ -0,0 +1,197 @@ + + + + + + +IncomingMessageReceiveTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface IncomingMessageReceiveTracer

+
+
All Superinterfaces:
Tracer
+
+
+
+
public interface IncomingMessageReceiveTracer
extends Tracer
+ + +

+Interface for receiving message tracer. + https://github.com/Dynatrace/OneAgent-SDK#messaging +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+  +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.html b/docs/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.html new file mode 100755 index 0000000..8dc19e9 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.html @@ -0,0 +1,238 @@ + + + + + + +IncomingRemoteCallTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface IncomingRemoteCallTracer

+
+
All Superinterfaces:
IncomingTaggable, Tracer
+
+
+
+
public interface IncomingRemoteCallTracer
extends Tracer, IncomingTaggable
+ + +

+Represents the server side of a remote call. This Interface extends + Tracer - it is important to respect the mentioned requirements when + working with IncomingRemoteCallTracer. +

+ +

+


+ +

+ + + + + + + + + + + + +
+Method Summary
+ voidsetProtocolName(java.lang.String protocolName) + +
+          Sets the name of the used remoting protocol.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.IncomingTaggable
setDynatraceByteTag, setDynatraceStringTag
+  +

+ + + + + + + + +
+Method Detail
+ +

+setProtocolName

+
+void setProtocolName(java.lang.String protocolName)
+
+
Sets the name of the used remoting protocol. +

+

+
+
+
+
Parameters:
protocolName - protocol name
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/IncomingTaggable.html b/docs/com/dynatrace/oneagent/sdk/api/IncomingTaggable.html new file mode 100755 index 0000000..65e11ce --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/IncomingTaggable.html @@ -0,0 +1,243 @@ + + + + + + +IncomingTaggable (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface IncomingTaggable

+
+
All Known Subinterfaces:
IncomingMessageProcessTracer, IncomingRemoteCallTracer, IncomingWebRequestTracer
+
+
+
+
public interface IncomingTaggable
+ + +

+Common interface for server-tagging-related methods. Not to be directly used + by SDK user. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidsetDynatraceByteTag(byte[] tag) + +
+          Same as setDynatraceStringTag(String) but consumes binary + representation of tag.
+ voidsetDynatraceStringTag(java.lang.String tag) + +
+          Consumes a tag to continue a pure path.
+  +

+ + + + + + + + +
+Method Detail
+ +

+setDynatraceStringTag

+
+void setDynatraceStringTag(java.lang.String tag)
+
+
Consumes a tag to continue a pure path. Must be set before a node is being + started.
+ See OutgoingTaggable to determine how to create a tag. +

+

+
Parameters:
tag - the tag in String representation - must not be null.
Since:
+
1.0
+
+
+
+
+ +

+setDynatraceByteTag

+
+void setDynatraceByteTag(byte[] tag)
+
+
Same as setDynatraceStringTag(String) but consumes binary + representation of tag. +

+

+
Parameters:
tag - the tag in binary representation - must not be null.
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.html b/docs/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.html new file mode 100755 index 0000000..6223420 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.html @@ -0,0 +1,346 @@ + + + + + + +IncomingWebRequestTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface IncomingWebRequestTracer

+
+
All Superinterfaces:
IncomingTaggable, Tracer
+
+
+
+
public interface IncomingWebRequestTracer
extends Tracer, IncomingTaggable
+ + +

+Interface for incoming webrequest tracer. https://github.com/Dynatrace/OneAgent-SDK#webrequests +

+ +

+

+
Since:
+
1.3
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddParameter(java.lang.String name, + java.lang.String value) + +
+          All HTTP parameters should be provided to this method.
+ voidaddRequestHeader(java.lang.String name, + java.lang.String value) + +
+          All HTTP request headers should be provided to this method.
+ voidaddResponseHeader(java.lang.String name, + java.lang.String value) + +
+          All HTTP response headers should be provided to this method.
+ voidsetRemoteAddress(java.lang.String remoteAddress) + +
+          Validates and sets the remote IP address of the incoming web request.
+ voidsetStatusCode(int statusCode) + +
+          Sets the HTTP response status code.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.IncomingTaggable
setDynatraceByteTag, setDynatraceStringTag
+  +

+ + + + + + + + +
+Method Detail
+ +

+setRemoteAddress

+
+void setRemoteAddress(java.lang.String remoteAddress)
+
+
Validates and sets the remote IP address of the incoming web request. This + information is very useful to gain information about Load balancers, Proxies + and ultimately the end user that is sending the request. +

+

+
+
+
+
Parameters:
remoteAddress - remote IP address
+
+
+
+ +

+addRequestHeader

+
+void addRequestHeader(java.lang.String name,
+                      java.lang.String value)
+
+
All HTTP request headers should be provided to this method. Selective + capturing will be done based on sensor configuration. +

+

+
+
+
+
Parameters:
name - HTTP request header field name
value - HTTP request header field value
+
+
+
+ +

+addParameter

+
+void addParameter(java.lang.String name,
+                  java.lang.String value)
+
+
All HTTP parameters should be provided to this method. Selective capturing + will be done based on sensor configuration. +

+

+
+
+
+
Parameters:
name - HTTP parameter name
value - HTTP parameter value
+
+
+
+ +

+addResponseHeader

+
+void addResponseHeader(java.lang.String name,
+                       java.lang.String value)
+
+
All HTTP response headers should be provided to this method. Selective + capturing will be done based on sensor configuration. +

+

+
+
+
+
Parameters:
name - HTTP response header field name
value - HTTP response header field value
+
+
+
+ +

+setStatusCode

+
+void setStatusCode(int statusCode)
+
+
Sets the HTTP response status code. +

+

+
+
+
+
Parameters:
statusCode - HTTP status code returned to client
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/LoggingCallback.html b/docs/com/dynatrace/oneagent/sdk/api/LoggingCallback.html new file mode 100755 index 0000000..e3c6ec7 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/LoggingCallback.html @@ -0,0 +1,238 @@ + + + + + + +LoggingCallback (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface LoggingCallback

+
+
+
public interface LoggingCallback
+ + +

+LoggingCallback gets called only inside a OneAgentSDK API call when an + error/warning has occurred.
+ Never call any SDK API inside one of these callback methods. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voiderror(java.lang.String message) + +
+          Something that should be done can't be done.
+ voidwarn(java.lang.String message) + +
+          Just a warning.
+  +

+ + + + + + + + +
+Method Detail
+ +

+warn

+
+void warn(java.lang.String message)
+
+
Just a warning. Something is missing, but OneAgent is working normal. +

+

+
Parameters:
message - message text. never null.
Since:
+
1.0
+
+
+
+
+ +

+error

+
+void error(java.lang.String message)
+
+
Something that should be done can't be done. (e. g. PurePath could not be + started) +

+

+
Parameters:
message - message text. never null.
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/OneAgentSDK.html b/docs/com/dynatrace/oneagent/sdk/api/OneAgentSDK.html new file mode 100755 index 0000000..27887ec --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/OneAgentSDK.html @@ -0,0 +1,822 @@ + + + + + + +OneAgentSDK (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface OneAgentSDK

+
+
+
public interface OneAgentSDK
+ + +

+Root interface contains provided Agent SDK API calls. Basically the whole API + is designed according to following rules: +

    +
  • API calls never throw any exception +
  • API calls never return null values. e. g. they returning NOOP Objects in + case of any issue or required parameters are null. +
+ Single API calls might differ from that rules. Those rules are explicitly + documented.
+

+ +

+


+ +

+ + + + + + + + + + + + + + + +
+Field Summary
+static java.lang.StringDYNATRACE_HTTP_HEADERNAME + +
+          Using this headername to transport Dynatrace tag inside an outgoing http + request ensures compatibility to Dynatrace built-in sensors.
+static java.lang.StringDYNATRACE_MESSAGE_PROPERTYNAME + +
+          Using this propertyname to transport Dynatrace tag along with the message, ensures compatibility to Dynatrace built-in sensors.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddCustomRequestAttribute(java.lang.String key, + double value) + +
+          Does exactly the same as addCustomRequestAttribute(String, String), + but request-attribute type double.
+ voidaddCustomRequestAttribute(java.lang.String key, + long value) + +
+          Does exactly the same as addCustomRequestAttribute(String, String), + but request-attribute type long.
+ voidaddCustomRequestAttribute(java.lang.String key, + java.lang.String value) + +
+          Adds a custom request attribute to currently traced service call.
+ DatabaseInfocreateDatabaseInfo(java.lang.String name, + java.lang.String vendor, + ChannelType channelType, + java.lang.String channelEndpoint) + +
+          Initializes a DatabaseInfo instance that is required for tracing database requests.
+ InProcessLinkcreateInProcessLink() + +
+          Creates a link for in-process-linking.
+ MessagingSystemInfocreateMessagingSystemInfo(java.lang.String vendorName, + java.lang.String destinationName, + MessageDestinationType destinationType, + ChannelType channelType, + java.lang.String channelEndpoint) + +
+          Initializes a MessagingSystemInfo instance that is required for tracing messages.
+ WebApplicationInfocreateWebApplicationInfo(java.lang.String webServerName, + java.lang.String applicationID, + java.lang.String contextRoot) + +
+          Initializes a WebApplicationInfo instance that is required for tracing + incoming web requests.
+ SDKStategetCurrentState() + +
+          Returns the current SDKState.
+ TraceContextInfogetTraceContextInfo() + +
+          Returns the current W3C trace context for log enrichment + (not meant for tagging and context-propagation but for log-enrichment).
+ voidsetLoggingCallback(LoggingCallback loggingCallback) + +
+          Installs a callback that gets informed, if any SDK action has failed.
+ CustomServiceTracertraceCustomService(java.lang.String serviceMethod, + java.lang.String serviceName) + +
+          Creates a tracer for a custom transaction (Dynatrace calls them Custom service).
+ IncomingMessageProcessTracertraceIncomingMessageProcess(MessagingSystemInfo messagingSystem) + +
+          Creates a tracer for processing (consuming) a received message (onMessage).
+ IncomingMessageReceiveTracertraceIncomingMessageReceive(MessagingSystemInfo messagingSystem) + +
+          Creates a tracer for an incoming asynchronous message (blocking receive).
+ IncomingRemoteCallTracertraceIncomingRemoteCall(java.lang.String serviceMethod, + java.lang.String serviceName, + java.lang.String serviceEndpoint) + +
+          Traces an incoming remote call.
+ IncomingWebRequestTracertraceIncomingWebRequest(WebApplicationInfo webApplicationInfo, + java.lang.String url, + java.lang.String method) + +
+          Traces an incoming web request.
+ InProcessLinkTracertraceInProcessLink(InProcessLink inProcessLink) + +
+          Traces the start of in-process-linking.
+ OutgoingMessageTracertraceOutgoingMessage(MessagingSystemInfo messagingSystem) + +
+          Creates a tracer for an outgoing asynchronous message (send).
+ OutgoingRemoteCallTracertraceOutgoingRemoteCall(java.lang.String serviceMethod, + java.lang.String serviceName, + java.lang.String serviceEndpoint, + ChannelType channelType, + java.lang.String channelEndpoint) + +
+          Traces an outgoing remote call.
+ OutgoingWebRequestTracertraceOutgoingWebRequest(java.lang.String url, + java.lang.String method) + +
+          Traces an outgoing web request.
+ DatabaseRequestTracertraceSqlDatabaseRequest(DatabaseInfo databaseInfo, + java.lang.String statement) + +
+          Creates a tracer for tracing outgoing SQL database requests.
+  +

+ + + + + + + + +
+Field Detail
+ +

+DYNATRACE_HTTP_HEADERNAME

+
+static final java.lang.String DYNATRACE_HTTP_HEADERNAME
+
+
Using this headername to transport Dynatrace tag inside an outgoing http + request ensures compatibility to Dynatrace built-in sensors. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DYNATRACE_MESSAGE_PROPERTYNAME

+
+static final java.lang.String DYNATRACE_MESSAGE_PROPERTYNAME
+
+
Using this propertyname to transport Dynatrace tag along with the message, ensures compatibility to Dynatrace built-in sensors. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Method Detail
+ +

+createDatabaseInfo

+
+DatabaseInfo createDatabaseInfo(java.lang.String name,
+                                java.lang.String vendor,
+                                ChannelType channelType,
+                                java.lang.String channelEndpoint)
+
+
Initializes a DatabaseInfo instance that is required for tracing database requests. +

+

+
Parameters:
name - name of the database
vendor - database vendor name (e.g. Oracle, MySQL, ...), can be a user defined name + If possible use a constant defined in DatabaseVendor
channelType - communication protocol used to communicate with the database.
channelEndpoint - this represents the communication endpoint for the database. This information allows Dynatrace to tie the database requests to a specific process or cloud service. It is optional. + * for TCP/IP: host name/IP of the server-side (can include port in the form of "host:port") + * for UNIX domain sockets: name of domain socket file + * for named pipes: name of pipe +
Returns:
DatabaseInfo instance to work with
Since:
+
1.7.0
+
+
+
+
+ +

+traceSqlDatabaseRequest

+
+DatabaseRequestTracer traceSqlDatabaseRequest(DatabaseInfo databaseInfo,
+                                              java.lang.String statement)
+
+
Creates a tracer for tracing outgoing SQL database requests. +

+

+
Parameters:
databaseInfo - information about database
statement - database SQL statement +
Returns:
DatabaseRequestTracer to work with
Since:
+
1.7.0
+
+
+
+
+ +

+createWebApplicationInfo

+
+WebApplicationInfo createWebApplicationInfo(java.lang.String webServerName,
+                                            java.lang.String applicationID,
+                                            java.lang.String contextRoot)
+
+
Initializes a WebApplicationInfo instance that is required for tracing + incoming web requests. This information determines the identity and name of + the resulting Web Request service in dynatrace. Also see + https://www.dynatrace.com/support/help/server-side-services/introduction/how-does-dynatrace-detect-and-name-services/#web-request-services + for detail description of the meaning of the parameters. +

+

+
Parameters:
webServerName - logical name of the web server. In case of a cluster every node in + the cluster must report the same name here. Attention: Make sure + not to use the host header for this parameter. Host headers are + often spoofed and contain things like google or baidoo which do + not reflect your setup.
applicationID - application ID of the web application
contextRoot - context root of the application. All URLs traced with the returned + WebApplicationInfo, should start with provided context root. +
Returns:
WebApplicationInfo instance to work with
Since:
+
1.3
+
+
+
+
+ +

+traceIncomingWebRequest

+
+IncomingWebRequestTracer traceIncomingWebRequest(WebApplicationInfo webApplicationInfo,
+                                                 java.lang.String url,
+                                                 java.lang.String method)
+
+
Traces an incoming web request. +

+

+
Parameters:
webApplicationInfo - information about web application
url - (parts of a) URL, which will be parsed into: scheme, + hostname/port, path & query Note: the hostname will be resolved by + the Agent at start() call
method - HTTP request method +
Returns:
IncomingWebRequestTracer to work with
Since:
+
1.3
+
+
+
+
+ +

+traceOutgoingWebRequest

+
+OutgoingWebRequestTracer traceOutgoingWebRequest(java.lang.String url,
+                                                 java.lang.String method)
+
+
Traces an outgoing web request. +

+

+
Parameters:
url - URL, which will be parsed into: scheme, hostname/port, path & + query Note: the hostname will be resolved by the Agent at start() + call
method - HTTP request method +
Returns:
OutgoingWebRequestTracer to work with
Since:
+
1.4
+
+
+
+
+ +

+traceIncomingRemoteCall

+
+IncomingRemoteCallTracer traceIncomingRemoteCall(java.lang.String serviceMethod,
+                                                 java.lang.String serviceName,
+                                                 java.lang.String serviceEndpoint)
+
+
Traces an incoming remote call. +

+

+
Parameters:
serviceMethod - name of the called remote method. (required)
serviceName - name of the remote service. (required)
serviceEndpoint - endpoint on the server side. (required) +
Returns:
IncomingRemoteCallTracer instance to work with
Since:
+
1.0
+
+
+
+
+ +

+traceOutgoingRemoteCall

+
+OutgoingRemoteCallTracer traceOutgoingRemoteCall(java.lang.String serviceMethod,
+                                                 java.lang.String serviceName,
+                                                 java.lang.String serviceEndpoint,
+                                                 ChannelType channelType,
+                                                 java.lang.String channelEndpoint)
+
+
Traces an outgoing remote call. +

+

+
Parameters:
serviceMethod - name of the called remote method. (required)
serviceName - name of the remote service. (required)
serviceEndpoint - endpoint on the server side. (required)
channelType - communication protocol used by remote call. See + ChannelType for available types. (required)
channelEndpoint - optional and depending on channelType: +
    +
  • for TCP/IP: host name/IP of the server-side (can include port) +
  • for UNIX domain sockets: path of domain socket file +
  • for named pipes: name of pipe +
+
Returns:
OutgoingRemoteCallTracer instance to work with
Since:
+
1.0
+
+
+
+
+ +

+createInProcessLink

+
+InProcessLink createInProcessLink()
+
+
Creates a link for in-process-linking. +

+

+ +
Returns:
InProcessLink instance to work with. Use it with + traceInProcessLink(InProcessLink)
Since:
+
1.1
+
+
+
+
+ +

+traceInProcessLink

+
+InProcessLinkTracer traceInProcessLink(InProcessLink inProcessLink)
+
+
Traces the start of in-process-linking. +

+

+
Parameters:
inProcessLink - a InProcessLink received via createInProcessLink() +
Returns:
InProcessLinkTracer to work with.
Since:
+
1.1
+
+
+
+
+ +

+addCustomRequestAttribute

+
+void addCustomRequestAttribute(java.lang.String key,
+                               java.lang.String value)
+
+
Adds a custom request attribute to currently traced service call. Might be + called multiple times, to add more than one attribute. Check via + setLoggingCallback(LoggingCallback) if error happened. If two + attributes with same key are set, both attribute-values are captured. +

+

+
Parameters:
key - key of the attribute. required parameter.
value - value of the attribute. required parameter.
Since:
+
1.2
+
+
+
+
+ +

+addCustomRequestAttribute

+
+void addCustomRequestAttribute(java.lang.String key,
+                               long value)
+
+
Does exactly the same as addCustomRequestAttribute(String, String), + but request-attribute type long. +

+

+
Since:
+
1.2
+
+
+
+
+ +

+addCustomRequestAttribute

+
+void addCustomRequestAttribute(java.lang.String key,
+                               double value)
+
+
Does exactly the same as addCustomRequestAttribute(String, String), + but request-attribute type double. +

+

+
Since:
+
1.2
+
+
+
+
+ +

+createMessagingSystemInfo

+
+MessagingSystemInfo createMessagingSystemInfo(java.lang.String vendorName,
+                                              java.lang.String destinationName,
+                                              MessageDestinationType destinationType,
+                                              ChannelType channelType,
+                                              java.lang.String channelEndpoint)
+
+
Initializes a MessagingSystemInfo instance that is required for tracing messages. +

+

+
Parameters:
vendorName - one of MessageSystemVendor if well known vendor. Custom provided in any other case.
destinationName - destination name (e.g. queue name, topic name)
destinationType - destination type - see MessageDestinationType.
channelType - communication protocol used
channelEndpoint - optional and depending on protocol: + * for TCP/IP: host name/IP of the server-side (can include port) + * for UNIX domain sockets: name of domain socket file + * for named pipes: name of pipe +
Returns:
MessagingSystemInfo instance to work with
Since:
+
1.5
+
+
+
+
+ +

+traceOutgoingMessage

+
+OutgoingMessageTracer traceOutgoingMessage(MessagingSystemInfo messagingSystem)
+
+
Creates a tracer for an outgoing asynchronous message (send). +

+

+
Parameters:
messagingSystem - information about the messaging system (see createMessagingSystemInfo methods). +
Returns:
OutgoingMessageTracer to work with
Since:
+
1.5
+
+
+
+
+ +

+traceIncomingMessageReceive

+
+IncomingMessageReceiveTracer traceIncomingMessageReceive(MessagingSystemInfo messagingSystem)
+
+
Creates a tracer for an incoming asynchronous message (blocking receive). +

+

+
Parameters:
messagingSystem - information about the messaging system (see createMessagingSystemInfo methods). +
Returns:
IncomingMessageReceiveTracer to work with
Since:
+
1.5
+
+
+
+
+ +

+traceIncomingMessageProcess

+
+IncomingMessageProcessTracer traceIncomingMessageProcess(MessagingSystemInfo messagingSystem)
+
+
Creates a tracer for processing (consuming) a received message (onMessage). +

+

+
Parameters:
messagingSystem - information about the messaging system (see createMessagingSystemInfo methods). +
Returns:
IncomingMessageProcessTracer to work with
Since:
+
1.5
+
+
+
+
+ +

+setLoggingCallback

+
+void setLoggingCallback(LoggingCallback loggingCallback)
+
+
Installs a callback that gets informed, if any SDK action has failed. For + details see LoggingCallback interface. The provided callback must be + thread-safe, when using this OneAgentSDK instance in multi-threaded + environments. +

+

+
Parameters:
loggingCallback - may be null, to remove current callback. provided callback + replaces any previously set callback.
Since:
+
1.0
+
+
+
+
+ +

+getCurrentState

+
+SDKState getCurrentState()
+
+
Returns the current SDKState. See SDKState for details. +

+

+ +
Returns:
current state - never null.
Since:
+
1.0
+
+
+
+
+ +

+traceCustomService

+
+CustomServiceTracer traceCustomService(java.lang.String serviceMethod,
+                                       java.lang.String serviceName)
+
+
Creates a tracer for a custom transaction (Dynatrace calls them Custom service). Used whenever a transaction + should be traced, that does not match any of the specialised transaction types (e. g. DB-request, webrequest, ...). +

+

+
Parameters:
serviceMethod - service method being used for service creation.
serviceName - service name being used for service creation. +
Returns:
CustomServiceTracer to work with
Since:
+
1.8
+
+
+
+
+ +

+getTraceContextInfo

+
+TraceContextInfo getTraceContextInfo()
+
+
Returns the current W3C trace context for log enrichment + (not meant for tagging and context-propagation but for log-enrichment). + See TraceContextInfo for details. +

+

+ +
Returns:
current trace context at the time of the call - never null (but may contain all-zero ID).
Since:
+
1.9
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.html b/docs/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.html new file mode 100755 index 0000000..fe2b2ac --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.html @@ -0,0 +1,263 @@ + + + + + + +OutgoingMessageTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface OutgoingMessageTracer

+
+
All Superinterfaces:
OutgoingTaggable, Tracer
+
+
+
+
public interface OutgoingMessageTracer
extends Tracer, OutgoingTaggable
+ + +

+Interface for outgoing message tracer. + https://github.com/Dynatrace/OneAgent-SDK#messaging +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidsetCorrelationId(java.lang.String correlationId) + +
+          Adds optional information about a traced message: correlation id used by messaging system.
+ voidsetVendorMessageId(java.lang.String vendorMessageId) + +
+          Adds optional information about a traced message: message id provided by messaging system.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.OutgoingTaggable
getDynatraceByteTag, getDynatraceStringTag
+  +

+ + + + + + + + +
+Method Detail
+ +

+setVendorMessageId

+
+void setVendorMessageId(java.lang.String vendorMessageId)
+
+
Adds optional information about a traced message: message id provided by messaging system. +

+

+
+
+
+
Parameters:
vendorMessageId - the messageId
+
+
+
+ +

+setCorrelationId

+
+void setCorrelationId(java.lang.String correlationId)
+
+
Adds optional information about a traced message: correlation id used by messaging system. +

+

+
+
+
+
Parameters:
correlationId - correlationId
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.html b/docs/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.html new file mode 100755 index 0000000..b7ffdd1 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.html @@ -0,0 +1,240 @@ + + + + + + +OutgoingRemoteCallTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface OutgoingRemoteCallTracer

+
+
All Superinterfaces:
OutgoingTaggable, Tracer
+
+
+
+
public interface OutgoingRemoteCallTracer
extends Tracer, OutgoingTaggable
+ + +

+Represents the client side of a remote call. + + This Interface extends Tracer - it is important to respect the + mentioned requirements when working with OutgoingRemoteCallTracer. +

+ +

+


+ +

+ + + + + + + + + + + + +
+Method Summary
+ voidsetProtocolName(java.lang.String protocolName) + +
+          Sets the name of the used remoting protocol.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.OutgoingTaggable
getDynatraceByteTag, getDynatraceStringTag
+  +

+ + + + + + + + +
+Method Detail
+ +

+setProtocolName

+
+void setProtocolName(java.lang.String protocolName)
+
+
Sets the name of the used remoting protocol. Setting the protocol name is + optional. +

+

+
+
+
+
Parameters:
protocolName - protocol name. null value is ignored.
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.html b/docs/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.html new file mode 100755 index 0000000..9844b1f --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.html @@ -0,0 +1,246 @@ + + + + + + +OutgoingTaggable (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface OutgoingTaggable

+
+
All Known Subinterfaces:
OutgoingMessageTracer, OutgoingRemoteCallTracer, OutgoingWebRequestTracer
+
+
+
+
public interface OutgoingTaggable
+ + +

+Common interface for client-tagging-related methods. Not to be directly used + by SDK user. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ byte[]getDynatraceByteTag() + +
+          Same as getDynatraceStringTag(), but returning the tag as binary + representation.
+ java.lang.StringgetDynatraceStringTag() + +
+          Creates a Dynatrace tag and returns the String representation of it.
+  +

+ + + + + + + + +
+Method Detail
+ +

+getDynatraceStringTag

+
+java.lang.String getDynatraceStringTag()
+
+
Creates a Dynatrace tag and returns the String representation of it. This tag + has to be transported with the remoting protocol to the destination.
+ See IncomingTaggable how to continue a path with provided tag on the + server side. +

+

+ +
Returns:
the tag - never null.
Since:
+
1.0
+
+
+
+
+ +

+getDynatraceByteTag

+
+byte[] getDynatraceByteTag()
+
+
Same as getDynatraceStringTag(), but returning the tag as binary + representation. +

+

+ +
Returns:
the tag - never null.
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.html b/docs/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.html new file mode 100755 index 0000000..912b9d8 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.html @@ -0,0 +1,293 @@ + + + + + + +OutgoingWebRequestTracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface OutgoingWebRequestTracer

+
+
All Superinterfaces:
OutgoingTaggable, Tracer
+
+
+
+
public interface OutgoingWebRequestTracer
extends Tracer, OutgoingTaggable
+ + +

+Represents client side of an outgoing webrequest. +

+ +

+

+
Since:
+
1.4
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddRequestHeader(java.lang.String name, + java.lang.String value) + +
+          All HTTP request headers should be provided to this method.
+ voidaddResponseHeader(java.lang.String name, + java.lang.String value) + +
+          All HTTP response headers returned by the server should be provided to this + method.
+ voidsetStatusCode(int statusCode) + +
+          Sets the HTTP response status code.
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.Tracer
end, error, error, start
+ + + + + + + +
Methods inherited from interface com.dynatrace.oneagent.sdk.api.OutgoingTaggable
getDynatraceByteTag, getDynatraceStringTag
+  +

+ + + + + + + + +
+Method Detail
+ +

+addRequestHeader

+
+void addRequestHeader(java.lang.String name,
+                      java.lang.String value)
+
+
All HTTP request headers should be provided to this method. Selective + capturing will be done based on sensor configuration. +

+

+
+
+
+
Parameters:
name - HTTP request header field name
value - HTTP request header field value
+
+
+
+ +

+addResponseHeader

+
+void addResponseHeader(java.lang.String name,
+                       java.lang.String value)
+
+
All HTTP response headers returned by the server should be provided to this + method. Selective capturing will be done based on sensor configuration. +

+

+
+
+
+
Parameters:
name - HTTP response header field name
value - HTTP response header field value
+
+
+
+ +

+setStatusCode

+
+void setStatusCode(int statusCode)
+
+
Sets the HTTP response status code. +

+

+
+
+
+
Parameters:
statusCode - HTTP status code retrieved from server
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/Tracer.html b/docs/com/dynatrace/oneagent/sdk/api/Tracer.html new file mode 100755 index 0000000..4879c6e --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/Tracer.html @@ -0,0 +1,316 @@ + + + + + + +Tracer (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api +
+Interface Tracer

+
+
All Known Subinterfaces:
CustomServiceTracer, DatabaseRequestTracer, IncomingMessageProcessTracer, IncomingMessageReceiveTracer, IncomingRemoteCallTracer, IncomingWebRequestTracer, InProcessLinkTracer, OutgoingMessageTracer, OutgoingRemoteCallTracer, OutgoingWebRequestTracer
+
+
+
+
public interface Tracer
+ + +

+Common interface for timing-related methods. Not to be directly used by SDK + user. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidend() + +
+          Ends timing of a node.
+ voiderror(java.lang.String message) + +
+          Marks the node as 'exited by exception'.
+ voiderror(java.lang.Throwable throwable) + +
+          Marks the node as 'exited by exception'.Additional information can be + provided as Throwable.
+ voidstart() + +
+          starts timing of a node.
+  +

+ + + + + + + + +
+Method Detail
+ +

+start

+
+void start()
+
+
starts timing of a node. Every node that has been started, must be ended with + end() method. Consider using the following pattern: + +
+ tracer.start();
+   try {
+     // do your work
+   } catch (Exception e) {
+     tracer.error(e);
+   } finally {
+     tracer.end();
+   }
+ 
+ 
+ + start(), end(), error(String), + error(Throwable) are not thread-safe. They must be called from the + same thread where start() has been invoked. +

+

+
Since:
+
1.0
+
+
+
+
+ +

+end

+
+void end()
+
+
Ends timing of a node. Typically this method is called via finally block. +
+ start(), end(), error(String), + error(Throwable) are not thread-safe. They must be called from the + same thread where start() has been invoked. +

+

+
Since:
+
1.0
+
+
+
+
+ +

+error

+
+void error(java.lang.String message)
+
+
Marks the node as 'exited by exception'. An additional error message can be + provided as String.
+ start(), end(), error(String), + error(Throwable) are not thread-safe. They must be called from the + same thread where start() has been invoked. +

+

+
Parameters:
message - error message with details about occurred error (eg. return code). + must not be null.
Since:
+
1.0
+
+
+
+
+ +

+error

+
+void error(java.lang.Throwable throwable)
+
+
Marks the node as 'exited by exception'.Additional information can be + provided as Throwable.
+ start(), end(), error(String), + error(Throwable) are not thread-safe. They must be called from the + same thread where start() has been invoked. +

+

+
Parameters:
throwable - exception, that occurred. must not null.
Since:
+
1.0
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/ChannelType.html b/docs/com/dynatrace/oneagent/sdk/api/enums/ChannelType.html new file mode 100755 index 0000000..44b8321 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/ChannelType.html @@ -0,0 +1,391 @@ + + + + + + +ChannelType (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.enums +
+Enum ChannelType

+
+java.lang.Object
+  extended by java.lang.Enum<ChannelType>
+      extended by com.dynatrace.oneagent.sdk.api.enums.ChannelType
+
+
+
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ChannelType>
+
+
+
+
public enum ChannelType
extends java.lang.Enum<ChannelType>
+ + +

+Defines the type of communication channel being used. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + +
+Enum Constant Summary
IN_PROCESS + +
+           
NAMED_PIPE + +
+           
OTHER + +
+           
TCP_IP + +
+           
UNIX_DOMAIN_SOCKET + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intgetSDKConstant() + +
+           
+static ChannelTypevalueOf(java.lang.String name) + +
+          Returns the enum constant of this type with the specified name.
+static ChannelType[]values() + +
+          Returns an array containing the constants of this enum type, in +the order they are declared.
+ + + + + + + +
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
+ + + + + + + +
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Enum Constant Detail
+ +

+OTHER

+
+public static final ChannelType OTHER
+
+
+
+
+
+ +

+TCP_IP

+
+public static final ChannelType TCP_IP
+
+
+
+
+
+ +

+UNIX_DOMAIN_SOCKET

+
+public static final ChannelType UNIX_DOMAIN_SOCKET
+
+
+
+
+
+ +

+NAMED_PIPE

+
+public static final ChannelType NAMED_PIPE
+
+
+
+
+
+ +

+IN_PROCESS

+
+public static final ChannelType IN_PROCESS
+
+
+
+
+ + + + + + + + +
+Method Detail
+ +

+values

+
+public static ChannelType[] values()
+
+
Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
+for (ChannelType c : ChannelType.values())
+    System.out.println(c);
+
+

+

+ +
Returns:
an array containing the constants of this enum type, in +the order they are declared
+
+
+
+ +

+valueOf

+
+public static ChannelType valueOf(java.lang.String name)
+
+
Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.) +

+

+
Parameters:
name - the name of the enum constant to be returned. +
Returns:
the enum constant with the specified name +
Throws: +
java.lang.IllegalArgumentException - if this enum type has no constant +with the specified name +
java.lang.NullPointerException - if the argument is null
+
+
+
+ +

+getSDKConstant

+
+public int getSDKConstant()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.html b/docs/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.html new file mode 100755 index 0000000..b9d6318 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.html @@ -0,0 +1,914 @@ + + + + + + +DatabaseVendor (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.enums +
+Enum DatabaseVendor

+
+java.lang.Object
+  extended by java.lang.Enum<DatabaseVendor>
+      extended by com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor
+
+
+
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<DatabaseVendor>
+
+
+
+
public enum DatabaseVendor
extends java.lang.Enum<DatabaseVendor>
+ + +

+Enumerates all well-known database vendors. See OneAgentSDK.createDatabaseInfo(String, String, ChannelType, String). + Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. +

+ +

+

+
Since:
+
1.7.0
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Enum Constant Summary
ADABAS + +
+           
APACHE_HIVE + +
+           
CACHE + +
+           
CASSANDRA + +
+           
CLOUDSCAPE + +
+           
COLDFUSION_IMQ + +
+           
COUCHBASE + +
+           
DB2 + +
+           
DERBY_CLIENT + +
+           
DERBY_EMBEDDED + +
+           
ENTERPRISE_DB + +
+           
FILEMAKER + +
+           
FIREBIRD + +
+           
FIRST_SQL + +
+           
H2 + +
+           
HANADB + +
+           
HSQLDB + +
+           
INFORMIX + +
+           
INGRES + +
+           
INSTANT_DB + +
+           
INTERBASE + +
+           
MARIADB + +
+           
MAXDB + +
+           
MYSQL + +
+           
NETEZZA + +
+           
ORACLE + +
+           
PERVASIVE + +
+           
POINTBASE + +
+           
POSTGRESQL + +
+           
PROGRESS + +
+           
REDSHIFT + +
+           
SQLITE + +
+           
SQLSERVER + +
+           
SYBASE + +
+           
TERADATA + +
+           
VERTICA + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetVendorName() + +
+           
+ java.lang.StringtoString() + +
+           
+static DatabaseVendorvalueOf(java.lang.String name) + +
+          Returns the enum constant of this type with the specified name.
+static DatabaseVendor[]values() + +
+          Returns an array containing the constants of this enum type, in +the order they are declared.
+ + + + + + + +
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
+ + + + + + + +
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Enum Constant Detail
+ +

+APACHE_HIVE

+
+public static final DatabaseVendor APACHE_HIVE
+
+
+
+
+
+ +

+CLOUDSCAPE

+
+public static final DatabaseVendor CLOUDSCAPE
+
+
+
+
+
+ +

+HSQLDB

+
+public static final DatabaseVendor HSQLDB
+
+
+
+
+
+ +

+PROGRESS

+
+public static final DatabaseVendor PROGRESS
+
+
+
+
+
+ +

+MAXDB

+
+public static final DatabaseVendor MAXDB
+
+
+
+
+
+ +

+HANADB

+
+public static final DatabaseVendor HANADB
+
+
+
+
+
+ +

+INGRES

+
+public static final DatabaseVendor INGRES
+
+
+
+
+
+ +

+FIRST_SQL

+
+public static final DatabaseVendor FIRST_SQL
+
+
+
+
+
+ +

+ENTERPRISE_DB

+
+public static final DatabaseVendor ENTERPRISE_DB
+
+
+
+
+
+ +

+CACHE

+
+public static final DatabaseVendor CACHE
+
+
+
+
+
+ +

+ADABAS

+
+public static final DatabaseVendor ADABAS
+
+
+
+
+
+ +

+FIREBIRD

+
+public static final DatabaseVendor FIREBIRD
+
+
+
+
+
+ +

+DB2

+
+public static final DatabaseVendor DB2
+
+
+
+
+
+ +

+DERBY_CLIENT

+
+public static final DatabaseVendor DERBY_CLIENT
+
+
+
+
+
+ +

+DERBY_EMBEDDED

+
+public static final DatabaseVendor DERBY_EMBEDDED
+
+
+
+
+
+ +

+FILEMAKER

+
+public static final DatabaseVendor FILEMAKER
+
+
+
+
+
+ +

+INFORMIX

+
+public static final DatabaseVendor INFORMIX
+
+
+
+
+
+ +

+INSTANT_DB

+
+public static final DatabaseVendor INSTANT_DB
+
+
+
+
+
+ +

+INTERBASE

+
+public static final DatabaseVendor INTERBASE
+
+
+
+
+
+ +

+MYSQL

+
+public static final DatabaseVendor MYSQL
+
+
+
+
+
+ +

+MARIADB

+
+public static final DatabaseVendor MARIADB
+
+
+
+
+
+ +

+NETEZZA

+
+public static final DatabaseVendor NETEZZA
+
+
+
+
+
+ +

+ORACLE

+
+public static final DatabaseVendor ORACLE
+
+
+
+
+
+ +

+PERVASIVE

+
+public static final DatabaseVendor PERVASIVE
+
+
+
+
+
+ +

+POINTBASE

+
+public static final DatabaseVendor POINTBASE
+
+
+
+
+
+ +

+POSTGRESQL

+
+public static final DatabaseVendor POSTGRESQL
+
+
+
+
+
+ +

+SQLSERVER

+
+public static final DatabaseVendor SQLSERVER
+
+
+
+
+
+ +

+SQLITE

+
+public static final DatabaseVendor SQLITE
+
+
+
+
+
+ +

+SYBASE

+
+public static final DatabaseVendor SYBASE
+
+
+
+
+
+ +

+TERADATA

+
+public static final DatabaseVendor TERADATA
+
+
+
+
+
+ +

+VERTICA

+
+public static final DatabaseVendor VERTICA
+
+
+
+
+
+ +

+CASSANDRA

+
+public static final DatabaseVendor CASSANDRA
+
+
+
+
+
+ +

+H2

+
+public static final DatabaseVendor H2
+
+
+
+
+
+ +

+COLDFUSION_IMQ

+
+public static final DatabaseVendor COLDFUSION_IMQ
+
+
+
+
+
+ +

+REDSHIFT

+
+public static final DatabaseVendor REDSHIFT
+
+
+
+
+
+ +

+COUCHBASE

+
+public static final DatabaseVendor COUCHBASE
+
+
+
+
+ + + + + + + + +
+Method Detail
+ +

+values

+
+public static DatabaseVendor[] values()
+
+
Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
+for (DatabaseVendor c : DatabaseVendor.values())
+    System.out.println(c);
+
+

+

+ +
Returns:
an array containing the constants of this enum type, in +the order they are declared
+
+
+
+ +

+valueOf

+
+public static DatabaseVendor valueOf(java.lang.String name)
+
+
Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.) +

+

+
Parameters:
name - the name of the enum constant to be returned. +
Returns:
the enum constant with the specified name +
Throws: +
java.lang.IllegalArgumentException - if this enum type has no constant +with the specified name +
java.lang.NullPointerException - if the argument is null
+
+
+
+ +

+getVendorName

+
+public java.lang.String getVendorName()
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Enum<DatabaseVendor>
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.html b/docs/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.html new file mode 100755 index 0000000..cf4b5d4 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.html @@ -0,0 +1,348 @@ + + + + + + +MessageDestinationType (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.enums +
+Enum MessageDestinationType

+
+java.lang.Object
+  extended by java.lang.Enum<MessageDestinationType>
+      extended by com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType
+
+
+
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<MessageDestinationType>
+
+
+
+
public enum MessageDestinationType
extends java.lang.Enum<MessageDestinationType>
+ + +

+Enumerates all well-known messaging destination types. See + OneAgentSDK.createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String) +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ + + + + + + + + + + + + +
+Enum Constant Summary
QUEUE + +
+           
TOPIC + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetName() + +
+           
+static MessageDestinationTypevalueOf(java.lang.String name) + +
+          Returns the enum constant of this type with the specified name.
+static MessageDestinationType[]values() + +
+          Returns an array containing the constants of this enum type, in +the order they are declared.
+ + + + + + + +
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
+ + + + + + + +
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Enum Constant Detail
+ +

+QUEUE

+
+public static final MessageDestinationType QUEUE
+
+
+
+
+
+ +

+TOPIC

+
+public static final MessageDestinationType TOPIC
+
+
+
+
+ + + + + + + + +
+Method Detail
+ +

+values

+
+public static MessageDestinationType[] values()
+
+
Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
+for (MessageDestinationType c : MessageDestinationType.values())
+    System.out.println(c);
+
+

+

+ +
Returns:
an array containing the constants of this enum type, in +the order they are declared
+
+
+
+ +

+valueOf

+
+public static MessageDestinationType valueOf(java.lang.String name)
+
+
Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.) +

+

+
Parameters:
name - the name of the enum constant to be returned. +
Returns:
the enum constant with the specified name +
Throws: +
java.lang.IllegalArgumentException - if this enum type has no constant +with the specified name +
java.lang.NullPointerException - if the argument is null
+
+
+
+ +

+getName

+
+public java.lang.String getName()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.html b/docs/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.html new file mode 100755 index 0000000..98fa96a --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.html @@ -0,0 +1,466 @@ + + + + + + +MessageSystemVendor (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.enums +
+Enum MessageSystemVendor

+
+java.lang.Object
+  extended by java.lang.Enum<MessageSystemVendor>
+      extended by com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor
+
+
+
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<MessageSystemVendor>
+
+
+
+
public enum MessageSystemVendor
extends java.lang.Enum<MessageSystemVendor>
+ + +

+Enumerates all well-known messaging systems. See OneAgentSDK.createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String). + Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Enum Constant Summary
ACTIVE_MQ + +
+           
ARTEMIS + +
+           
HORNETQ + +
+           
MQSERIES + +
+           
MQSERIES_JMS + +
+           
RABBIT_MQ + +
+           
TIBCO + +
+           
WEBSPHERE + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetVendorName() + +
+           
+ java.lang.StringtoString() + +
+           
+static MessageSystemVendorvalueOf(java.lang.String name) + +
+          Returns the enum constant of this type with the specified name.
+static MessageSystemVendor[]values() + +
+          Returns an array containing the constants of this enum type, in +the order they are declared.
+ + + + + + + +
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
+ + + + + + + +
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Enum Constant Detail
+ +

+HORNETQ

+
+public static final MessageSystemVendor HORNETQ
+
+
+
+
+
+ +

+ACTIVE_MQ

+
+public static final MessageSystemVendor ACTIVE_MQ
+
+
+
+
+
+ +

+RABBIT_MQ

+
+public static final MessageSystemVendor RABBIT_MQ
+
+
+
+
+
+ +

+ARTEMIS

+
+public static final MessageSystemVendor ARTEMIS
+
+
+
+
+
+ +

+WEBSPHERE

+
+public static final MessageSystemVendor WEBSPHERE
+
+
+
+
+
+ +

+MQSERIES_JMS

+
+public static final MessageSystemVendor MQSERIES_JMS
+
+
+
+
+
+ +

+MQSERIES

+
+public static final MessageSystemVendor MQSERIES
+
+
+
+
+
+ +

+TIBCO

+
+public static final MessageSystemVendor TIBCO
+
+
+
+
+ + + + + + + + +
+Method Detail
+ +

+values

+
+public static MessageSystemVendor[] values()
+
+
Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
+for (MessageSystemVendor c : MessageSystemVendor.values())
+    System.out.println(c);
+
+

+

+ +
Returns:
an array containing the constants of this enum type, in +the order they are declared
+
+
+
+ +

+valueOf

+
+public static MessageSystemVendor valueOf(java.lang.String name)
+
+
Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.) +

+

+
Parameters:
name - the name of the enum constant to be returned. +
Returns:
the enum constant with the specified name +
Throws: +
java.lang.IllegalArgumentException - if this enum type has no constant +with the specified name +
java.lang.NullPointerException - if the argument is null
+
+
+
+ +

+getVendorName

+
+public java.lang.String getVendorName()
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Enum<MessageSystemVendor>
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/SDKState.html b/docs/com/dynatrace/oneagent/sdk/api/enums/SDKState.html new file mode 100755 index 0000000..34b6376 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/SDKState.html @@ -0,0 +1,357 @@ + + + + + + +SDKState (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.enums +
+Enum SDKState

+
+java.lang.Object
+  extended by java.lang.Enum<SDKState>
+      extended by com.dynatrace.oneagent.sdk.api.enums.SDKState
+
+
+
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<SDKState>
+
+
+
+
public enum SDKState
extends java.lang.Enum<SDKState>
+ + +

+Defines the possible states of the SDK. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + +
+Enum Constant Summary
ACTIVE + +
+          SDK is connected to OneAgent and capturing data.
PERMANENTLY_INACTIVE + +
+          SDK isn't connected to OneAgent, so it will never capture data.
TEMPORARILY_INACTIVE + +
+          SDK is connected to OneAgent, but capturing is disabled.It is good practice + to skip creating SDK transactions to save resources.
+  + + + + + + + + + + + + + + + +
+Method Summary
+static SDKStatevalueOf(java.lang.String name) + +
+          Returns the enum constant of this type with the specified name.
+static SDKState[]values() + +
+          Returns an array containing the constants of this enum type, in +the order they are declared.
+ + + + + + + +
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
+ + + + + + + +
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Enum Constant Detail
+ +

+ACTIVE

+
+public static final SDKState ACTIVE
+
+
SDK is connected to OneAgent and capturing data. +

+

+
Since:
+
1.0
+
+
+
+ +

+TEMPORARILY_INACTIVE

+
+public static final SDKState TEMPORARILY_INACTIVE
+
+
SDK is connected to OneAgent, but capturing is disabled.It is good practice + to skip creating SDK transactions to save resources. The SDK state should be + checked regularly as it may change at every point in time. +

+

+
Since:
+
1.0
+
+
+
+ +

+PERMANENTLY_INACTIVE

+
+public static final SDKState PERMANENTLY_INACTIVE
+
+
SDK isn't connected to OneAgent, so it will never capture data. This SDK + state will never change during the lifetime of a JVM. It is good practice to + never call any SDK API to save resources. +

+

+
Since:
+
1.0
+
+
+ + + + + + + + +
+Method Detail
+ +

+values

+
+public static SDKState[] values()
+
+
Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
+for (SDKState c : SDKState.values())
+    System.out.println(c);
+
+

+

+ +
Returns:
an array containing the constants of this enum type, in +the order they are declared
+
+
+
+ +

+valueOf

+
+public static SDKState valueOf(java.lang.String name)
+
+
Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.) +

+

+
Parameters:
name - the name of the enum constant to be returned. +
Returns:
the enum constant with the specified name +
Throws: +
java.lang.IllegalArgumentException - if this enum type has no constant +with the specified name +
java.lang.NullPointerException - if the argument is null
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/package-frame.html b/docs/com/dynatrace/oneagent/sdk/api/enums/package-frame.html new file mode 100755 index 0000000..2ccf664 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/package-frame.html @@ -0,0 +1,40 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.enums (sdk 1.9.0 API) + + + + + + + + + + + +com.dynatrace.oneagent.sdk.api.enums + + + + +
+Enums  + +
+ChannelType +
+DatabaseVendor +
+MessageDestinationType +
+MessageSystemVendor +
+SDKState
+ + + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/package-summary.html b/docs/com/dynatrace/oneagent/sdk/api/enums/package-summary.html new file mode 100755 index 0000000..194e4ba --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/package-summary.html @@ -0,0 +1,171 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.enums (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.dynatrace.oneagent.sdk.api.enums +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Enum Summary
ChannelTypeDefines the type of communication channel being used.
DatabaseVendorEnumerates all well-known database vendors.
MessageDestinationTypeEnumerates all well-known messaging destination types.
MessageSystemVendorEnumerates all well-known messaging systems.
SDKStateDefines the possible states of the SDK.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/enums/package-tree.html b/docs/com/dynatrace/oneagent/sdk/api/enums/package-tree.html new file mode 100755 index 0000000..cd92fbc --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/enums/package-tree.html @@ -0,0 +1,154 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.enums Class Hierarchy (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.dynatrace.oneagent.sdk.api.enums +

+
+
+
Package Hierarchies:
All Packages
+
+

+Enum Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.html b/docs/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.html new file mode 100755 index 0000000..5c10c54 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.html @@ -0,0 +1,174 @@ + + + + + + +DatabaseInfo (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.infos +
+Interface DatabaseInfo

+
+
+
public interface DatabaseInfo
+ + +

+Type returned by OneAgentSDK.createDatabaseInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String) +

+ +

+

+
Since:
+
1.7.0
+
+
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.html b/docs/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.html new file mode 100755 index 0000000..813c5e0 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.html @@ -0,0 +1,174 @@ + + + + + + +MessagingSystemInfo (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.infos +
+Interface MessagingSystemInfo

+
+
+
public interface MessagingSystemInfo
+ + +

+Type returned by OneAgentSDK.createMessagingSystemInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String) +

+ +

+

+
Since:
+
1.5
+
+
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.html b/docs/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.html new file mode 100644 index 0000000..8abd244 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.html @@ -0,0 +1,327 @@ + + + + + + +TraceContextInfo (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.infos +
+Interface TraceContextInfo

+
+
+
public interface TraceContextInfo
+ + +

+Provides information about a PurePath node using the TraceContext (Trace-Id, Span-Id) model as defined in + + + + + + + + + + + + + +
+Field Summary
+static java.lang.StringINVALID_SPAN_ID + +
+          All-zero (invalid) W3C span ID.
+static java.lang.StringINVALID_TRACE_ID + +
+          All-zero (invalid) W3C trace ID.
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetSpanId() + +
+          The W3C span ID hex string (never empty or null, but might be all-zero if isValid()) is false)
+ java.lang.StringgetTraceId() + +
+          The W3C trace ID hex string (never empty or null, but might be all-zero if isValid()) is false)
+ booleanisValid() + +
+          If true, the trace & span ID are both valid (i.e., non-zero).
+  +

+ + + + + + + + +
+Field Detail
+ +

+INVALID_TRACE_ID

+
+static final java.lang.String INVALID_TRACE_ID
+
+
All-zero (invalid) W3C trace ID. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INVALID_SPAN_ID

+
+static final java.lang.String INVALID_SPAN_ID
+
+
All-zero (invalid) W3C span ID. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Method Detail
+ +

+isValid

+
+boolean isValid()
+
+
If true, the trace & span ID are both valid (i.e., non-zero). + +

These are a few common reasons for why you may be unable to get a valid trace context:

+

+

+

+
+
+
+
+ +

+getTraceId

+
+java.lang.String getTraceId()
+
+
The W3C trace ID hex string (never empty or null, but might be all-zero if isValid()) is false) +

+

+
+
+
+
+ +

+getSpanId

+
+java.lang.String getSpanId()
+
+
The W3C span ID hex string (never empty or null, but might be all-zero if isValid()) is false) +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.html b/docs/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.html new file mode 100755 index 0000000..d54241e --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.html @@ -0,0 +1,175 @@ + + + + + + +WebApplicationInfo (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.dynatrace.oneagent.sdk.api.infos +
+Interface WebApplicationInfo

+
+
+
public interface WebApplicationInfo
+ + +

+Type returned by + OneAgentSDK.createWebApplicationInfo(String, String, String) +

+ +

+

+
Since:
+
1.3
+
+
+ +

+ +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/package-frame.html b/docs/com/dynatrace/oneagent/sdk/api/infos/package-frame.html new file mode 100755 index 0000000..263f386 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/package-frame.html @@ -0,0 +1,38 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.infos (sdk 1.9.0 API) + + + + + + + + + + + +com.dynatrace.oneagent.sdk.api.infos + + + + +
+Interfaces  + +
+DatabaseInfo +
+MessagingSystemInfo +
+TraceContextInfo +
+WebApplicationInfo
+ + + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/package-summary.html b/docs/com/dynatrace/oneagent/sdk/api/infos/package-summary.html new file mode 100755 index 0000000..eb3c133 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/package-summary.html @@ -0,0 +1,169 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.infos (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.dynatrace.oneagent.sdk.api.infos +

+ + + + + + + + + + + + + + + + + + +
+Interface Summary
DatabaseInfoType returned by OneAgentSDK.createDatabaseInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)
MessagingSystemInfoType returned by OneAgentSDK.createMessagingSystemInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)
TraceContextInfoProvides information about a PurePath node using the TraceContext (Trace-Id, Span-Id) model as defined in + +WebApplicationInfoType returned by + OneAgentSDK.createWebApplicationInfo(String, String, String)
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/infos/package-tree.html b/docs/com/dynatrace/oneagent/sdk/api/infos/package-tree.html new file mode 100755 index 0000000..0040413 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/infos/package-tree.html @@ -0,0 +1,149 @@ + + + + + + +com.dynatrace.oneagent.sdk.api.infos Class Hierarchy (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.dynatrace.oneagent.sdk.api.infos +

+
+
+
Package Hierarchies:
All Packages
+
+

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/package-frame.html b/docs/com/dynatrace/oneagent/sdk/api/package-frame.html new file mode 100755 index 0000000..29abaa3 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/package-frame.html @@ -0,0 +1,62 @@ + + + + + + +com.dynatrace.oneagent.sdk.api (sdk 1.9.0 API) + + + + + + + + + + + +com.dynatrace.oneagent.sdk.api + + + + +
+Interfaces  + +
+CustomServiceTracer +
+DatabaseRequestTracer +
+IncomingMessageProcessTracer +
+IncomingMessageReceiveTracer +
+IncomingRemoteCallTracer +
+IncomingTaggable +
+IncomingWebRequestTracer +
+InProcessLink +
+InProcessLinkTracer +
+LoggingCallback +
+OneAgentSDK +
+OutgoingMessageTracer +
+OutgoingRemoteCallTracer +
+OutgoingTaggable +
+OutgoingWebRequestTracer +
+Tracer
+ + + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/package-summary.html b/docs/com/dynatrace/oneagent/sdk/api/package-summary.html new file mode 100755 index 0000000..b5be375 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/package-summary.html @@ -0,0 +1,216 @@ + + + + + + +com.dynatrace.oneagent.sdk.api (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.dynatrace.oneagent.sdk.api +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Interface Summary
CustomServiceTracerInterface for tracing custom services.
DatabaseRequestTracerInterface for outgoing database tracer.
IncomingMessageProcessTracerInterface for processing message tracer.
IncomingMessageReceiveTracerInterface for receiving message tracer.
IncomingRemoteCallTracerRepresents the server side of a remote call.
IncomingTaggableCommon interface for server-tagging-related methods.
IncomingWebRequestTracerInterface for incoming webrequest tracer.
InProcessLinkRepresents link used for in-process-tagging.
InProcessLinkTracerTracer used to trace in-process-linking.
LoggingCallbackLoggingCallback gets called only inside a OneAgentSDK API call when an + error/warning has occurred.
OneAgentSDKRoot interface contains provided Agent SDK API calls.
OutgoingMessageTracerInterface for outgoing message tracer.
OutgoingRemoteCallTracerRepresents the client side of a remote call.
OutgoingTaggableCommon interface for client-tagging-related methods.
OutgoingWebRequestTracerRepresents client side of an outgoing webrequest.
TracerCommon interface for timing-related methods.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/api/package-tree.html b/docs/com/dynatrace/oneagent/sdk/api/package-tree.html new file mode 100755 index 0000000..159a1ce --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/api/package-tree.html @@ -0,0 +1,167 @@ + + + + + + +com.dynatrace.oneagent.sdk.api Class Hierarchy (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.dynatrace.oneagent.sdk.api +

+
+
+
Package Hierarchies:
All Packages
+
+

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/package-frame.html b/docs/com/dynatrace/oneagent/sdk/package-frame.html new file mode 100755 index 0000000..0850ac5 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/package-frame.html @@ -0,0 +1,32 @@ + + + + + + +com.dynatrace.oneagent.sdk (sdk 1.9.0 API) + + + + + + + + + + + +com.dynatrace.oneagent.sdk + + + + +
+Classes  + +
+OneAgentSDKFactory
+ + + + diff --git a/docs/com/dynatrace/oneagent/sdk/package-summary.html b/docs/com/dynatrace/oneagent/sdk/package-summary.html new file mode 100755 index 0000000..bcaa16c --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/package-summary.html @@ -0,0 +1,155 @@ + + + + + + +com.dynatrace.oneagent.sdk (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.dynatrace.oneagent.sdk +

+ + + + + + + + + +
+Class Summary
OneAgentSDKFactoryEntry point for customer application.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/dynatrace/oneagent/sdk/package-tree.html b/docs/com/dynatrace/oneagent/sdk/package-tree.html new file mode 100755 index 0000000..ca75b99 --- /dev/null +++ b/docs/com/dynatrace/oneagent/sdk/package-tree.html @@ -0,0 +1,151 @@ + + + + + + +com.dynatrace.oneagent.sdk Class Hierarchy (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.dynatrace.oneagent.sdk +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/constant-values.html b/docs/constant-values.html new file mode 100755 index 0000000..33bc4a7 --- /dev/null +++ b/docs/constant-values.html @@ -0,0 +1,202 @@ + + + + + + +Constant Field Values (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+com.dynatrace.*
+ +

+ + + + + + + + + + + + + + + + + +
com.dynatrace.oneagent.sdk.api.OneAgentSDK
+public static final java.lang.StringDYNATRACE_HTTP_HEADERNAME"X-dynaTrace"
+public static final java.lang.StringDYNATRACE_MESSAGE_PROPERTYNAME"dtdTraceTagInfo"
+ +

+ +

+ + + + + + + + + + + + + + + + + +
com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo
+public static final java.lang.StringINVALID_SPAN_ID"0000000000000000"
+public static final java.lang.StringINVALID_TRACE_ID"00000000000000000000000000000000"
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/deprecated-list.html b/docs/deprecated-list.html new file mode 100755 index 0000000..1139736 --- /dev/null +++ b/docs/deprecated-list.html @@ -0,0 +1,144 @@ + + + + + + +Deprecated List (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents
    +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/help-doc.html b/docs/help-doc.html new file mode 100755 index 0000000..db6c54b --- /dev/null +++ b/docs/help-doc.html @@ -0,0 +1,217 @@ + + + + + + +API Help (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Overview

+
+ +

+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    +
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description +

    +

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary +

    +

  • Field Detail
  • Constructor Detail
  • Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

    +
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

    +
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    +
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/index-all.html b/docs/index-all.html new file mode 100755 index 0000000..db6c040 --- /dev/null +++ b/docs/index-all.html @@ -0,0 +1,431 @@ + + + + + + +Index (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A C D E G I L M O S T V W
+

+A

+
+
addCustomRequestAttribute(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Adds a custom request attribute to currently traced service call. +
addCustomRequestAttribute(String, long) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Does exactly the same as OneAgentSDK.addCustomRequestAttribute(String, String), + but request-attribute type long. +
addCustomRequestAttribute(String, double) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Does exactly the same as OneAgentSDK.addCustomRequestAttribute(String, String), + but request-attribute type double. +
addParameter(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer +
All HTTP parameters should be provided to this method. +
addRequestHeader(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer +
All HTTP request headers should be provided to this method. +
addRequestHeader(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer +
All HTTP request headers should be provided to this method. +
addResponseHeader(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer +
All HTTP response headers should be provided to this method. +
addResponseHeader(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer +
All HTTP response headers returned by the server should be provided to this + method. +
+
+

+C

+
+
ChannelType - Enum in com.dynatrace.oneagent.sdk.api.enums
Defines the type of communication channel being used.
com.dynatrace.oneagent.sdk - package com.dynatrace.oneagent.sdk
 
com.dynatrace.oneagent.sdk.api - package com.dynatrace.oneagent.sdk.api
 
com.dynatrace.oneagent.sdk.api.enums - package com.dynatrace.oneagent.sdk.api.enums
 
com.dynatrace.oneagent.sdk.api.infos - package com.dynatrace.oneagent.sdk.api.infos
 
createDatabaseInfo(String, String, ChannelType, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Initializes a DatabaseInfo instance that is required for tracing database requests. +
createInProcessLink() - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a link for in-process-linking. +
createInstance() - +Static method in class com.dynatrace.oneagent.sdk.OneAgentSDKFactory +
Provides a OneAgentSDK instance, that has to be used to create + transactions. +
createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Initializes a MessagingSystemInfo instance that is required for tracing messages. +
createWebApplicationInfo(String, String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Initializes a WebApplicationInfo instance that is required for tracing + incoming web requests. +
CustomServiceTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for tracing custom services.
+
+

+D

+
+
DatabaseInfo - Interface in com.dynatrace.oneagent.sdk.api.infos
Type returned by OneAgentSDK.createDatabaseInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)
DatabaseRequestTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for outgoing database tracer.
DatabaseVendor - Enum in com.dynatrace.oneagent.sdk.api.enums
Enumerates all well-known database vendors.
DYNATRACE_HTTP_HEADERNAME - +Static variable in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Using this headername to transport Dynatrace tag inside an outgoing http + request ensures compatibility to Dynatrace built-in sensors. +
DYNATRACE_MESSAGE_PROPERTYNAME - +Static variable in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Using this propertyname to transport Dynatrace tag along with the message, ensures compatibility to Dynatrace built-in sensors. +
+
+

+E

+
+
end() - +Method in interface com.dynatrace.oneagent.sdk.api.Tracer +
Ends timing of a node. +
error(String) - +Method in interface com.dynatrace.oneagent.sdk.api.LoggingCallback +
Something that should be done can't be done. +
error(String) - +Method in interface com.dynatrace.oneagent.sdk.api.Tracer +
Marks the node as 'exited by exception'. +
error(Throwable) - +Method in interface com.dynatrace.oneagent.sdk.api.Tracer +
Marks the node as 'exited by exception'.Additional information can be + provided as Throwable. +
+
+

+G

+
+
getCurrentState() - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Returns the current SDKState. +
getDynatraceByteTag() - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingTaggable +
Same as OutgoingTaggable.getDynatraceStringTag(), but returning the tag as binary + representation. +
getDynatraceStringTag() - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingTaggable +
Creates a Dynatrace tag and returns the String representation of it. +
getName() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType +
  +
getSDKConstant() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.ChannelType +
  +
getSpanId() - +Method in interface com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo +
The W3C span ID hex string (never empty or null, but might be all-zero if TraceContextInfo.isValid()) is false) +
getTraceContextInfo() - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Returns the current W3C trace context for log enrichment + (not meant for tagging and context-propagation but for log-enrichment). +
getTraceId() - +Method in interface com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo +
The W3C trace ID hex string (never empty or null, but might be all-zero if TraceContextInfo.isValid()) is false) +
getVendorName() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor +
  +
getVendorName() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor +
  +
+
+

+I

+
+
IncomingMessageProcessTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for processing message tracer.
IncomingMessageReceiveTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for receiving message tracer.
IncomingRemoteCallTracer - Interface in com.dynatrace.oneagent.sdk.api
Represents the server side of a remote call.
IncomingTaggable - Interface in com.dynatrace.oneagent.sdk.api
Common interface for server-tagging-related methods.
IncomingWebRequestTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for incoming webrequest tracer.
InProcessLink - Interface in com.dynatrace.oneagent.sdk.api
Represents link used for in-process-tagging.
InProcessLinkTracer - Interface in com.dynatrace.oneagent.sdk.api
Tracer used to trace in-process-linking.
INVALID_SPAN_ID - +Static variable in interface com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo +
All-zero (invalid) W3C span ID. +
INVALID_TRACE_ID - +Static variable in interface com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo +
All-zero (invalid) W3C trace ID. +
isValid() - +Method in interface com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo +
If true, the trace & span ID are both valid (i.e., non-zero). +
+
+

+L

+
+
LoggingCallback - Interface in com.dynatrace.oneagent.sdk.api
LoggingCallback gets called only inside a OneAgentSDK API call when an + error/warning has occurred.
+
+

+M

+
+
MessageDestinationType - Enum in com.dynatrace.oneagent.sdk.api.enums
Enumerates all well-known messaging destination types.
MessageSystemVendor - Enum in com.dynatrace.oneagent.sdk.api.enums
Enumerates all well-known messaging systems.
MessagingSystemInfo - Interface in com.dynatrace.oneagent.sdk.api.infos
Type returned by OneAgentSDK.createMessagingSystemInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)
+
+

+O

+
+
OneAgentSDK - Interface in com.dynatrace.oneagent.sdk.api
Root interface contains provided Agent SDK API calls.
OneAgentSDKFactory - Class in com.dynatrace.oneagent.sdk
Entry point for customer application.
OneAgentSDKFactory() - +Constructor for class com.dynatrace.oneagent.sdk.OneAgentSDKFactory +
  +
OutgoingMessageTracer - Interface in com.dynatrace.oneagent.sdk.api
Interface for outgoing message tracer.
OutgoingRemoteCallTracer - Interface in com.dynatrace.oneagent.sdk.api
Represents the client side of a remote call.
OutgoingTaggable - Interface in com.dynatrace.oneagent.sdk.api
Common interface for client-tagging-related methods.
OutgoingWebRequestTracer - Interface in com.dynatrace.oneagent.sdk.api
Represents client side of an outgoing webrequest.
+
+

+S

+
+
SDKState - Enum in com.dynatrace.oneagent.sdk.api.enums
Defines the possible states of the SDK.
setCorrelationId(String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer +
Adds optional information about a traced message: correlation id used by messaging system. +
setCorrelationId(String) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer +
Adds optional information about a traced message: correlation id used by messaging system. +
setDynatraceByteTag(byte[]) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingTaggable +
Same as IncomingTaggable.setDynatraceStringTag(String) but consumes binary + representation of tag. +
setDynatraceStringTag(String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingTaggable +
Consumes a tag to continue a pure path. +
setLoggingCallback(LoggingCallback) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Installs a callback that gets informed, if any SDK action has failed. +
setProtocolName(String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer +
Sets the name of the used remoting protocol. +
setProtocolName(String) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer +
Sets the name of the used remoting protocol. +
setRemoteAddress(String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer +
Validates and sets the remote IP address of the incoming web request. +
setReturnedRowCount(int) - +Method in interface com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer +
Adds optional information about retrieved rows of the traced database request. +
setRoundTripCount(int) - +Method in interface com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer +
Adds optional information about round-trip count to database server. +
setStatusCode(int) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer +
Sets the HTTP response status code. +
setStatusCode(int) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer +
Sets the HTTP response status code. +
setVendorMessageId(String) - +Method in interface com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer +
Adds optional information about a traced message: message id provided by messaging system. +
setVendorMessageId(String) - +Method in interface com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer +
Adds optional information about a traced message: message id provided by messaging system. +
start() - +Method in interface com.dynatrace.oneagent.sdk.api.Tracer +
starts timing of a node. +
+
+

+T

+
+
toString() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor +
  +
toString() - +Method in enum com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor +
  +
TraceContextInfo - Interface in com.dynatrace.oneagent.sdk.api.infos
Provides information about a PurePath node using the TraceContext (Trace-Id, Span-Id) model as defined in + traceCustomService(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a tracer for a custom transaction (Dynatrace calls them Custom service). +
traceIncomingMessageProcess(MessagingSystemInfo) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a tracer for processing (consuming) a received message (onMessage). +
traceIncomingMessageReceive(MessagingSystemInfo) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a tracer for an incoming asynchronous message (blocking receive). +
traceIncomingRemoteCall(String, String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Traces an incoming remote call. +
traceIncomingWebRequest(WebApplicationInfo, String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Traces an incoming web request. +
traceInProcessLink(InProcessLink) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Traces the start of in-process-linking. +
traceOutgoingMessage(MessagingSystemInfo) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a tracer for an outgoing asynchronous message (send). +
traceOutgoingRemoteCall(String, String, String, ChannelType, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Traces an outgoing remote call. +
traceOutgoingWebRequest(String, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Traces an outgoing web request. +
Tracer - Interface in com.dynatrace.oneagent.sdk.api
Common interface for timing-related methods.
traceSqlDatabaseRequest(DatabaseInfo, String) - +Method in interface com.dynatrace.oneagent.sdk.api.OneAgentSDK +
Creates a tracer for tracing outgoing SQL database requests. +
+
+

+V

+
+
valueOf(String) - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.ChannelType +
Returns the enum constant of this type with the specified name. +
valueOf(String) - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor +
Returns the enum constant of this type with the specified name. +
valueOf(String) - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType +
Returns the enum constant of this type with the specified name. +
valueOf(String) - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor +
Returns the enum constant of this type with the specified name. +
valueOf(String) - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.SDKState +
Returns the enum constant of this type with the specified name. +
values() - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.ChannelType +
Returns an array containing the constants of this enum type, in +the order they are declared. +
values() - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor +
Returns an array containing the constants of this enum type, in +the order they are declared. +
values() - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType +
Returns an array containing the constants of this enum type, in +the order they are declared. +
values() - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor +
Returns an array containing the constants of this enum type, in +the order they are declared. +
values() - +Static method in enum com.dynatrace.oneagent.sdk.api.enums.SDKState +
Returns an array containing the constants of this enum type, in +the order they are declared. +
+
+

+W

+
+
warn(String) - +Method in interface com.dynatrace.oneagent.sdk.api.LoggingCallback +
Just a warning. +
WebApplicationInfo - Interface in com.dynatrace.oneagent.sdk.api.infos
Type returned by + OneAgentSDK.createWebApplicationInfo(String, String, String)
+
+A C D E G I L M O S T V W + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/index.html b/docs/index.html new file mode 100755 index 0000000..17f39e0 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,73 @@ + + + + + + +sdk 1.9.0 API + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +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. +<BR> +Link to<A HREF="overview-summary.html">Non-frame version.</A> + + + diff --git a/docs/overview-frame.html b/docs/overview-frame.html new file mode 100755 index 0000000..1c3cd38 --- /dev/null +++ b/docs/overview-frame.html @@ -0,0 +1,48 @@ + + + + + + +Overview List (sdk 1.9.0 API) + + + + + + + + + + + + + + + +
+
+ + + + + +
All Classes +

+ +Packages +
+com.dynatrace.oneagent.sdk +
+com.dynatrace.oneagent.sdk.api +
+com.dynatrace.oneagent.sdk.api.enums +
+com.dynatrace.oneagent.sdk.api.infos +
+

+ +

+  + + diff --git a/docs/overview-summary.html b/docs/overview-summary.html new file mode 100755 index 0000000..e905b6d --- /dev/null +++ b/docs/overview-summary.html @@ -0,0 +1,166 @@ + + + + + + +Overview (sdk 1.9.0 API) + + + + + + + + + + + + +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+sdk 1.9.0 API +

+
+ + + + + + + + + + + + + + + + + + + + + +
+Packages
com.dynatrace.oneagent.sdk 
com.dynatrace.oneagent.sdk.api 
com.dynatrace.oneagent.sdk.api.enums 
com.dynatrace.oneagent.sdk.api.infos 
+ +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/overview-tree.html b/docs/overview-tree.html new file mode 100755 index 0000000..ede1da8 --- /dev/null +++ b/docs/overview-tree.html @@ -0,0 +1,183 @@ + + + + + + +Class Hierarchy (sdk 1.9.0 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
com.dynatrace.oneagent.sdk, com.dynatrace.oneagent.sdk.api, com.dynatrace.oneagent.sdk.api.enums, com.dynatrace.oneagent.sdk.api.infos
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +

+Enum Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/package-list b/docs/package-list new file mode 100755 index 0000000..ebefb0a --- /dev/null +++ b/docs/package-list @@ -0,0 +1,4 @@ +com.dynatrace.oneagent.sdk +com.dynatrace.oneagent.sdk.api +com.dynatrace.oneagent.sdk.api.enums +com.dynatrace.oneagent.sdk.api.infos diff --git a/docs/resources/inherit.gif b/docs/resources/inherit.gif new file mode 100755 index 0000000..c814867 Binary files /dev/null and b/docs/resources/inherit.gif differ diff --git a/docs/stylesheet.css b/docs/stylesheet.css new file mode 100755 index 0000000..6ea9e51 --- /dev/null +++ b/docs/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/samples/README.md b/samples/README.md index 889427b..029f30b 100644 --- a/samples/README.md +++ b/samples/README.md @@ -1,10 +1,14 @@ -# Sample applications for OneAgent SDK for Java +# Sample applications for OneAgent SDK for Java Sample applications showing how to use Dynatrace OneAgent SDK for Java to create custom specific PurePaths and service calls. ## Contents - `remotecall`: shows usage of remote call API. Allows you to tag remote calls in the same or between different JVMs. +- `in-process-linking`: shows usage of in-process-linking API. Allows you to tag eg. asynchronous execution inside the same process. +- `webrequest`: shows usage of outgoing and incoming web request tracing +- `messaging`: shows usage of messaging +- `database`: shows usage of database request tracing ## Build and prepare running sample applications @@ -14,10 +18,50 @@ Sample applications showing how to use Dynatrace OneAgent SDK for Java to create - run `mvn package` in root directory of the desired sample ### Run RemoteCall sample application + 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. - Server: `mvn -pl remotecall-server exec:exec` - Client: `mvn -pl remotecall-client exec:exec` -Check your Dynatrace environment for newly created services. \ No newline at end of file +Check your Dynatrace environment for newly created service like that: +![remotecall-server](img/remotecall-service.png) + +### Run InProcessLinking sample application + +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. + +- ensure you have custom service for method `startAsyncOperation` in class `com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp` +- run sample: `mvn exec:exec` + +Check your Dynatrace environment for newly created services like that: +![in-process-linking-service](img/in-process-linking-service.png) + +### Run WebRequest sample application + +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: + +- run sample: `mvn exec:exec` + +### Run Messaging sample application + +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: + +- run sample: `mvn exec:exec` + +### Run DatabaseRequest sample application + +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: + +- run sample: `mvn exec:exec` + +To run this sample you need to create a custom service for your tenant. See source of sample app for details. + +### Run custom service sample application + +This Application shows how to trace a custom service. +To run this sample, go into the sample directory and run the sample by typing: + +- run sample: `mvn exec:exec` + diff --git a/samples/custom-service/pom.xml b/samples/custom-service/pom.xml new file mode 100644 index 0000000..2963ce5 --- /dev/null +++ b/samples/custom-service/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + com.dynatrace.oneagent.sdk.samples.customservice + custom-service-sample + 1.8.0 + jar + + + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.8.0 + compile + + + + https://github.com/Dynatrace/OneAgent-SDK-Java + Dynatrace OneAgent SDK Java custom service sample + + Dynatrace + http://www.dynatrace.com + + + + 1.6 + 1.6 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + com.dynatrace.oneagent.sdk.samples.customservice.CustomServiceApp + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + exec + + + + + java + + ${agent.agentpath} + -classpath + + com.dynatrace.oneagent.sdk.samples.customservice.CustomServiceApp + + + + + + + diff --git a/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/CustomServiceApp.java b/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/CustomServiceApp.java new file mode 100644 index 0000000..a300515 --- /dev/null +++ b/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/CustomServiceApp.java @@ -0,0 +1,77 @@ +package com.dynatrace.oneagent.sdk.samples.customservice; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Sample application that shows how a custom service should be traced. + * + * @author wolfgang.ziegler@dynatrace.com + * + */ +public class CustomServiceApp { + + private final OneAgentSDK oneAgentSdk; + + static CustomServiceApp instance; + + private CustomServiceApp() { + oneAgentSdk = OneAgentSDKFactory.createInstance(); + oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); + switch (oneAgentSdk.getCurrentState()) { + case ACTIVE: + System.out.println("SDK is active and capturing."); + break; + case PERMANENTLY_INACTIVE: + System.err.println( + "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); + break; + case TEMPORARILY_INACTIVE: + System.err.println( + "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + break; + default: + System.err.println("SDK is in unknown state."); + break; + } + instance = this; + } + + public static void main(String args[]) { + System.out.println("*************************************************************"); + System.out.println("** Running custom service request sample **"); + System.out.println("*************************************************************"); + try { + CustomServiceApp app = new CustomServiceApp(); + + app.traceCustomService(); + + System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); + Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server + } catch (Exception e) { + System.err.println("custom service request sample failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + } + + private void traceCustomService() throws Exception { + String serviceMethod = "onTimer"; + String serviceName = "PeriodicCleanupTask"; + CustomServiceTracer tracer = oneAgentSdk.traceCustomService(serviceMethod, serviceName); + tracer.start(); + try { + doOtherThings(); + } catch (Exception e) { + tracer.error(e.getMessage()); + throw e; + } finally { + tracer.end(); + } + } + + private void doOtherThings() { + // ... + } +} diff --git a/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/StdErrLoggingCallback.java b/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/StdErrLoggingCallback.java new file mode 100644 index 0000000..58d5080 --- /dev/null +++ b/samples/custom-service/src/main/java/com/dynatrace/oneagent/sdk/samples/customservice/StdErrLoggingCallback.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.customservice; + +/* + * Copyright 2021 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.dynatrace.oneagent.sdk.api.LoggingCallback; + +/** + * Implementation of OneAgent Logging Callback. Just printing output messages to + * std err. + */ +public class StdErrLoggingCallback implements LoggingCallback { + + @Override + public void error(String message) { + System.err.println("[OneAgent SDK ERROR]: " + message); + } + + @Override + public void warn(String message) { + System.err.println("[OneAgent SDK WARNING]: " + message); + } + +} diff --git a/samples/database/pom.xml b/samples/database/pom.xml new file mode 100644 index 0000000..d77592c --- /dev/null +++ b/samples/database/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + com.dynatrace.oneagent.sdk.samples.messaging + messaging-sample + 1.7.0 + jar + + + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.7.0 + compile + + + + https://github.com/Dynatrace/OneAgent-SDK-Java + Dynatrace OneAgent SDK Java database request sample + + Dynatrace + http://www.dynatrace.com + + + + 1.6 + 1.6 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + com.dynatrace.oneagent.sdk.samples.database.DatabaseApp + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + exec + + + + + java + + ${agent.agentpath} + -classpath + + com.dynatrace.oneagent.sdk.samples.database.DatabaseApp + + + + + + + \ No newline at end of file diff --git a/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/DatabaseApp.java b/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/DatabaseApp.java new file mode 100644 index 0000000..5056081 --- /dev/null +++ b/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/DatabaseApp.java @@ -0,0 +1,85 @@ +package com.dynatrace.oneagent.sdk.samples.database; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; + +/** + * Sample application shows how database requests should be traced. + * + * @author Alram.Lechner + * + */ +public class DatabaseApp { + + private final OneAgentSDK oneAgentSdk; + + static DatabaseApp instance; + + private DatabaseApp() { + oneAgentSdk = OneAgentSDKFactory.createInstance(); + oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); + switch (oneAgentSdk.getCurrentState()) { + case ACTIVE: + System.out.println("SDK is active and capturing."); + break; + case PERMANENTLY_INACTIVE: + System.err.println( + "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); + break; + case TEMPORARILY_INACTIVE: + System.err.println( + "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + break; + default: + System.err.println("SDK is in unknown state."); + break; + } + instance = this; + } + + public static void main(String args[]) { + System.out.println("*************************************************************"); + System.out.println("** Running database request sample **"); + System.out.println("*************************************************************"); + try { + DatabaseApp app = new DatabaseApp(); + + app.traceSqlRequest("Select * from anyTable"); + + System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); + Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server + } catch (Exception e) { + System.err.println("database request sample failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + } + + /** + * You need to add a custom service for this method. a database request will only be captured, if it s part of an already + * started transaction. + * see Dynatrace help + * for more information about a custom service. + */ + private void traceSqlRequest(String sql) { + DatabaseInfo databaseInfo = oneAgentSdk.createDatabaseInfo("myCoolDatabase", "UnsupportedDatabaseVendor", ChannelType.TCP_IP, "theDbHost.localdomain:3434"); + DatabaseRequestTracer databaseRequestTracer = oneAgentSdk.traceSqlDatabaseRequest(databaseInfo, sql); + databaseRequestTracer.start(); + try { + executeRequest(sql); + } catch(Exception e) { + databaseRequestTracer.error(e); + // handle or re-throw exception! + } finally { + databaseRequestTracer.end(); + } + } + + private void executeRequest(String sql) { + // run the sql against the db ... + } + +} diff --git a/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/StdErrLoggingCallback.java b/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/StdErrLoggingCallback.java new file mode 100644 index 0000000..c6d131d --- /dev/null +++ b/samples/database/src/main/java/com/dynatrace/oneagent/sdk/samples/database/StdErrLoggingCallback.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.database; + +/* + * Copyright 2018 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.dynatrace.oneagent.sdk.api.LoggingCallback; + +/** + * Implementation of OneAgent Logging Callback. Just printing output messages to + * std err. + */ +public class StdErrLoggingCallback implements LoggingCallback { + + @Override + public void error(String message) { + System.err.println("[OneAgent SDK ERROR]: " + message); + } + + @Override + public void warn(String message) { + System.err.println("[OneAgent SDK WARNING]: " + message); + } + +} diff --git a/samples/img/in-process-linking-service.png b/samples/img/in-process-linking-service.png new file mode 100644 index 0000000..a448e53 Binary files /dev/null and b/samples/img/in-process-linking-service.png differ diff --git a/samples/img/remotecall-service.png b/samples/img/remotecall-service.png new file mode 100644 index 0000000..f54dd5f Binary files /dev/null and b/samples/img/remotecall-service.png differ diff --git a/samples/img/webrequest-service.png b/samples/img/webrequest-service.png new file mode 100644 index 0000000..7b6d1ab Binary files /dev/null and b/samples/img/webrequest-service.png differ diff --git a/samples/in-process-linking/.gitignore b/samples/in-process-linking/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/samples/in-process-linking/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/samples/in-process-linking/pom.xml b/samples/in-process-linking/pom.xml new file mode 100644 index 0000000..d8f7dcc --- /dev/null +++ b/samples/in-process-linking/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + com.dynatrace.oneagent.sdk.samples.inprocesslinking + in-process-linking-sample + 1.2.0 + jar + + + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.2.0 + compile + + + + https://github.com/Dynatrace/OneAgent-SDK-Java + Dynatrace OneAgent SDK Java In-Process-Linking sample + + Dynatrace + http://www.dynatrace.com + + + + 1.6 + 1.6 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + exec + + + + + java + + ${agent.agentpath} + -classpath + + com.dynatrace.oneagent.sdk.samples.inprocesslinking.InProcessLinkingApp + + + + + + + \ No newline at end of file diff --git a/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/InProcessLinkingApp.java b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/InProcessLinkingApp.java new file mode 100644 index 0000000..8d82c91 --- /dev/null +++ b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/InProcessLinkingApp.java @@ -0,0 +1,121 @@ +package com.dynatrace.oneagent.sdk.samples.inprocesslinking; + +/* + * Copyright 2018 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.net.URL; +import java.sql.SQLException; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +import javax.net.ssl.HttpsURLConnection; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * ServerApp is listing for remote call requests from remote-call client. + * + * @author Alram.Lechner + * + */ +public class InProcessLinkingApp { + + private final OneAgentSDK oneAgentSdk; + + private BlockingQueue blockingQueue = new ArrayBlockingQueue(5); + + private InProcessLinkingApp() { + oneAgentSdk = OneAgentSDKFactory.createInstance(); + oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); + switch (oneAgentSdk.getCurrentState()) { + case ACTIVE: + System.out.println("SDK is active and capturing."); + break; + case PERMANENTLY_INACTIVE: + System.err.println( + "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); + break; + case TEMPORARILY_INACTIVE: + System.err.println( + "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + break; + default: + System.err.println("SDK is in unknown state."); + break; + } + } + + public static void main(String args[]) { + System.out.println("*************************************************************"); + System.out.println("** Running in-process-linking sample **"); + System.out.println("*************************************************************"); + try { + InProcessLinkingApp app = new InProcessLinkingApp(); + // start worker thread, responsible for downloading files in background. thread waits on provided blocking queue. + new UrlDownloaderThread(app.blockingQueue).start(); + String latestVersion = app.startAsyncOperation(); + System.err.println("Found latest OneAgent SDK for Java: " + latestVersion); + System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); + Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server + app.end(); + } catch (Exception e) { + System.err.println("in-process-linking sample failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + } + + /** + * TODO: add custom service for this method + * check for latest version and start downloading them asynchronously. + */ + private String startAsyncOperation() throws IOException, ClassNotFoundException, InterruptedException, SQLException { + System.out.println("Executor started ..."); + + // do some sync work - eg. check for latest version: + HttpsURLConnection url = (HttpsURLConnection) new URL("https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/latest").openConnection(); + + // we expect redirect to latest release url: + url.setInstanceFollowRedirects(false); + int responseStatus = url.getResponseCode(); + if (responseStatus != 302) { + System.out.println("no redirect retrieved!"); + return null; + } + + // e. g.: https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/tag/v1.0.3 + String location = url.getHeaderField("Location"); + String latestVersion = location.substring(location.lastIndexOf('/') + 1); + + // tag this request using the found SDK version: + oneAgentSdk.addCustomRequestAttribute("oneagentsdk.java.version", latestVersion); + + // download the big release archive asynchronously ... + UrlDownloadItem asyncWorkItem = new UrlDownloadItem( + "https://github.com/Dynatrace/OneAgent-SDK-for-Java/archive/" + latestVersion + ".zip", + oneAgentSdk.createInProcessLink()); + blockingQueue.put(asyncWorkItem); + + return latestVersion; + } + + private void end() { + blockingQueue.offer(UrlDownloadItem.END); + } + +} \ No newline at end of file diff --git a/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/StdErrLoggingCallback.java b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/StdErrLoggingCallback.java new file mode 100644 index 0000000..6f72b80 --- /dev/null +++ b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/StdErrLoggingCallback.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.inprocesslinking; + +/* + * Copyright 2018 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.dynatrace.oneagent.sdk.api.LoggingCallback; + +/** + * Implementation of OneAgent Logging Callback. Just printing output messages to + * std err. + */ +public class StdErrLoggingCallback implements LoggingCallback { + + @Override + public void error(String message) { + System.err.println("[OneAgent SDK ERROR]: " + message); + } + + @Override + public void warn(String message) { + System.err.println("[OneAgent SDK WARNING]: " + message); + } + +} diff --git a/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloadItem.java b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloadItem.java new file mode 100644 index 0000000..a3cb6d1 --- /dev/null +++ b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloadItem.java @@ -0,0 +1,27 @@ +package com.dynatrace.oneagent.sdk.samples.inprocesslinking; + +import com.dynatrace.oneagent.sdk.api.InProcessLink; + +public class UrlDownloadItem { + + public static final UrlDownloadItem END = new UrlDownloadItem("END", null); + + // async operation - eg. URL to download + private String url; + + // trace to link async execution with dynatrace + private InProcessLink link; + + public UrlDownloadItem(String url, InProcessLink link) { + this.url = url; + this.link = link; + } + + public String getUrl() { + return url; + } + + public InProcessLink getLink() { + return link; + } +} diff --git a/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloaderThread.java b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloaderThread.java new file mode 100644 index 0000000..c85a0a6 --- /dev/null +++ b/samples/in-process-linking/src/main/java/com/dynatrace/oneagent/sdk/samples/inprocesslinking/UrlDownloaderThread.java @@ -0,0 +1,69 @@ +package com.dynatrace.oneagent.sdk.samples.inprocesslinking; + +import java.io.InputStream; +import java.net.URL; +import java.util.concurrent.BlockingQueue; + +import javax.net.ssl.HttpsURLConnection; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +public class UrlDownloaderThread extends Thread { + + private BlockingQueue queue; + private OneAgentSDK oneAgentSdk; + + UrlDownloaderThread(BlockingQueue queue) { + this.queue = queue; + oneAgentSdk = OneAgentSDKFactory.createInstance(); + setDaemon(true); + } + + @Override + public void run() { + try { + while (true) { + UrlDownloadItem item = queue.take(); + if (item == UrlDownloadItem.END) { + System.out.println("[DBWorker] retrieved end - exiting"); + return; + } + System.out.println("[UrlDownloaderThread] retrieved item: " + item.getUrl()); + + // trace the execution of retrieved SQL: + InProcessLinkTracer inProcessLinkTracer = oneAgentSdk.traceInProcessLink(item.getLink()); + inProcessLinkTracer.start(); + HttpsURLConnection connection = (HttpsURLConnection) new URL(item.getUrl()).openConnection(); + try { + System.out.println("[UrlDownloaderThread] HTTP status code: " + connection.getResponseCode()); + InputStream inputStream = connection.getInputStream(); + int bytesRetrieved = 0; + try { + byte buffer[] = new byte[1024*10]; + while(true) { + int read = inputStream.read(buffer); + if (read < 0) { + break; + } + bytesRetrieved += read; + } + System.out.println("[UrlDownloaderThread] retrieved " + bytesRetrieved + " bytes"); + } finally { + inputStream.close(); + } + } catch (Exception e) { + inProcessLinkTracer.error(e); + System.out.println("[UrlDownloaderThread] *** download operation failed: " + e.getClass().getName() + ": " + e.getMessage()); + } finally { + inProcessLinkTracer.end(); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.exit(-2); + } + } + +} diff --git a/samples/messaging/pom.xml b/samples/messaging/pom.xml new file mode 100644 index 0000000..5835fed --- /dev/null +++ b/samples/messaging/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + com.dynatrace.oneagent.sdk.samples.messaging + messaging-sample + 1.6.0 + jar + + + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.6.0 + compile + + + + https://github.com/Dynatrace/OneAgent-SDK-Java + Dynatrace OneAgent SDK Java WebRequest sample + + Dynatrace + http://www.dynatrace.com + + + + 1.6 + 1.6 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + com.dynatrace.oneagent.sdk.samples.messaging.MessagingApp + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + exec + + + + + java + + ${agent.agentpath} + -classpath + + com.dynatrace.oneagent.sdk.samples.messaging.MessagingApp + + + + + + + \ No newline at end of file diff --git a/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/FakedQueueManager.java b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/FakedQueueManager.java new file mode 100644 index 0000000..ada19f4 --- /dev/null +++ b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/FakedQueueManager.java @@ -0,0 +1,59 @@ +package com.dynatrace.oneagent.sdk.samples.messaging; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +public class FakedQueueManager { + + private BlockingQueue queue = new ArrayBlockingQueue(10); + private MessageListener messageListener; + + public FakedQueueManager() { + } + + private class QueueManagerThread extends Thread { + private QueueManagerThread() { + super("QueueManager"); + setDaemon(true); + } + + @Override + public void run() { + while (true) { + Message incomingMessage; + try { + incomingMessage = queue.take(); + messageListener.onMessage(incomingMessage); + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } + } + } + } + + public void registerMessageListener(MessageListener listener) { + this.messageListener = listener; + new QueueManagerThread().start(); + } + + + public void send(String queueName, Message message) { + try { + queue.put(message); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public Message receive(String queueName) { + try { + return queue.take(); + } catch (InterruptedException e) { + e.printStackTrace(); + return null; + } + } + + +} diff --git a/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/Message.java b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/Message.java new file mode 100644 index 0000000..9f0404c --- /dev/null +++ b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/Message.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.messaging; + +import java.util.HashMap; +import java.util.Map; + +public class Message { + + private Map properties = new HashMap(); + private String vendorMessageId = null; + private String correlationId = null; + + public void addProperty(String propertyName, String propertyValue) { + properties.put(propertyName, propertyValue); + } + + public String getProperty(String propertyName) { + return properties.get(propertyName); + } + + public String getVendorMessageId() { + return vendorMessageId; + } + + public void setVendorMessageId(String vendorMessageId) { + this.vendorMessageId = vendorMessageId; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String correlationId) { + this.correlationId = correlationId; + } + + +} diff --git a/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessageListener.java b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessageListener.java new file mode 100644 index 0000000..a00c12e --- /dev/null +++ b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessageListener.java @@ -0,0 +1,7 @@ +package com.dynatrace.oneagent.sdk.samples.messaging; + +public interface MessageListener { + + public void onMessage(Message message); + +} diff --git a/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessagingApp.java b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessagingApp.java new file mode 100644 index 0000000..cebecf7 --- /dev/null +++ b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/MessagingApp.java @@ -0,0 +1,153 @@ +package com.dynatrace.oneagent.sdk.samples.messaging; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; +import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; +import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; + +/** + * Sample application shows how incoming/outgoing messages should be traced. + * + * @author Alram.Lechner + * + */ +public class MessagingApp { + + private final OneAgentSDK oneAgentSdk; + final FakedQueueManager queueManager; + + static MessagingApp instance; + + + private MessagingApp() { + oneAgentSdk = OneAgentSDKFactory.createInstance(); + oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); + switch (oneAgentSdk.getCurrentState()) { + case ACTIVE: + System.out.println("SDK is active and capturing."); + break; + case PERMANENTLY_INACTIVE: + System.err.println( + "SDK is PERMANENTLY_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); + break; + case TEMPORARILY_INACTIVE: + System.err.println( + "SDK is TEMPORARILY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + break; + default: + System.err.println("SDK is in unknown state."); + break; + } + queueManager = new FakedQueueManager(); + instance = this; + } + + public static void main(String args[]) { + System.out.println("*************************************************************"); + System.out.println("** Running messaging sample **"); + System.out.println("*************************************************************"); + try { + MessagingApp app = new MessagingApp(); + + // sending and blocking receive ... + app.sendMessage(); + app.receiveMessage(); + + // or sending and event based receive: + app.registerMessageListener(); + app.sendMessage(); + + System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); + Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server + } catch (Exception e) { + System.err.println("messaging sample failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + } + + private void registerMessageListener() { + queueManager.registerMessageListener(new MessageListener() { + @Override + public void onMessage(Message message) { + MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); + IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk.traceIncomingMessageProcess(messagingSystemInfo); + // store incoming tag to tracer: + incomingMessageProcessTracer.setDynatraceStringTag(message.getProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); + incomingMessageProcessTracer.setVendorMessageId(message.getVendorMessageId()); + incomingMessageProcessTracer.start(); + try { + // do something with the message ... + System.out.println("Message received: " + message.toString()); + } catch (Exception e) { + incomingMessageProcessTracer.error(e); + } finally { + incomingMessageProcessTracer.end(); + } + } + }); + + } + + private void sendMessage() { + MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); + OutgoingMessageTracer outgoingMessageTracer = oneAgentSdk.traceOutgoingMessage(messagingSystemInfo); + + outgoingMessageTracer.start(); + try { + Message messageToSend = new Message(); + + // add dynatrace tag as property to message ... + messageToSend.addProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME, outgoingMessageTracer.getDynatraceStringTag()); + + queueManager.send("theQueue", messageToSend); + + // in case queueManager provided messageId: + if (messageToSend.getVendorMessageId() != null) { + outgoingMessageTracer.setVendorMessageId(messageToSend.getVendorMessageId()); + } + + } catch (Exception e) { + outgoingMessageTracer.error(e); + } finally { + outgoingMessageTracer.end(); + } + } + + /** shows how to trace a blocking receive of a message */ + private void receiveMessage() { + MessagingSystemInfo messagingSystemInfo = oneAgentSdk.createMessagingSystemInfo("DynatraceSample", "theQueue", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null); + IncomingMessageReceiveTracer incomingMessageReceiveTracer = oneAgentSdk.traceIncomingMessageReceive(messagingSystemInfo); + incomingMessageReceiveTracer.start(); + try { + Message msg = queueManager.receive("theQeue"); + if (msg == null) { + return; // no message received + } + IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk.traceIncomingMessageProcess(messagingSystemInfo); + // store incoming tag to tracer: + incomingMessageProcessTracer.setDynatraceStringTag(msg.getProperty(OneAgentSDK.DYNATRACE_MESSAGE_PROPERTYNAME)); + incomingMessageProcessTracer.setVendorMessageId(msg.getVendorMessageId()); + incomingMessageProcessTracer.start(); + try { + // do something with the message ... + System.out.println("Message received: " + msg.toString()); + } catch (Exception e) { + incomingMessageProcessTracer.error(e); + } finally { + incomingMessageProcessTracer.end(); + } + + + } catch (Exception e) { + incomingMessageReceiveTracer.error(e); + } finally { + incomingMessageReceiveTracer.end(); + } + } + +} diff --git a/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/StdErrLoggingCallback.java b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/StdErrLoggingCallback.java new file mode 100644 index 0000000..256a8c5 --- /dev/null +++ b/samples/messaging/src/main/java/com/dynatrace/oneagent/sdk/samples/messaging/StdErrLoggingCallback.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.messaging; + +/* + * Copyright 2018 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.dynatrace.oneagent.sdk.api.LoggingCallback; + +/** + * Implementation of OneAgent Logging Callback. Just printing output messages to + * std err. + */ +public class StdErrLoggingCallback implements LoggingCallback { + + @Override + public void error(String message) { + System.err.println("[OneAgent SDK ERROR]: " + message); + } + + @Override + public void warn(String message) { + System.err.println("[OneAgent SDK WARNING]: " + message); + } + +} diff --git a/samples/remotecall/parent/pom.xml b/samples/remotecall/parent/pom.xml index 078ff03..a32ef25 100644 --- a/samples/remotecall/parent/pom.xml +++ b/samples/remotecall/parent/pom.xml @@ -6,15 +6,14 @@ com.dynatrace.oneagent.sdk.samples.remoting parent - 1.0.3 + 1.2.0 pom - com.dynatrace.oneagent.sdk.java oneagent-sdk - 1.0.3 + 1.2.0 compile @@ -34,6 +33,7 @@ ,debugOneAgentSdkJava=true -agentpath:"${agent.lib}=name=SdkSample,server=${agent.server}"${agent.options},tenant=${agent.tenant},tenantToken=${agent.tenantToken} --> - + + \ No newline at end of file diff --git a/samples/remotecall/pom.xml b/samples/remotecall/pom.xml index 200fb80..aed81dc 100644 --- a/samples/remotecall/pom.xml +++ b/samples/remotecall/pom.xml @@ -6,7 +6,7 @@ com.dynatrace.oneagent.sdk.samples.remoting remotecall-sample - 1.0.3 + 1.2.0 pom diff --git a/samples/remotecall/remotecall-client/pom.xml b/samples/remotecall/remotecall-client/pom.xml index cfab4d9..5a71fbb 100644 --- a/samples/remotecall/remotecall-client/pom.xml +++ b/samples/remotecall/remotecall-client/pom.xml @@ -7,7 +7,7 @@ com.dynatrace.oneagent.sdk.samples.remoting parent - 1.0.3 + 1.2.0 ../parent/pom.xml @@ -46,7 +46,8 @@ ${agent.agentpath} -classpath - com.dynatrace.oneagent.sdk.samples.remoting.ClientApp + com.dynatrace.oneagent.sdk.samples.remoting.ClientApp + ${sample.mode} diff --git a/samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ClientApp.java b/samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ClientApp.java index 53170f0..ccea0c2 100644 --- a/samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ClientApp.java +++ b/samples/remotecall/remotecall-client/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ClientApp.java @@ -19,6 +19,8 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.net.Socket; +import java.util.logging.Level; +import java.util.logging.Logger; import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; import com.dynatrace.oneagent.sdk.api.OneAgentSDK; @@ -28,6 +30,7 @@ public class ClientApp { private final OneAgentSDK oneAgentSdk; + private final Logger logger = Logger.getLogger("ClientApp"); private ClientApp() { oneAgentSdk = OneAgentSDKFactory.createInstance(); @@ -53,17 +56,22 @@ public static void main(String args[]) { System.out.println("** Running remote call client **"); System.out.println("*************************************************************"); int port = 33744; + boolean endlessmode = false; for (String arg : args) { if (arg.startsWith("port=")) { port = Integer.parseInt(arg.substring("port=".length())); + } else if (arg.startsWith("endlessmode")) { + endlessmode = true; } else { System.err.println("unknown argument: " + arg); } } try { - new ClientApp().run(port); - System.out.println("remote call client finished. sleeping a while, so OneAgent is able to send data to server ..."); - Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server. + ClientApp clientApp = new ClientApp(); + do { + clientApp.run(port); + Thread.sleep(10000); + } while (endlessmode); } catch (Exception e) { System.err.println("remote call client failed: " + e.getMessage()); e.printStackTrace(); @@ -85,7 +93,7 @@ private void run(int port) throws IOException, ClassNotFoundException { } private void traceCallToServer(ObjectOutputStream out, int port) throws IOException { - OutgoingRemoteCallTracer outgoingRemoteCall = oneAgentSdk.traceOutgoingRemoteCall("myMethod", "myService", "endpoint", ChannelType.IN_PROCESS, "localhost:" + port); + OutgoingRemoteCallTracer outgoingRemoteCall = oneAgentSdk.traceOutgoingRemoteCall("myMethod", "myService", "endpoint", ChannelType.TCP_IP, "localhost:" + port); outgoingRemoteCall.start(); try { String outgoingTag = outgoingRemoteCall.getDynatraceStringTag(); @@ -93,6 +101,7 @@ private void traceCallToServer(ObjectOutputStream out, int port) throws IOExcept invokeCallToServer(out, outgoingTag); } catch (Exception e) { outgoingRemoteCall.error(e); + logger.log(Level.WARNING, "remotecall failed", e); } finally { outgoingRemoteCall.end(); } diff --git a/samples/remotecall/remotecall-server/pom.xml b/samples/remotecall/remotecall-server/pom.xml index 8db9f88..5b16126 100644 --- a/samples/remotecall/remotecall-server/pom.xml +++ b/samples/remotecall/remotecall-server/pom.xml @@ -7,7 +7,7 @@ com.dynatrace.oneagent.sdk.samples.remoting parent - 1.0.3 + 1.2.0 ../parent/pom.xml @@ -46,7 +46,8 @@ ${agent.agentpath} -classpath - com.dynatrace.oneagent.sdk.samples.remoting.ServerApp + com.dynatrace.oneagent.sdk.samples.remoting.ServerApp + ${sample.mode} diff --git a/samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ServerApp.java b/samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ServerApp.java index 45dca3d..57295fd 100644 --- a/samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ServerApp.java +++ b/samples/remotecall/remotecall-server/src/main/java/com/dynatrace/oneagent/sdk/samples/remoting/ServerApp.java @@ -20,6 +20,8 @@ import java.io.ObjectInputStream; import java.net.ServerSocket; import java.net.Socket; +import java.util.logging.Level; +import java.util.logging.Logger; import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; @@ -32,8 +34,9 @@ * */ public class ServerApp { - + private final OneAgentSDK oneAgentSdk; + private final Logger logger = Logger.getLogger("ServerApp"); private ServerApp() { oneAgentSdk = OneAgentSDKFactory.createInstance(); @@ -47,29 +50,34 @@ private ServerApp() { "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); break; case TEMPORARILY_INACTIVE: - System.err.println("SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + System.err.println( + "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); break; default: System.err.println("SDK is in unknown state."); break; } } - + public static void main(String args[]) { System.out.println("*************************************************************"); System.out.println("** Running remote call server **"); System.out.println("*************************************************************"); int port = 33744; // default port + boolean endlessmode = false; for (String arg : args) { if (arg.startsWith("port=")) { port = Integer.parseInt(arg.substring("port=".length())); + } else if (arg.startsWith("endlessmode")) { + endlessmode = true; } else { System.err.println("unknown argument: " + arg); } } try { - new ServerApp().run(port); - System.out.println("remote call server stopped. sleeping a while, so OneAgent is able to send data to server ..."); + new ServerApp().run(port, endlessmode); + System.out.println( + "remote call server stopped. sleeping a while, so OneAgent is able to send data to server ..."); Thread.sleep(15000); // we have to wait - so OneAgent is able to send data to server. } catch (Exception e) { System.err.println("remote call server failed: " + e.getMessage()); @@ -78,31 +86,34 @@ public static void main(String args[]) { } } - private void run(int port) throws IOException, ClassNotFoundException { + private void run(int port, boolean endlessmode) throws IOException, ClassNotFoundException { ServerSocket serverSocket = new ServerSocket(port); try { - System.out.println("Waiting for clients on port " + serverSocket.getInetAddress().getHostName() + ":" - + serverSocket.getLocalPort()); - Socket client = serverSocket.accept(); - try { - System.out.println( - "Client " + client.getInetAddress().getHostName() + ":" + client.getPort() + " connected"); - ObjectInputStream in = new ObjectInputStream(client.getInputStream()); - - Object receivedTag = in.readObject(); - String receivedMessage = (String) in.readObject(); - System.out.println("received tag: " + receivedTag.toString()); - traceCallFromClient(receivedTag, receivedMessage); - } finally { - client.close(); - } + do { + System.out.println("Waiting for clients on port " + serverSocket.getInetAddress().getHostName() + ":" + + serverSocket.getLocalPort()); + Socket client = serverSocket.accept(); + try { + System.out.println( + "Client " + client.getInetAddress().getHostName() + ":" + client.getPort() + " connected"); + ObjectInputStream in = new ObjectInputStream(client.getInputStream()); + + Object receivedTag = in.readObject(); + String receivedMessage = (String) in.readObject(); + System.out.println("received tag: " + receivedTag.toString()); + traceCallFromClient(receivedTag, receivedMessage); + } finally { + client.close(); + } + } while (endlessmode); } finally { serverSocket.close(); } } - + private void traceCallFromClient(Object receivedTag, String receivedMessage) { - IncomingRemoteCallTracer incomingRemoteCall = oneAgentSdk.traceIncomingRemoteCall("myMethod", "myService", "endpoint"); + IncomingRemoteCallTracer incomingRemoteCall = oneAgentSdk.traceIncomingRemoteCall("myMethod", "myService", + "endpoint"); if (receivedTag instanceof String) { incomingRemoteCall.setDynatraceStringTag((String) receivedTag); } else if (receivedTag instanceof byte[]) { @@ -110,21 +121,22 @@ private void traceCallFromClient(Object receivedTag, String receivedMessage) { } else { System.err.println("invalid tag received: " + receivedTag.getClass().toString()); } - + incomingRemoteCall.start(); try { handleCallFromClient(receivedMessage); } catch (Exception e) { incomingRemoteCall.error(e); + logger.log(Level.WARNING, "handling of remotecall failed", e); } finally { incomingRemoteCall.end(); } - + } private void handleCallFromClient(String receivedMessage) { // do whatever the server should do ... System.out.println("Received message from client: " + receivedMessage); } - + } \ No newline at end of file diff --git a/samples/webrequest/.gitignore b/samples/webrequest/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/samples/webrequest/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/samples/webrequest/pom.xml b/samples/webrequest/pom.xml new file mode 100644 index 0000000..64bf7c1 --- /dev/null +++ b/samples/webrequest/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + com.dynatrace.oneagent.sdk.samples.webrequest + webrequest-sample + 1.4.0 + jar + + + + com.dynatrace.oneagent.sdk.java + oneagent-sdk + 1.4.0 + compile + + + + https://github.com/Dynatrace/OneAgent-SDK-Java + Dynatrace OneAgent SDK Java WebRequest sample + + Dynatrace + http://www.dynatrace.com + + + + 1.6 + 1.6 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + com.dynatrace.oneagent.sdk.samples.webrequest.WebRequestApp + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + exec + + + + + java + + ${agent.agentpath} + -classpath + + com.dynatrace.oneagent.sdk.samples.webrequest.WebRequestApp + + + + + + + \ No newline at end of file diff --git a/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedHttpClient.java b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedHttpClient.java new file mode 100644 index 0000000..f760fbc --- /dev/null +++ b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedHttpClient.java @@ -0,0 +1,93 @@ +package com.dynatrace.oneagent.sdk.samples.webrequest; + +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.dynatrace.oneagent.sdk.samples.webrequest.FakedWebserver.HttpRequest; +import com.dynatrace.oneagent.sdk.samples.webrequest.FakedWebserver.HttpResponse; + +public class FakedHttpClient implements HttpResponse { + + // REQUEST + private URL url; + private String method; + private Map> requestHeaders = new HashMap>(); + + // RESPONSE + private int statusCode; + private Map> responseHeaders = new HashMap>(); + + public FakedHttpClient(String url, String method) throws MalformedURLException { + this.method = method; + this.url = new URL(url); + } + + public void addRequestHeader(String requestHeader, String value) { + List values = requestHeaders.get(requestHeader); + if (values == null) { + values = new ArrayList(); + requestHeaders.put(requestHeader, values); + } + values.add(value); + } + + public void addResponseHeader(String headerField, String value) { + List values = responseHeaders.get(headerField); + if (values == null) { + values = new ArrayList(); + responseHeaders.put(headerField, values); + } + values.add(value); + } + + public void executeRequest() { + // a normal HTTP client should open plain tcp socket and send the request now ... + // ... but we are putting them into non-blocking queue: + + // build the request object, as a standard web container would provide it ... + HttpRequest httpRequest; + String clientIp; + try { + clientIp = InetAddress.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + clientIp = "192.168.4.5"; // fake IP + } + httpRequest = new HttpRequest(url.getPath() + "?" + url.getQuery(), method, clientIp, requestHeaders); + + // ... and queue it for processing: + WebRequestApp.instance.webServer.enqeueHttpRequestForProcessing(httpRequest, this); + } + + public Map> getRequestHeaders() { + return requestHeaders; + } + + public Map> getResponseHeaders() { + return responseHeaders; + } + + public int getStatusCode() { + return statusCode; + } + + public void setResponseHeaders(Map> responseHeaders) { + this.responseHeaders = responseHeaders; + } + + @Override + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + @Override + public void setContent(byte[] content) { + // ignore the content we got from server + } + +} diff --git a/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java new file mode 100644 index 0000000..8f010eb --- /dev/null +++ b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java @@ -0,0 +1,144 @@ +package com.dynatrace.oneagent.sdk.samples.webrequest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; + +public class FakedWebserver { + + private final OneAgentSDK oneAgentSDK; + private final WebApplicationInfo webAppInfo; + + private final BlockingQueue requestQueue = new ArrayBlockingQueue(10); + + public FakedWebserver(OneAgentSDK oneAgentSDK) { + this.oneAgentSDK = oneAgentSDK; + webAppInfo = oneAgentSDK.createWebApplicationInfo("servername", "BillingService", "/billing"); + new RequestProcessor().start(); + } + + private class RequestProcessor extends Thread { + private RequestProcessor() { + super("Webserver-Worker"); + setDaemon(true); + } + + @Override + public void run() { + while (true) { + Pair incomingRequest; + try { + incomingRequest = requestQueue.take(); + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } + serve(incomingRequest.httpRequest, incomingRequest.httpResponse); + } + } + } + + private class Pair { + public HttpRequest httpRequest; + public HttpResponse httpResponse; + + public Pair(HttpRequest httpRequest, HttpResponse httpResponse) { + this.httpRequest = httpRequest; + this.httpResponse = httpResponse; + } + } + + public void enqeueHttpRequestForProcessing(HttpRequest httpRequest, HttpResponse httpResponse) { + try { + requestQueue.put(new Pair(httpRequest,httpResponse)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public static interface HttpResponse { + + public void setStatusCode(int statusCode); + + public void addResponseHeader(String headerField, String value); + + public void setContent(byte[] content); + } + + public static class HttpRequest { + private final String remoteIpAddress; + private final String uri; + private final String method; + private final Map> requestHeaders; + + public HttpRequest(String uri, String method, String remoteIpAddress, Map> requestHeaders) { + this.uri = uri; + this.method = method; + this.remoteIpAddress = remoteIpAddress; + this.requestHeaders = requestHeaders; + } + + public String getUri() { + return uri; + } + + public String getMethod() { + return method; + } + + public Map> getHeaders() { + return requestHeaders; + } + + public Map> getParameters() { + return new HashMap>(); + } + + public String getRemoteIpAddress() { + return remoteIpAddress; + } + } + + /** faked http request handling. shows usage of OneAgent SDK's incoming webrequest API */ + private void serve(HttpRequest request, HttpResponse response) { + String url = request.getUri(); + System.out.println("[Server] serve " + url); + IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK.traceIncomingWebRequest(webAppInfo, url, request.getMethod()); + + // add request header, parameter and remote address before start: + for (Entry> headerField : request.getHeaders().entrySet()) { + for (String value : headerField.getValue()) { + incomingWebrequestTracer.addRequestHeader(headerField.getKey(), value); + } + } + for (Entry> parameter : request.getParameters().entrySet()) { + for (String value : parameter.getValue()) { + incomingWebrequestTracer.addParameter(parameter.getKey(), value); + } + } + incomingWebrequestTracer.setRemoteAddress(request.getRemoteIpAddress()); + + incomingWebrequestTracer.start(); + try { + response.setContent("Hello world!".getBytes()); + response.setStatusCode(200); + incomingWebrequestTracer.setStatusCode(200); + } catch (Exception e) { + // we assume, container is sending http 500 in case of exception is thrown while serving an request: + incomingWebrequestTracer.error(e); + e.printStackTrace(); + throw new RuntimeException(e); + } finally { + incomingWebrequestTracer.end(); + } + } + + +} diff --git a/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/StdErrLoggingCallback.java b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/StdErrLoggingCallback.java new file mode 100644 index 0000000..032047b --- /dev/null +++ b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/StdErrLoggingCallback.java @@ -0,0 +1,37 @@ +package com.dynatrace.oneagent.sdk.samples.webrequest; + +/* + * Copyright 2018 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.dynatrace.oneagent.sdk.api.LoggingCallback; + +/** + * Implementation of OneAgent Logging Callback. Just printing output messages to + * std err. + */ +public class StdErrLoggingCallback implements LoggingCallback { + + @Override + public void error(String message) { + System.err.println("[OneAgent SDK ERROR]: " + message); + } + + @Override + public void warn(String message) { + System.err.println("[OneAgent SDK WARNING]: " + message); + } + +} diff --git a/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/WebRequestApp.java b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/WebRequestApp.java new file mode 100644 index 0000000..aac1ae9 --- /dev/null +++ b/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/WebRequestApp.java @@ -0,0 +1,92 @@ +package com.dynatrace.oneagent.sdk.samples.webrequest; + +import java.util.List; +import java.util.Map.Entry; + +import com.dynatrace.oneagent.sdk.OneAgentSDKFactory; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; + +/** + * Sample application shows how incoming webrequests should be traced. + * + * @author Alram.Lechner + * + */ +public class WebRequestApp { + + private final OneAgentSDK oneAgentSdk; + final FakedWebserver webServer; + + static WebRequestApp instance; + + + private WebRequestApp() { + oneAgentSdk = OneAgentSDKFactory.createInstance(); + oneAgentSdk.setLoggingCallback(new StdErrLoggingCallback()); + switch (oneAgentSdk.getCurrentState()) { + case ACTIVE: + System.out.println("SDK is active and capturing."); + break; + case PERMANENTLY_INACTIVE: + System.err.println( + "SDK is PERMANENT_INACTIVE; Probably no OneAgent injected or OneAgent is incompatible with SDK."); + break; + case TEMPORARILY_INACTIVE: + System.err.println( + "SDK is TEMPORARY_INACTIVE; OneAgent has been deactivated - check OneAgent configuration."); + break; + default: + System.err.println("SDK is in unknown state."); + break; + } + webServer = new FakedWebserver(oneAgentSdk); + instance = this; + } + + public static void main(String args[]) { + System.out.println("*************************************************************"); + System.out.println("** Running webrequest sample **"); + System.out.println("*************************************************************"); + try { + WebRequestApp app = new WebRequestApp(); + app.runFakedWebrequest(); + // app.runIncomingWebrequest(); + System.out.println("sample application stopped. sleeping a while, so OneAgent is able to send data to server ..."); + Thread.sleep(15000 * 3); // we have to wait - so OneAgent is able to send data to server + } catch (Exception e) { + System.err.println("webrequest sample failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + } + + private void runFakedWebrequest() { + String url = "http://localhost:80/billing/my/path?param1=value1¶m2=value2"; + System.out.println("[Client] request " + url); + OutgoingWebRequestTracer outgoingWebRequestTracer = oneAgentSdk.traceOutgoingWebRequest(url, "GET"); + outgoingWebRequestTracer.start(); + try { + FakedHttpClient httpClient = new FakedHttpClient(url, "GET"); + + // add link to headers ... + httpClient.addRequestHeader(OneAgentSDK.DYNATRACE_HTTP_HEADERNAME, outgoingWebRequestTracer.getDynatraceStringTag()); + + httpClient.executeRequest(); + + // add response headers to tracer: + for (Entry> entry : httpClient.getResponseHeaders().entrySet()) { + for (String value : entry.getValue()) { + outgoingWebRequestTracer.addResponseHeader(entry.getKey(), value); + } + } + + outgoingWebRequestTracer.setStatusCode(httpClient.getStatusCode()); + } catch (Exception e) { + outgoingWebRequestTracer.error(e); + } finally { + outgoingWebRequestTracer.end(); + } + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.java b/src/main/java/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.java new file mode 100644 index 0000000..df67b69 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/OneAgentSDKFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; + +/** + * Entry point for customer application. + */ +public class OneAgentSDKFactory { + + /** + * Provides a {@link OneAgentSDK} instance, that has to be used to create + * transactions. It is safe to use returned {@link OneAgentSDK} instance in + * multiple threads. Every application should only create one single SDK + * instance during its lifetime. + * + * @return never null. if no OneAgent present, NOOP implementation gets + * returned. + */ + public static OneAgentSDK createInstance() { + return OneAgentSDKFactoryImpl.createInstance(); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.java new file mode 100644 index 0000000..f015bd5 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/CustomServiceTracer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for tracing custom services. + * https://github.com/Dynatrace/OneAgent-SDK#customservice + * + * @since 1.8.0 + */ +public interface CustomServiceTracer extends Tracer { +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.java new file mode 100644 index 0000000..c3f0f44 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/DatabaseRequestTracer.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for outgoing database tracer. + * https://github.com/Dynatrace/OneAgent-SDK#database + * + * @since 1.7.0 + */ +public interface DatabaseRequestTracer extends Tracer { + + /** + * Adds optional information about retrieved rows of the traced database request. + * + * @param returnedRowCount number of rows returned by this traced database request. Only positive values are allowed. + * @since 1.7.0 + */ + public void setReturnedRowCount(int returnedRowCount); + + /** + * Adds optional information about round-trip count to database server. + * + * @param roundTripCount count of round-trips that took place. Only positive values are allowed. + * @since 1.7.0 + */ + public void setRoundTripCount(int roundTripCount); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLink.java b/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLink.java new file mode 100644 index 0000000..efd0d0d --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLink.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Represents link used for in-process-tagging. See + * {@link OneAgentSDK#createInProcessLink()} and + * {@link OneAgentSDK#traceInProcessLink(InProcessLink)} for more details. + * + * @since 1.1 + */ +public interface InProcessLink { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.java new file mode 100644 index 0000000..64c8004 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/InProcessLinkTracer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Tracer used to trace in-process-linking. See + * {@link OneAgentSDK#createInProcessLink()} and + * {@link OneAgentSDK#traceInProcessLink(InProcessLink)} for more details. + * + * @since 1.1 + */ +public interface InProcessLinkTracer extends Tracer { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.java new file mode 100644 index 0000000..56325e7 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageProcessTracer.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for processing message tracer. + * https://github.com/Dynatrace/OneAgent-SDK#messaging + * + * @since 1.5 + */ +public interface IncomingMessageProcessTracer extends IncomingTaggable, Tracer { + + /** + * Adds optional information about a traced message: message id provided by messaging system. + * + * @param vendorMessageId the messageId + */ + public void setVendorMessageId(String vendorMessageId); + + /** + * Adds optional information about a traced message: correlation id used by messaging system. + * + * @param correlationId correlationId + */ + public void setCorrelationId(String correlationId); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.java new file mode 100644 index 0000000..e49c885 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingMessageReceiveTracer.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for receiving message tracer. + * https://github.com/Dynatrace/OneAgent-SDK#messaging + * + * @since 1.5 + */ +public interface IncomingMessageReceiveTracer extends Tracer { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.java new file mode 100644 index 0000000..9c37d54 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingRemoteCallTracer.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Represents the server side of a remote call. This Interface extends + * {@link Tracer} - it is important to respect the mentioned requirements when + * working with {@link IncomingRemoteCallTracer}. + * + */ + +public interface IncomingRemoteCallTracer extends Tracer, IncomingTaggable { + + /** + * Sets the name of the used remoting protocol. + * + * @param protocolName + * protocol name + * @since 1.0 + */ + void setProtocolName(String protocolName); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingTaggable.java b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingTaggable.java new file mode 100644 index 0000000..80dd18e --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingTaggable.java @@ -0,0 +1,45 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Common interface for server-tagging-related methods. Not to be directly used + * by SDK user. + */ +public interface IncomingTaggable { + + /** + * Consumes a tag to continue a pure path. Must be set before a node is being + * started.
+ * See {@link OutgoingTaggable} to determine how to create a tag. + * + * @param tag + * the tag in String representation - must not be null. + * @since 1.0 + */ + void setDynatraceStringTag(String tag); + + /** + * Same as {@link #setDynatraceStringTag(String)} but consumes binary + * representation of tag. + * + * @param tag + * the tag in binary representation - must not be null. + * @since 1.0 + */ + void setDynatraceByteTag(byte[] tag); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.java new file mode 100644 index 0000000..f2d561a --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/IncomingWebRequestTracer.java @@ -0,0 +1,77 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for incoming webrequest tracer. https://github.com/Dynatrace/OneAgent-SDK#webrequests + * + * @since 1.3 + */ +public interface IncomingWebRequestTracer extends Tracer, IncomingTaggable { + + /** + * Validates and sets the remote IP address of the incoming web request. This + * information is very useful to gain information about Load balancers, Proxies + * and ultimately the end user that is sending the request. + * + * @param remoteAddress + * remote IP address + */ + void setRemoteAddress(String remoteAddress); + + /** + * All HTTP request headers should be provided to this method. Selective + * capturing will be done based on sensor configuration. + * + * @param name + * HTTP request header field name + * @param value + * HTTP request header field value + */ + void addRequestHeader(String name, String value); + + /** + * All HTTP parameters should be provided to this method. Selective capturing + * will be done based on sensor configuration. + * + * @param name + * HTTP parameter name + * @param value + * HTTP parameter value + */ + void addParameter(String name, String value); + + /** + * All HTTP response headers should be provided to this method. Selective + * capturing will be done based on sensor configuration. + * + * @param name + * HTTP response header field name + * @param value + * HTTP response header field value + */ + void addResponseHeader(String name, String value); + + /** + * Sets the HTTP response status code. + * + * @param statusCode + * HTTP status code returned to client + */ + void setStatusCode(int statusCode); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/LoggingCallback.java b/src/main/java/com/dynatrace/oneagent/sdk/api/LoggingCallback.java new file mode 100644 index 0000000..f098d66 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/LoggingCallback.java @@ -0,0 +1,43 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * LoggingCallback gets called only inside a OneAgentSDK API call when an + * error/warning has occurred.
+ * Never call any SDK API inside one of these callback methods. + */ +public interface LoggingCallback { + + /** + * Just a warning. Something is missing, but OneAgent is working normal. + * + * @param message + * message text. never null. + * @since 1.0 + */ + void warn(String message); + + /** + * Something that should be done can't be done. (e. g. PurePath could not be + * started) + * + * @param message + * message text. never null. + * @since 1.0 + */ + void error(String message); +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/OneAgentSDK.java b/src/main/java/com/dynatrace/oneagent/sdk/api/OneAgentSDK.java new file mode 100644 index 0000000..8843127 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/OneAgentSDK.java @@ -0,0 +1,319 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; +import com.dynatrace.oneagent.sdk.api.enums.SDKState; +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; +import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; +import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; + +/** + * Root interface contains provided Agent SDK API calls. Basically the whole API + * is designed according to following rules: + *
    + *
  • API calls never throw any exception + *
  • API calls never return null values. e. g. they returning NOOP Objects in + * case of any issue or required parameters are null. + *
+ * Single API calls might differ from that rules. Those rules are explicitly + * documented.
+ */ +public interface OneAgentSDK { + + /** + * Using this headername to transport Dynatrace tag inside an outgoing http + * request ensures compatibility to Dynatrace built-in sensors. + */ + public static final String DYNATRACE_HTTP_HEADERNAME = "X-dynaTrace"; + + /** + * Using this propertyname to transport Dynatrace tag along with the message, ensures compatibility to Dynatrace built-in sensors. + */ + public static final String DYNATRACE_MESSAGE_PROPERTYNAME = "dtdTraceTagInfo"; + + // ***** outgoing Database ***** + + /** + * Initializes a DatabaseInfo instance that is required for tracing database requests. + * + * @param name name of the database + * @param vendor database vendor name (e.g. Oracle, MySQL, ...), can be a user defined name + * If possible use a constant defined in {@link com.dynatrace.oneagent.sdk.api.enums.DatabaseVendor} + * @param channelType communication protocol used to communicate with the database. + * @param channelEndpoint this represents the communication endpoint for the database. This information allows Dynatrace to tie the database requests to a specific process or cloud service. It is optional. + * * for TCP/IP: host name/IP of the server-side (can include port in the form of "host:port") + * * for UNIX domain sockets: name of domain socket file + * * for named pipes: name of pipe + * @return {@link DatabaseInfo} instance to work with + * @since 1.7.0 + */ + DatabaseInfo createDatabaseInfo(String name, String vendor, ChannelType channelType, String channelEndpoint); + + /** + * Creates a tracer for tracing outgoing SQL database requests. + * + * @param databaseInfo information about database + * @param statement database SQL statement + * @return {@link DatabaseRequestTracer} to work with + * @since 1.7.0 + */ + DatabaseRequestTracer traceSqlDatabaseRequest(DatabaseInfo databaseInfo, String statement); + + // ***** Web Requests (incoming) ***** + + /** + * Initializes a WebApplicationInfo instance that is required for tracing + * incoming web requests. This information determines the identity and name of + * the resulting Web Request service in dynatrace. Also see + * https://www.dynatrace.com/support/help/server-side-services/introduction/how-does-dynatrace-detect-and-name-services/#web-request-services + * for detail description of the meaning of the parameters. + * + * @param webServerName + * logical name of the web server. In case of a cluster every node in + * the cluster must report the same name here. Attention: Make sure + * not to use the host header for this parameter. Host headers are + * often spoofed and contain things like google or baidoo which do + * not reflect your setup. + * @param applicationID + * application ID of the web application + * @param contextRoot + * context root of the application. All URLs traced with the returned + * WebApplicationInfo, should start with provided context root. + * @return {@link WebApplicationInfo} instance to work with + * @since 1.3 + */ + WebApplicationInfo createWebApplicationInfo(String webServerName, String applicationID, String contextRoot); + + /** + * Traces an incoming web request. + * + * @param webApplicationInfo + * information about web application + * @param url + * (parts of a) URL, which will be parsed into: scheme, + * hostname/port, path & query Note: the hostname will be resolved by + * the Agent at start() call + * @param method + * HTTP request method + * @return {@link IncomingWebRequestTracer} to work with + * @since 1.3 + */ + IncomingWebRequestTracer traceIncomingWebRequest(WebApplicationInfo webApplicationInfo, String url, String method); + + /** + * Traces an outgoing web request. + * + * @param url + * URL, which will be parsed into: scheme, hostname/port, path & + * query Note: the hostname will be resolved by the Agent at start() + * call + * @param method + * HTTP request method + * @return {@link OutgoingWebRequestTracer} to work with + * @since 1.4 + */ + OutgoingWebRequestTracer traceOutgoingWebRequest(String url, String method); + + // ***** Remote Calls (outgoing & incoming) ***** + + /** + * Traces an incoming remote call. + * + * @param serviceMethod + * name of the called remote method. (required) + * @param serviceName + * name of the remote service. (required) + * @param serviceEndpoint + * endpoint on the server side. (required) + * @return {@link IncomingRemoteCallTracer} instance to work with + * @since 1.0 + */ + IncomingRemoteCallTracer traceIncomingRemoteCall(String serviceMethod, String serviceName, String serviceEndpoint); + + /** + * Traces an outgoing remote call. + * + * @param serviceMethod + * name of the called remote method. (required) + * @param serviceName + * name of the remote service. (required) + * @param serviceEndpoint + * endpoint on the server side. (required) + * @param channelType + * communication protocol used by remote call. See + * {@link ChannelType} for available types. (required) + * @param channelEndpoint + * optional and depending on channelType: + *
    + *
  • for TCP/IP: host name/IP of the server-side (can include port) + *
  • for UNIX domain sockets: path of domain socket file + *
  • for named pipes: name of pipe + *
+ * @return {@link OutgoingRemoteCallTracer} instance to work with + * @since 1.0 + */ + OutgoingRemoteCallTracer traceOutgoingRemoteCall(String serviceMethod, String serviceName, String serviceEndpoint, + ChannelType channelType, String channelEndpoint); + + // ***** in-process-linking ***** + /** + * Creates a link for in-process-linking. + * + * @return {@link InProcessLink} instance to work with. Use it with + * {@link #traceInProcessLink(InProcessLink)} + * @since 1.1 + */ + InProcessLink createInProcessLink(); + + /** + * Traces the start of in-process-linking. + * + * @param inProcessLink + * a InProcessLink received via {@link #createInProcessLink()} + * @return {@link InProcessLinkTracer} to work with. + * @since 1.1 + */ + InProcessLinkTracer traceInProcessLink(InProcessLink inProcessLink); + + // ***** Custom request attributes ***** + /** + * Adds a custom request attribute to currently traced service call. Might be + * called multiple times, to add more than one attribute. Check via + * {@link #setLoggingCallback(LoggingCallback)} if error happened. If two + * attributes with same key are set, both attribute-values are captured. + * + * @param key + * key of the attribute. required parameter. + * @param value + * value of the attribute. required parameter. + * @since 1.2 + */ + void addCustomRequestAttribute(String key, String value); + + /** + * Does exactly the same as {@link #addCustomRequestAttribute(String, String)}, + * but request-attribute type long. + * + * @since 1.2 + */ + void addCustomRequestAttribute(String key, long value); + + /** + * Does exactly the same as {@link #addCustomRequestAttribute(String, String)}, + * but request-attribute type double. + * + * @since 1.2 + */ + void addCustomRequestAttribute(String key, double value); + + // ***** Messaging (outgoing & incoming) ***** + + /** + * Initializes a MessagingSystemInfo instance that is required for tracing messages. + * + * @param vendorName one of {@link com.dynatrace.oneagent.sdk.api.enums.MessageSystemVendor} if well known vendor. Custom provided in any other case. + * @param destinationName destination name (e.g. queue name, topic name) + * @param destinationType destination type - see {@link MessageDestinationType}. + * @param channelType communication protocol used + * @param channelEndpoint optional and depending on protocol: + * * for TCP/IP: host name/IP of the server-side (can include port) + * * for UNIX domain sockets: name of domain socket file + * * for named pipes: name of pipe + * @return {@link MessagingSystemInfo} instance to work with + * + * @since 1.5 + */ + MessagingSystemInfo createMessagingSystemInfo(String vendorName, String destinationName, MessageDestinationType destinationType, ChannelType channelType, String channelEndpoint); + + /** + * Creates a tracer for an outgoing asynchronous message (send). + * + * @param messagingSystem information about the messaging system (see createMessagingSystemInfo methods). + * @return {@link OutgoingMessageTracer} to work with + * + * @since 1.5 + */ + OutgoingMessageTracer traceOutgoingMessage(MessagingSystemInfo messagingSystem); + + /** + * Creates a tracer for an incoming asynchronous message (blocking receive). + * + * @param messagingSystem information about the messaging system (see createMessagingSystemInfo methods). + * @return {@link IncomingMessageReceiveTracer} to work with + * + * @since 1.5 + */ + IncomingMessageReceiveTracer traceIncomingMessageReceive(MessagingSystemInfo messagingSystem); + + /** + * Creates a tracer for processing (consuming) a received message (onMessage). + * + * @param messagingSystem information about the messaging system (see createMessagingSystemInfo methods). + * @return {@link IncomingMessageProcessTracer} to work with + * + * @since 1.5 + */ + IncomingMessageProcessTracer traceIncomingMessageProcess(MessagingSystemInfo messagingSystem); + + // ***** various ***** + + /** + * Installs a callback that gets informed, if any SDK action has failed. For + * details see {@link LoggingCallback} interface. The provided callback must be + * thread-safe, when using this {@link OneAgentSDK} instance in multi-threaded + * environments. + * + * @param loggingCallback + * may be null, to remove current callback. provided callback + * replaces any previously set callback. + * @since 1.0 + */ + void setLoggingCallback(LoggingCallback loggingCallback); + + /** + * Returns the current SDKState. See {@link SDKState} for details. + * + * @return current state - never null. + * @since 1.0 + */ + SDKState getCurrentState(); + + /** + * Creates a tracer for a custom transaction (Dynatrace calls them Custom service). Used whenever a transaction + * should be traced, that does not match any of the specialised transaction types (e. g. DB-request, webrequest, ...). + * + * @param serviceMethod service method being used for service creation. + * @param serviceName service name being used for service creation. + * + * @return {@link CustomServiceTracer} to work with + * @since 1.8 + */ + CustomServiceTracer traceCustomService(String serviceMethod, String serviceName); + + /** + * Returns the current W3C trace context for log enrichment + * (not meant for tagging and context-propagation but for log-enrichment). + * See {@link TraceContextInfo} for details. + * + * @return current trace context at the time of the call - never null (but may contain all-zero ID). + * @since 1.9 + */ + TraceContextInfo getTraceContextInfo(); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.java new file mode 100644 index 0000000..f1a32d1 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingMessageTracer.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Interface for outgoing message tracer. + * https://github.com/Dynatrace/OneAgent-SDK#messaging + * + * @since 1.5 + */ +public interface OutgoingMessageTracer extends Tracer, OutgoingTaggable { + + /** + * Adds optional information about a traced message: message id provided by messaging system. + * + * @param vendorMessageId the messageId + */ + public void setVendorMessageId(String vendorMessageId); + + /** + * Adds optional information about a traced message: correlation id used by messaging system. + * + * @param correlationId correlationId + */ + public void setCorrelationId(String correlationId); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.java new file mode 100644 index 0000000..4c4d7fc --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingRemoteCallTracer.java @@ -0,0 +1,37 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Represents the client side of a remote call. + * + * This Interface extends {@link Tracer} - it is important to respect the + * mentioned requirements when working with {@link OutgoingRemoteCallTracer}. + * + */ +public interface OutgoingRemoteCallTracer extends Tracer, OutgoingTaggable { + + /** + * Sets the name of the used remoting protocol. Setting the protocol name is + * optional. + * + * @param protocolName + * protocol name. null value is ignored. + * @since 1.0 + */ + void setProtocolName(String protocolName); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.java b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.java new file mode 100644 index 0000000..1592d89 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingTaggable.java @@ -0,0 +1,44 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Common interface for client-tagging-related methods. Not to be directly used + * by SDK user. + */ +public interface OutgoingTaggable { + + /** + * Creates a Dynatrace tag and returns the String representation of it. This tag + * has to be transported with the remoting protocol to the destination.
+ * See {@link IncomingTaggable} how to continue a path with provided tag on the + * server side. + * + * @return the tag - never null. + * @since 1.0 + */ + String getDynatraceStringTag(); + + /** + * Same as {@link #getDynatraceStringTag()}, but returning the tag as binary + * representation. + * + * @return the tag - never null. + * @since 1.0 + */ + byte[] getDynatraceByteTag(); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.java new file mode 100644 index 0000000..98c4211 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/OutgoingWebRequestTracer.java @@ -0,0 +1,56 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Represents client side of an outgoing webrequest. + * + * @since 1.4 + * + */ +public interface OutgoingWebRequestTracer extends Tracer, OutgoingTaggable { + + /** + * All HTTP request headers should be provided to this method. Selective + * capturing will be done based on sensor configuration. + * + * @param name + * HTTP request header field name + * @param value + * HTTP request header field value + */ + void addRequestHeader(String name, String value); + + /** + * All HTTP response headers returned by the server should be provided to this + * method. Selective capturing will be done based on sensor configuration. + * + * @param name + * HTTP response header field name + * @param value + * HTTP response header field value + */ + void addResponseHeader(String name, String value); + + /** + * Sets the HTTP response status code. + * + * @param statusCode + * HTTP status code retrieved from server + */ + void setStatusCode(int statusCode); + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/Tracer.java b/src/main/java/com/dynatrace/oneagent/sdk/api/Tracer.java new file mode 100644 index 0000000..b8c8570 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/Tracer.java @@ -0,0 +1,86 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api; + +/** + * Common interface for timing-related methods. Not to be directly used by SDK + * user. + */ +public interface Tracer { + + /** + * starts timing of a node. Every node that has been started, must be ended with + * {@link #end()} method. Consider using the following pattern: + * + *
+	 * {@code
+	 *   tracer.start();
+	 *   try {
+	 *     // do your work
+	 *   } catch (Exception e) {
+	 *     tracer.error(e);
+	 *   } finally {
+	 *     tracer.end();
+	 *   }
+	 * }
+	 * 
+ * + * {@link #start()}, {@link #end()}, {@link #error(String)}, + * {@link #error(Throwable)} are not thread-safe. They must be called from the + * same thread where {@link #start()} has been invoked. + * + * @since 1.0 + */ + void start(); + + /** + * Ends timing of a node. Typically this method is called via finally block. + *
+ * {@link #start()}, {@link #end()}, {@link #error(String)}, + * {@link #error(Throwable)} are not thread-safe. They must be called from the + * same thread where {@link #start()} has been invoked. + * + * @since 1.0 + */ + void end(); + + /** + * Marks the node as 'exited by exception'. An additional error message can be + * provided as String.
+ * {@link #start()}, {@link #end()}, {@link #error(String)}, + * {@link #error(Throwable)} are not thread-safe. They must be called from the + * same thread where {@link #start()} has been invoked. + * + * @param message + * error message with details about occurred error (eg. return code). + * must not be null. + * @since 1.0 + */ + void error(String message); + + /** + * Marks the node as 'exited by exception'.Additional information can be + * provided as Throwable.
+ * {@link #start()}, {@link #end()}, {@link #error(String)}, + * {@link #error(Throwable)} are not thread-safe. They must be called from the + * same thread where {@link #start()} has been invoked. + * + * @param throwable + * exception, that occurred. must not null. + * @since 1.0 + */ + void error(Throwable throwable); +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/enums/ChannelType.java b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/ChannelType.java new file mode 100644 index 0000000..2f44299 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/ChannelType.java @@ -0,0 +1,38 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.enums; + +/** + * Defines the type of communication channel being used. + * + * @author Alram.Lechner + * + */ +public enum ChannelType { + + OTHER(0), TCP_IP(1), UNIX_DOMAIN_SOCKET(2), NAMED_PIPE(3), IN_PROCESS(4); + + /** constant is being used in API call to OneAgent. don't change it! */ + private final int sdkConstant; + + private ChannelType(int sdkConstant) { + this.sdkConstant = sdkConstant; + } + + public int getSDKConstant() { + return sdkConstant; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.java b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.java new file mode 100644 index 0000000..c140f90 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/DatabaseVendor.java @@ -0,0 +1,78 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.enums; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Enumerates all well-known database vendors. See {@link OneAgentSDK#createDatabaseInfo(String, String, ChannelType, String)}. + * Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. + * @since 1.7.0 + */ +public enum DatabaseVendor { + + APACHE_HIVE("ApacheHive"), + CLOUDSCAPE("Cloudscape"), + HSQLDB("HSQLDB"), + PROGRESS("Progress"), + MAXDB("MaxDB"), + HANADB("HanaDB"), + INGRES("Ingres"), + FIRST_SQL("FirstSQL"), + ENTERPRISE_DB("EnterpriseDB"), + CACHE("Cache"), + ADABAS("Adabas"), + FIREBIRD("Firebird"), + DB2("DB2"), + DERBY_CLIENT("Derby Client"), + DERBY_EMBEDDED("Derby Embedded"), + FILEMAKER("Filemaker"), + INFORMIX("Informix"), + INSTANT_DB("InstantDb"), + INTERBASE("Interbase"), + MYSQL("MySQL"), + MARIADB("MariaDB"), + NETEZZA("Netezza"), + ORACLE("Oracle"), + PERVASIVE("Pervasive"), + POINTBASE("Pointbase"), + POSTGRESQL("PostgreSQL"), + SQLSERVER("SQL Server"), + SQLITE("sqlite"), + SYBASE("Sybase"), + TERADATA("Teradata"), + VERTICA("Vertica"), + CASSANDRA("Cassandra"), + H2("H2"), + COLDFUSION_IMQ("ColdFusion IMQ"), + REDSHIFT("Amazon Redshift"), + COUCHBASE("Couchbase"); + + private final String vendorName; + + private DatabaseVendor(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorName() { + return vendorName; + } + + @Override + public String toString() { + return vendorName; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.java b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.java new file mode 100644 index 0000000..ef9ab54 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageDestinationType.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.enums; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Enumerates all well-known messaging destination types. See + * {@link OneAgentSDK#createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String)} + * + * @since 1.5 + */ +public enum MessageDestinationType { + + QUEUE("Queue"), + TOPIC("Topic"); + + private final String name; + + private MessageDestinationType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.java b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.java new file mode 100644 index 0000000..4387e0e --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/MessageSystemVendor.java @@ -0,0 +1,52 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.enums; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Enumerates all well-known messaging systems. See {@link OneAgentSDK#createMessagingSystemInfo(String, String, MessageDestinationType, ChannelType, String)}. + * Using these constants ensures that services captured by OneAgentSDK are handled the same way as traced via built-in sensors. + * + * @since 1.5 + */ +public enum MessageSystemVendor { + + HORNETQ("HornetQ"), + ACTIVE_MQ("ActiveMQ"), + RABBIT_MQ("RabbitMQ"), + ARTEMIS("Artemis"), + WEBSPHERE("WebSphere"), + MQSERIES_JMS("MQSeries JMS"), + MQSERIES("MQSeries"), + TIBCO("Tibco"); + + private final String vendorName; + + private MessageSystemVendor(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorName() { + return vendorName; + } + + @Override + public String toString() { + return vendorName; + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/enums/SDKState.java b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/SDKState.java new file mode 100644 index 0000000..3c63ee1 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/enums/SDKState.java @@ -0,0 +1,48 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.enums; + +/** + * Defines the possible states of the SDK. + */ +public enum SDKState { + + /** + * SDK is connected to OneAgent and capturing data. + * + * @since 1.0 + */ + ACTIVE, + + /** + * SDK is connected to OneAgent, but capturing is disabled.It is good practice + * to skip creating SDK transactions to save resources. The SDK state should be + * checked regularly as it may change at every point in time. + * + * @since 1.0 + */ + TEMPORARILY_INACTIVE, + + /** + * SDK isn't connected to OneAgent, so it will never capture data. This SDK + * state will never change during the lifetime of a JVM. It is good practice to + * never call any SDK API to save resources. + * + * @since 1.0 + */ + PERMANENTLY_INACTIVE; + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.java b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.java new file mode 100644 index 0000000..4aa3a04 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/DatabaseInfo.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.infos; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Type returned by {@link OneAgentSDK#createDatabaseInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)} + * @since 1.7.0 + */ +public interface DatabaseInfo { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.java b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.java new file mode 100644 index 0000000..0399199 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/MessagingSystemInfo.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.infos; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Type returned by {@link OneAgentSDK#createMessagingSystemInfo(String, String, com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType, com.dynatrace.oneagent.sdk.api.enums.ChannelType, String)} + * + * @since 1.5 + */ +public interface MessagingSystemInfo { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.java b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.java new file mode 100644 index 0000000..0e4d408 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/TraceContextInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.infos; + +/** + * Provides information about a PurePath node using the TraceContext (Trace-Id, Span-Id) model as defined in + * These are a few common reasons for why you may be unable to get a valid trace context:
    + *
  • No OneAgent is present, or it is incompatible with this SDK version + * (check {@link com.dynatrace.oneagent.sdk.api.OneAgentSDK#getCurrentState()})
  • + *
  • There is no currently active PurePath context.
  • + *
  • Some other reason; more information may be available through {@link com.dynatrace.oneagent.sdk.api.OneAgentSDK#setLoggingCallback(com.dynatrace.oneagent.sdk.api.LoggingCallback)}
  • + *
+ *

+ * */ + boolean isValid(); + + /** The W3C trace ID hex string (never empty or null, but might be all-zero if {@link #isValid()}) is false) */ + String getTraceId(); + + /** The W3C span ID hex string (never empty or null, but might be all-zero if {@link #isValid()}) is false) */ + String getSpanId(); +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.java b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.java new file mode 100644 index 0000000..45348c7 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/api/infos/WebApplicationInfo.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.api.infos; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; + +/** + * Type returned by + * {@link OneAgentSDK#createWebApplicationInfo(String, String, String)} + * + * @since 1.3 + * + */ +public interface WebApplicationInfo { + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImpl.java new file mode 100644 index 0000000..ef44809 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImpl.java @@ -0,0 +1,73 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl; + +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.impl.noop.OneAgentSDKNoop; +import com.dynatrace.oneagent.sdk.impl.proxy.OneAgentSDKProxy; +import com.dynatrace.oneagent.sdk.impl.proxy.SDK2AgentInternalApiProxy; + +/** + * Entry point for customer application. + */ +public class OneAgentSDKFactoryImpl { + + /* + * increase version with every change. in case of non breaking change (to + * OneAgent), increase oneSdkFix only. + */ + static final int oneSdkMajor = 1; + static final int oneSdkMinor = 9; + static final int oneSdkFix = 0; + + public static final boolean debugOneAgentSdkStub = Boolean.parseBoolean(System.getProperty("com.dynatrace.oneagent.sdk.debug", "false")); + + private static OneAgentSDK createOneSDK() { + Object agentApiImpl = SDKInstanceProvider.create(oneSdkMajor, oneSdkMinor, oneSdkFix); + if (agentApiImpl == null) { + // OneAgent not present or not compatible + if (debugOneAgentSdkStub) { + logDebug("- no OneAgent present or OneAgent declined to work with OneAgentSdk version " + oneSdkMajor + + "." + oneSdkMinor + "." + oneSdkFix); + } + return new OneAgentSDKNoop(); + } + try { + SDK2AgentInternalApiProxy agentApi = new SDK2AgentInternalApiProxy(agentApiImpl); + Object agentSdkImpl = agentApi.oneAgentSDKFactory_createSdk(); + if (agentSdkImpl != null) { + return new OneAgentSDKProxy(agentApi, agentSdkImpl); + } + if (debugOneAgentSdkStub) { + logDebug("- OneAgent failed to provide sdk object."); + } + return new OneAgentSDKNoop(); + } catch (Throwable e) { + if (debugOneAgentSdkStub) { + logDebug("- failed to contact OneAgent: " + e.getClass().getName() + ": " + e.getMessage()); + } + return new OneAgentSDKNoop(); + } + } + + public static OneAgentSDK createInstance() { + return createOneSDK(); + } + + public static void logDebug(String msg) { + System.out.println("[onesdk ] " + msg); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProvider.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProvider.java new file mode 100644 index 0000000..e9018aa --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProvider.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl; + +/** class gets replaced by OneAgent, if OneAgent is loaded. */ +class SDKInstanceProvider { + + /** + * @return SDK Object provided by OneAgent. null if no OneAgent is loaded or + * declines to work with current SDK. + */ + static Object create(int onesdkmajor, int onesdkminor, int onesdkfix) { + return null; + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/CustomServiceTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/CustomServiceTracerNoop.java new file mode 100644 index 0000000..4473460 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/CustomServiceTracerNoop.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; + +public final class CustomServiceTracerNoop extends NodeNoop implements CustomServiceTracer { + + public static final CustomServiceTracer INSTANCE = new CustomServiceTracerNoop(); + + private CustomServiceTracerNoop() { + } + + @Override + public void start() { + } + + @Override + public void end() { + } + + @Override + public void error(String message) { + } + + @Override + public void error(Throwable throwable) { + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseInfoNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseInfoNoop.java new file mode 100644 index 0000000..cddafac --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseInfoNoop.java @@ -0,0 +1,25 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; + +public final class DatabaseInfoNoop implements DatabaseInfo { + public static final DatabaseInfo INSTANCE = new DatabaseInfoNoop(); + + private DatabaseInfoNoop() { + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseRequestTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseRequestTracerNoop.java new file mode 100644 index 0000000..467ce07 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/DatabaseRequestTracerNoop.java @@ -0,0 +1,51 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; + +public final class DatabaseRequestTracerNoop extends NodeNoop implements DatabaseRequestTracer { + + public static final DatabaseRequestTracerNoop INSTANCE = new DatabaseRequestTracerNoop(); + + private DatabaseRequestTracerNoop() { + } + + @Override + public void start() { + } + + @Override + public void end() { + } + + @Override + public void error(String message) { + } + + @Override + public void error(Throwable throwable) { + } + + @Override + public void setReturnedRowCount(int rowsReturned) { + } + + @Override + public void setRoundTripCount(int roundTripCount) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkNoop.java new file mode 100644 index 0000000..b5d7769 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkNoop.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.InProcessLink; + +public final class InProcessLinkNoop implements InProcessLink { + + public final static InProcessLink INSTANCE = new InProcessLinkNoop(); + + private InProcessLinkNoop() { + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkTracerNoop.java new file mode 100644 index 0000000..a4ae5d8 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/InProcessLinkTracerNoop.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; + +public final class InProcessLinkTracerNoop extends NodeNoop implements InProcessLinkTracer { + + public final static InProcessLinkTracer INSTANCE = new InProcessLinkTracerNoop(); + + private InProcessLinkTracerNoop() { + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageProcessTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageProcessTracerNoop.java new file mode 100644 index 0000000..78377d7 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageProcessTracerNoop.java @@ -0,0 +1,44 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; + +public final class IncomingMessageProcessTracerNoop extends NodeNoop implements IncomingMessageProcessTracer { + + public static final IncomingMessageProcessTracerNoop INSTANCE = new IncomingMessageProcessTracerNoop(); + + private IncomingMessageProcessTracerNoop() { + } + + @Override + public void setDynatraceStringTag(String tag) { + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + } + + @Override + public void setVendorMessageId(String vendorMessageId) { + } + + @Override + public void setCorrelationId(String correlationId) { + } + + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageReceiveTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageReceiveTracerNoop.java new file mode 100644 index 0000000..0b25f0a --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingMessageReceiveTracerNoop.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; + +public final class IncomingMessageReceiveTracerNoop extends NodeNoop implements IncomingMessageReceiveTracer { + + public static final IncomingMessageReceiveTracerNoop INSTANCE = new IncomingMessageReceiveTracerNoop(); + + private IncomingMessageReceiveTracerNoop() { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingWebRequestTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingWebRequestTracerNoop.java new file mode 100644 index 0000000..e085f75 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/IncomingWebRequestTracerNoop.java @@ -0,0 +1,60 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; + +public final class IncomingWebRequestTracerNoop extends NodeNoop implements IncomingWebRequestTracer { + + public static final IncomingWebRequestTracer INSTANCE = new IncomingWebRequestTracerNoop(); + + private IncomingWebRequestTracerNoop() { + } + + @Override + public void setDynatraceStringTag(String tag) { + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + } + + @Override + public void setRemoteAddress(String remoteAddress) { + + } + + @Override + public void addRequestHeader(String name, String value) { + + } + + @Override + public void addParameter(String name, String value) { + + } + + @Override + public void addResponseHeader(String name, String value) { + + } + + @Override + public void setStatusCode(int statusCode) { + + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/MessagingSystemInfoNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/MessagingSystemInfoNoop.java new file mode 100644 index 0000000..e26536f --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/MessagingSystemInfoNoop.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; + +public final class MessagingSystemInfoNoop implements MessagingSystemInfo { + + public static final MessagingSystemInfoNoop INSTANCE = new MessagingSystemInfoNoop(); + + private MessagingSystemInfoNoop() { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/NodeNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/NodeNoop.java new file mode 100644 index 0000000..e1a589f --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/NodeNoop.java @@ -0,0 +1,41 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.Tracer; + +abstract class NodeNoop implements Tracer { + + protected static final byte[] NO_TAG_BLOB = new byte[] {}; + protected static final String NO_TAG_STRING = ""; + + @Override + public void start() { + } + + @Override + public void end() { + } + + @Override + public void error(String message) { + } + + @Override + public void error(Throwable throwable) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OneAgentSDKNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OneAgentSDKNoop.java new file mode 100644 index 0000000..0c82831 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OneAgentSDKNoop.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; +import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; +import com.dynatrace.oneagent.sdk.api.InProcessLink; +import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; +import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; +import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; +import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; +import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; +import com.dynatrace.oneagent.sdk.api.LoggingCallback; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; +import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; +import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; +import com.dynatrace.oneagent.sdk.api.enums.SDKState; +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; +import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; +import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; + +/** + * This class provides an empty (NOOP) implementation of the {@link OneAgentSDK} + * interface. + * + * @author Alram.Lechner + * + */ +public final class OneAgentSDKNoop implements OneAgentSDK { + + // ***** Webrequests (incoming) ***** + @Override + public WebApplicationInfo createWebApplicationInfo(String webServerName, String applicationID, String contextRoot) { + return WebApplicationInfoNoop.INSTANCE; + } + + @Override + public IncomingWebRequestTracer traceIncomingWebRequest(WebApplicationInfo webApplicationInfo, String url, + String method) { + return IncomingWebRequestTracerNoop.INSTANCE; + } + + // ***** Remote Calls (outgoing & incoming) ***** + @Override + public IncomingRemoteCallTracer traceIncomingRemoteCall(String remoteMethod, String remoteService, + String clientEndpoint) { + return RemoteCallServerTracerNoop.INSTANCE; + } + + @Override + public OutgoingRemoteCallTracer traceOutgoingRemoteCall(String remoteMethod, String remoteService, + String serviceEndpoint, ChannelType channelType, String channelEndpoint) { + return RemoteCallClientTracerNoop.INSTANCE; + } + + // ***** Common ***** + + @Override + public void setLoggingCallback(LoggingCallback loggingCallback) { + } + + @Override + public SDKState getCurrentState() { + return SDKState.PERMANENTLY_INACTIVE; + } + + @Override + public InProcessLink createInProcessLink() { + return InProcessLinkNoop.INSTANCE; + } + + @Override + public InProcessLinkTracer traceInProcessLink(InProcessLink inProcessLink) { + return InProcessLinkTracerNoop.INSTANCE; + } + + @Override + public void addCustomRequestAttribute(String key, String value) { + } + + @Override + public void addCustomRequestAttribute(String key, long value) { + } + + @Override + public void addCustomRequestAttribute(String key, double value) { + } + + @Override + public OutgoingWebRequestTracer traceOutgoingWebRequest(String url, String method) { + return OutgoingWebRequestTracerNoop.INSTANCE; + } + + @Override + public MessagingSystemInfo createMessagingSystemInfo(String vendorName, String destinationName, + MessageDestinationType destinationType, ChannelType channelType, String channelEndpoint) { + return MessagingSystemInfoNoop.INSTANCE; + } + + @Override + public OutgoingMessageTracer traceOutgoingMessage(MessagingSystemInfo messagingSystem) { + return OutgoingMessageTracerNoop.INSTANCE; + } + + @Override + public IncomingMessageReceiveTracer traceIncomingMessageReceive(MessagingSystemInfo messagingSystem) { + return IncomingMessageReceiveTracerNoop.INSTANCE; + } + + @Override + public IncomingMessageProcessTracer traceIncomingMessageProcess(MessagingSystemInfo messagingSystem) { + return IncomingMessageProcessTracerNoop.INSTANCE; + } + + @Override + public DatabaseInfo createDatabaseInfo(String name, String vendor, ChannelType channelType, + String channelEndpoint) { + return DatabaseInfoNoop.INSTANCE; + } + + @Override + public DatabaseRequestTracer traceSqlDatabaseRequest(DatabaseInfo databaseInfo, String statement) { + return DatabaseRequestTracerNoop.INSTANCE; + } + + @Override + public CustomServiceTracer traceCustomService(String serviceMethod, String serviceName) { + return CustomServiceTracerNoop.INSTANCE; + } + + @Override + public TraceContextInfo getTraceContextInfo() { + return TraceContextInfoNoop.INSTANCE; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingMessageTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingMessageTracerNoop.java new file mode 100644 index 0000000..1c47bd7 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingMessageTracerNoop.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; + +public final class OutgoingMessageTracerNoop extends NodeNoop implements OutgoingMessageTracer { + + public static final OutgoingMessageTracerNoop INSTANCE = new OutgoingMessageTracerNoop(); + + private OutgoingMessageTracerNoop() { + } + + @Override + public void start() { + } + + @Override + public void end() { + } + + @Override + public void error(String message) { + } + + @Override + public void error(Throwable throwable) { + } + + @Override + public String getDynatraceStringTag() { + return NO_TAG_STRING; + } + + @Override + public byte[] getDynatraceByteTag() { + return NO_TAG_BLOB; + } + + @Override + public void setVendorMessageId(String vendorMessageId) { + + } + + @Override + public void setCorrelationId(String correlationId) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingWebRequestTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingWebRequestTracerNoop.java new file mode 100644 index 0000000..05150e5 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/OutgoingWebRequestTracerNoop.java @@ -0,0 +1,48 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; + +public final class OutgoingWebRequestTracerNoop extends NodeNoop implements OutgoingWebRequestTracer { + public static final OutgoingWebRequestTracerNoop INSTANCE = new OutgoingWebRequestTracerNoop(); + + private OutgoingWebRequestTracerNoop() { + } + + @Override + public String getDynatraceStringTag() { + return NO_TAG_STRING; + } + + @Override + public byte[] getDynatraceByteTag() { + return NO_TAG_BLOB; + } + + @Override + public void addRequestHeader(String name, String value) { + } + + @Override + public void addResponseHeader(String name, String value) { + } + + @Override + public void setStatusCode(int statusCode) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallClientTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallClientTracerNoop.java new file mode 100644 index 0000000..9603329 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallClientTracerNoop.java @@ -0,0 +1,41 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; + +public final class RemoteCallClientTracerNoop extends NodeNoop implements OutgoingRemoteCallTracer { + + public static final OutgoingRemoteCallTracer INSTANCE = new RemoteCallClientTracerNoop(); + + private RemoteCallClientTracerNoop() { + } + + @Override + public String getDynatraceStringTag() { + return NO_TAG_STRING; + } + + @Override + public byte[] getDynatraceByteTag() { + return NO_TAG_BLOB; + } + + @Override + public void setProtocolName(String protocolName) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallServerTracerNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallServerTracerNoop.java new file mode 100644 index 0000000..8543d64 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/RemoteCallServerTracerNoop.java @@ -0,0 +1,39 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; + +public final class RemoteCallServerTracerNoop extends NodeNoop implements IncomingRemoteCallTracer { + + public static final IncomingRemoteCallTracer INSTANCE = new RemoteCallServerTracerNoop(); + + private RemoteCallServerTracerNoop() { + } + + @Override + public void setDynatraceStringTag(String tag) { + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + } + + @Override + public void setProtocolName(String protocolName) { + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/TraceContextInfoNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/TraceContextInfoNoop.java new file mode 100644 index 0000000..363f3eb --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/TraceContextInfoNoop.java @@ -0,0 +1,39 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; + +public final class TraceContextInfoNoop implements TraceContextInfo { + public static final TraceContextInfoNoop INSTANCE = new TraceContextInfoNoop(); + + private TraceContextInfoNoop() {} + + @Override + public boolean isValid() { + return false; + } + + @Override + public String getTraceId() { + return INVALID_TRACE_ID; + } + + @Override + public String getSpanId() { + return INVALID_SPAN_ID; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/WebApplicationInfoNoop.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/WebApplicationInfoNoop.java new file mode 100644 index 0000000..0dedec2 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/noop/WebApplicationInfoNoop.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.noop; + +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; + +public final class WebApplicationInfoNoop implements WebApplicationInfo { + + public static final WebApplicationInfo INSTANCE = new WebApplicationInfoNoop(); + + private WebApplicationInfoNoop() { + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/CustomServiceTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/CustomServiceTracerProxy.java new file mode 100644 index 0000000..1abd4f4 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/CustomServiceTracerProxy.java @@ -0,0 +1,25 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; + +final class CustomServiceTracerProxy extends TraceableProxy implements CustomServiceTracer { + + CustomServiceTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object customServiceTracer) { + super(apiProxy, customServiceTracer); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseInfoImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseInfoImpl.java new file mode 100644 index 0000000..8761907 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseInfoImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; + +final class DatabaseInfoImpl implements DatabaseInfo { + + private final String name; + private final String vendor; + private final ChannelType channelType; + private final String channelEndpoint; + + DatabaseInfoImpl(String name, String vendor, ChannelType channelType, String channelEndpoint) { + this.name = name; + this.vendor = vendor; + this.channelType = channelType; + this.channelEndpoint = channelEndpoint; + } + + String getName() { + return name; + } + + String getVendor() { + return vendor; + } + + ChannelType getChannelType() { + return channelType; + } + + String getChannelEndpoint() { + return channelEndpoint; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseRequestTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseRequestTracerProxy.java new file mode 100644 index 0000000..83982cf --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/DatabaseRequestTracerProxy.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; + +final class DatabaseRequestTracerProxy extends TraceableProxy implements DatabaseRequestTracer { + + DatabaseRequestTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object outgoingMessageTracer) { + super(apiProxy, outgoingMessageTracer); + } + + @Override + public void setReturnedRowCount(int rowsReturned) { + apiProxy.databaseRequestTracer_setRowsReturned(agentsNodeObject, rowsReturned); + } + + @Override + public void setRoundTripCount(int roundTripCount) { + apiProxy.databaseRequestTracer_setRoundTripCount(agentsNodeObject, roundTripCount); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkImpl.java new file mode 100644 index 0000000..51abed2 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkImpl.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.InProcessLink; + +final class InProcessLinkImpl implements InProcessLink { + + private final Object agentProvidedLink; + + InProcessLinkImpl(Object agentProvidedLink) { + this.agentProvidedLink = agentProvidedLink; + } + + Object getAgentProvidedLink() { + return agentProvidedLink; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkTracerProxy.java new file mode 100644 index 0000000..5c6d8d3 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/InProcessLinkTracerProxy.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; + +final class InProcessLinkTracerProxy extends TraceableProxy implements InProcessLinkTracer { + + InProcessLinkTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object node) { + super(apiProxy, node); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageProcessTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageProcessTracerProxy.java new file mode 100644 index 0000000..ee7432b --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageProcessTracerProxy.java @@ -0,0 +1,45 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; + +final class IncomingMessageProcessTracerProxy extends TraceableProxy implements IncomingMessageProcessTracer { + + IncomingMessageProcessTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { + super(apiProxy, agentObject); + } + + @Override + public void setDynatraceStringTag(String tag) { + apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); + } + + @Override + public void setVendorMessageId(String vendorMessageId) { + apiProxy.messageTracer_setVendorMessageId(agentsNodeObject, vendorMessageId); + } + + @Override + public void setCorrelationId(String correlationId) { + apiProxy.messageTracer_setCorrelationId(agentsNodeObject, correlationId); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageReceiveTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageReceiveTracerProxy.java new file mode 100644 index 0000000..f72a118 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingMessageReceiveTracerProxy.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; + +final class IncomingMessageReceiveTracerProxy extends TraceableProxy implements IncomingMessageReceiveTracer { + + IncomingMessageReceiveTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { + super(apiProxy, agentObject); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingWebRequestProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingWebRequestProxy.java new file mode 100644 index 0000000..93f2dd9 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/IncomingWebRequestProxy.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; + +final class IncomingWebRequestProxy extends TraceableProxy implements IncomingWebRequestTracer { + + IncomingWebRequestProxy(SDK2AgentInternalApiProxy apiProxy, Object agentObject) { + super(apiProxy, agentObject); + } + + @Override + public void setDynatraceStringTag(String tag) { + apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); + } + + @Override + public void setRemoteAddress(String remoteAddress) { + apiProxy.incomingWebRequestTracer_setRemoteAddress(agentsNodeObject, remoteAddress); + + } + + @Override + public void addRequestHeader(String name, String value) { + apiProxy.webRequestTracer_addRequestHeader(agentsNodeObject, name, value); + } + + @Override + public void addParameter(String name, String value) { + apiProxy.incomingWebRequestTracer_addParameter(agentsNodeObject, name, value); + } + + @Override + public void addResponseHeader(String name, String value) { + apiProxy.webRequestTracer_addResponseHeader(agentsNodeObject, name, value); + } + + @Override + public void setStatusCode(int statusCode) { + apiProxy.webRequestTracer_setStatusCode(agentsNodeObject, statusCode); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/MessagingSystemInfoImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/MessagingSystemInfoImpl.java new file mode 100644 index 0000000..e2fd3bf --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/MessagingSystemInfoImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; + +final class MessagingSystemInfoImpl implements com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo { + + private final String vendorName; + private final String destinationName; + private final MessageDestinationType destinationType; + private final ChannelType channelType; + private final String channelEndpoint; + + MessagingSystemInfoImpl(String vendorName, String destinationName, MessageDestinationType destinationType, + ChannelType channelType, String channelEndpoint) { + this.vendorName = vendorName; + this.destinationName = destinationName; + this.destinationType = destinationType; + this.channelType = channelType; + this.channelEndpoint = channelEndpoint; + } + + String getVendorName() { + return vendorName; + } + + String getDestinationName() { + return destinationName; + } + + MessageDestinationType getDestinationType() { + return destinationType; + } + + ChannelType getChannelType() { + return channelType; + } + + String getChannelEndpoint() { + return channelEndpoint; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OneAgentSDKProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OneAgentSDKProxy.java new file mode 100644 index 0000000..3af92f2 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OneAgentSDKProxy.java @@ -0,0 +1,331 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import java.util.Map; + +import com.dynatrace.oneagent.sdk.api.CustomServiceTracer; +import com.dynatrace.oneagent.sdk.api.DatabaseRequestTracer; +import com.dynatrace.oneagent.sdk.api.InProcessLink; +import com.dynatrace.oneagent.sdk.api.InProcessLinkTracer; +import com.dynatrace.oneagent.sdk.api.IncomingMessageProcessTracer; +import com.dynatrace.oneagent.sdk.api.IncomingMessageReceiveTracer; +import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; +import com.dynatrace.oneagent.sdk.api.IncomingWebRequestTracer; +import com.dynatrace.oneagent.sdk.api.LoggingCallback; +import com.dynatrace.oneagent.sdk.api.OneAgentSDK; +import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; +import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; +import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; +import com.dynatrace.oneagent.sdk.api.enums.ChannelType; +import com.dynatrace.oneagent.sdk.api.enums.MessageDestinationType; +import com.dynatrace.oneagent.sdk.api.enums.SDKState; +import com.dynatrace.oneagent.sdk.api.infos.DatabaseInfo; +import com.dynatrace.oneagent.sdk.api.infos.MessagingSystemInfo; +import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; +import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; +import com.dynatrace.oneagent.sdk.impl.noop.CustomServiceTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.DatabaseInfoNoop; +import com.dynatrace.oneagent.sdk.impl.noop.DatabaseRequestTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.InProcessLinkNoop; +import com.dynatrace.oneagent.sdk.impl.noop.InProcessLinkTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.IncomingMessageProcessTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.IncomingMessageReceiveTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.IncomingWebRequestTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.MessagingSystemInfoNoop; +import com.dynatrace.oneagent.sdk.impl.noop.OutgoingMessageTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.OutgoingWebRequestTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.RemoteCallClientTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.RemoteCallServerTracerNoop; +import com.dynatrace.oneagent.sdk.impl.noop.TraceContextInfoNoop; +import com.dynatrace.oneagent.sdk.impl.noop.WebApplicationInfoNoop; + +/** TODO: check if/how class could be generated */ +public final class OneAgentSDKProxy implements OneAgentSDK { + + private final SDK2AgentInternalApiProxy apiProxy; + private final Object agentSdkImpl; + + public OneAgentSDKProxy(SDK2AgentInternalApiProxy apiProxy, Object agentSdkImpl) { + this.apiProxy = apiProxy; + this.agentSdkImpl = agentSdkImpl; + } + + @Override + public IncomingRemoteCallTracer traceIncomingRemoteCall(String remoteMethod, String remoteService, + String serviceEndpoint) { + Object agentObject = apiProxy.oneAgentSDK_traceIncomingRemoteCall(agentSdkImpl, remoteMethod, remoteService, + serviceEndpoint); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return RemoteCallServerTracerNoop.INSTANCE; + } + return new RemoteCallServerProxy(apiProxy, agentObject); + } + + @Override + public OutgoingRemoteCallTracer traceOutgoingRemoteCall(String remoteMethod, String remoteService, + String serverEndpoint, ChannelType channelType, String remoteHost) { + int iChannelType = -1; + if (channelType != null) { + iChannelType = channelType.getSDKConstant(); + } + Object agentObject = apiProxy.oneAgentSDK_traceOutgoingRemoteCall(agentSdkImpl, remoteMethod, remoteService, + serverEndpoint, iChannelType, remoteHost); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return RemoteCallClientTracerNoop.INSTANCE; + } + return new RemoteCallClientProxy(apiProxy, agentObject); + } + + @Override + public void setLoggingCallback(LoggingCallback loggingCallback) { + apiProxy.oneAgentSDK_setLoggingCallback(agentSdkImpl, loggingCallback); + } + + @Override + public SDKState getCurrentState() { + Boolean isCapturing = apiProxy.oneAgentSDK_isCapturing(agentSdkImpl); + if (isCapturing == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return SDKState.PERMANENTLY_INACTIVE; + } + if (isCapturing.booleanValue()) { + return SDKState.ACTIVE; + } else { + return SDKState.TEMPORARILY_INACTIVE; + } + } + + @Override + public InProcessLink createInProcessLink() { + Object agentProvidedLink = apiProxy.oneAgentSDK_createInProcessLink(agentSdkImpl); + if (agentProvidedLink == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide InProcessLink"); + } + return InProcessLinkNoop.INSTANCE; + } + return new InProcessLinkImpl(agentProvidedLink); + } + + @Override + public InProcessLinkTracer traceInProcessLink(InProcessLink inProcessLink) { + if (inProcessLink instanceof InProcessLinkNoop) { + return InProcessLinkTracerNoop.INSTANCE; + } else if (!(inProcessLink instanceof InProcessLinkImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid InProcessLink object provided: " + + (inProcessLink == null ? "null" : inProcessLink.getClass().getName())); + } + return InProcessLinkTracerNoop.INSTANCE; + } + + Object agentObject = apiProxy.oneAgentSDK_traceInProcessLink(agentSdkImpl, (InProcessLinkImpl) inProcessLink); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide InProcessLinkTracer"); + } + return InProcessLinkTracerNoop.INSTANCE; + } + return new InProcessLinkTracerProxy(apiProxy, agentObject); + } + + @Override + public void addCustomRequestAttribute(String key, String value) { + apiProxy.oneAgentSDK_addCustomRequestAttribute(agentSdkImpl, key, value); + } + + @Override + public void addCustomRequestAttribute(String key, long value) { + apiProxy.oneAgentSDK_addCustomRequestAttribute(agentSdkImpl, key, value); + } + + @Override + public void addCustomRequestAttribute(String key, double value) { + apiProxy.oneAgentSDK_addCustomRequestAttribute(agentSdkImpl, key, value); + } + + @Override + public WebApplicationInfo createWebApplicationInfo(String webServerName, String applicationID, String contextRoot) { + return new WebApplicationInfoImpl(webServerName, applicationID, contextRoot); + } + + @Override + public IncomingWebRequestTracer traceIncomingWebRequest(WebApplicationInfo webApplicationInfo, String url, + String method) { + if (webApplicationInfo instanceof WebApplicationInfoNoop) { + return IncomingWebRequestTracerNoop.INSTANCE; + } else if (!(webApplicationInfo instanceof WebApplicationInfoImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid WebApplicationInfo object provided: " + + (webApplicationInfo == null ? "null" : webApplicationInfo.getClass().getName())); + } + return IncomingWebRequestTracerNoop.INSTANCE; + } + + Object agentObject = apiProxy.oneAgentSDK_traceIncomingWebRequest(agentSdkImpl, + (WebApplicationInfoImpl) webApplicationInfo, url, method); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return IncomingWebRequestTracerNoop.INSTANCE; + } + return new IncomingWebRequestProxy(apiProxy, agentObject); + } + + @Override + public OutgoingWebRequestTracer traceOutgoingWebRequest(String url, String method) { + Object agentObject = apiProxy.oneAgentSDK_traceOutgoingWebRequest(agentSdkImpl, url, method); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return OutgoingWebRequestTracerNoop.INSTANCE; + } + return new OutgoingWebRequestTracerProxy(apiProxy, agentObject); + } + + @Override + public MessagingSystemInfo createMessagingSystemInfo(String vendorName, String destinationName, + MessageDestinationType destinationType, ChannelType channelType, String channelEndpoint) { + return new MessagingSystemInfoImpl(vendorName, destinationName, destinationType, channelType, channelEndpoint); + } + + @Override + public OutgoingMessageTracer traceOutgoingMessage(MessagingSystemInfo messagingSystem) { + if (messagingSystem instanceof MessagingSystemInfoNoop) { + return OutgoingMessageTracerNoop.INSTANCE; + } else if (!(messagingSystem instanceof MessagingSystemInfoImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid MessagingSystemInfo object provided: " + + (messagingSystem == null ? "null" : messagingSystem.getClass().getName())); + } + return OutgoingMessageTracerNoop.INSTANCE; + } + + Object agentObject = apiProxy.oneAgentSDK_traceOutgoingMessage(agentSdkImpl, + (MessagingSystemInfoImpl) messagingSystem); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return OutgoingMessageTracerNoop.INSTANCE; + } + return new OutgoingMessageTracerProxy(apiProxy, agentObject); + } + + @Override + public IncomingMessageReceiveTracer traceIncomingMessageReceive(MessagingSystemInfo messagingSystem) { + if (messagingSystem instanceof MessagingSystemInfoNoop) { + return IncomingMessageReceiveTracerNoop.INSTANCE; + } else if (!(messagingSystem instanceof MessagingSystemInfoImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid MessagingSystemInfo object provided: " + + (messagingSystem == null ? "null" : messagingSystem.getClass().getName())); + } + return IncomingMessageReceiveTracerNoop.INSTANCE; + } + Object agentObject = apiProxy.oneAgentSDK_traceIncomingMessageReceive(agentSdkImpl, + (MessagingSystemInfoImpl) messagingSystem); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return IncomingMessageReceiveTracerNoop.INSTANCE; + } + return new IncomingMessageReceiveTracerProxy(apiProxy, agentObject); + } + + @Override + public IncomingMessageProcessTracer traceIncomingMessageProcess(MessagingSystemInfo messagingSystem) { + if (messagingSystem instanceof MessagingSystemInfoNoop) { + return IncomingMessageProcessTracerNoop.INSTANCE; + } else if (!(messagingSystem instanceof MessagingSystemInfoImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid MessagingSystemInfo object provided: " + + (messagingSystem == null ? "null" : messagingSystem.getClass().getName())); + } + return IncomingMessageProcessTracerNoop.INSTANCE; + } + Object agentObject = apiProxy.oneAgentSDK_traceIncomingMessageProcess(agentSdkImpl, + (MessagingSystemInfoImpl) messagingSystem); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return IncomingMessageProcessTracerNoop.INSTANCE; + } + return new IncomingMessageProcessTracerProxy(apiProxy, agentObject); + } + + @Override + public DatabaseInfo createDatabaseInfo(String name, String vendor, ChannelType channelType, + String channelEndpoint) { + return new DatabaseInfoImpl(name, vendor, channelType, channelEndpoint); + } + + @Override + public DatabaseRequestTracer traceSqlDatabaseRequest(DatabaseInfo databaseInfo, String statement) { + if (databaseInfo instanceof DatabaseInfoNoop) { + return DatabaseRequestTracerNoop.INSTANCE; + } else if (!(databaseInfo instanceof DatabaseInfoImpl)) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- invalid DatabaseInfo object provided: " + + (databaseInfo == null ? "null" : databaseInfo.getClass().getName())); + } + return DatabaseRequestTracerNoop.INSTANCE; + } + + Object agentObject = apiProxy.oneAgentSDK_traceSQLDatabaseRequest(agentSdkImpl, (DatabaseInfoImpl) databaseInfo, + statement); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return DatabaseRequestTracerNoop.INSTANCE; + } + return new DatabaseRequestTracerProxy(apiProxy, agentObject); + } + + @Override + public CustomServiceTracer traceCustomService(String serviceMethod, String serviceName) { + Object agentObject = apiProxy.oneAgentSDK_traceCustomService(agentSdkImpl, serviceMethod, serviceName); + if (agentObject == null) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + OneAgentSDKFactoryImpl.logDebug("- OneAgent failed to provide object"); + } + return CustomServiceTracerNoop.INSTANCE; + } + return new CustomServiceTracerProxy(apiProxy, agentObject); + } + + @Override + public TraceContextInfo getTraceContextInfo() { + Map.Entry traceAndSpanId = apiProxy.oneAgentSDK_getCurrentTraceAndSpanId(agentSdkImpl); + return traceAndSpanId == null ? TraceContextInfoNoop.INSTANCE : new TraceContextInfoImpl( + traceAndSpanId.getKey(), traceAndSpanId.getValue()); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingMessageTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingMessageTracerProxy.java new file mode 100644 index 0000000..603331f --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingMessageTracerProxy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.OutgoingMessageTracer; + +final class OutgoingMessageTracerProxy extends TraceableProxy implements OutgoingMessageTracer { + + OutgoingMessageTracerProxy(SDK2AgentInternalApiProxy apiProxy, Object outgoingMessageTracer) { + super(apiProxy, outgoingMessageTracer); + } + + @Override + public String getDynatraceStringTag() { + return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); + } + + @Override + public byte[] getDynatraceByteTag() { + return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); + } + + @Override + public void setVendorMessageId(String vendorMessageId) { + apiProxy.messageTracer_setVendorMessageId(agentsNodeObject, vendorMessageId); + } + + @Override + public void setCorrelationId(String correlationId) { + apiProxy.messageTracer_setCorrelationId(agentsNodeObject, correlationId); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingWebRequestTracerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingWebRequestTracerProxy.java new file mode 100644 index 0000000..5b23093 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/OutgoingWebRequestTracerProxy.java @@ -0,0 +1,52 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.OutgoingWebRequestTracer; + +final class OutgoingWebRequestTracerProxy extends TraceableProxy implements OutgoingWebRequestTracer { + + OutgoingWebRequestTracerProxy(SDK2AgentInternalApiProxy apiProxy, + Object oneAgentSDK_createOutgoingWebreqeustTracer) { + super(apiProxy, oneAgentSDK_createOutgoingWebreqeustTracer); + } + + @Override + public String getDynatraceStringTag() { + return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); + } + + @Override + public byte[] getDynatraceByteTag() { + return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); + } + + @Override + public void addRequestHeader(String name, String value) { + apiProxy.webRequestTracer_addRequestHeader(agentsNodeObject, name, value); + } + + @Override + public void addResponseHeader(String name, String value) { + apiProxy.webRequestTracer_addResponseHeader(agentsNodeObject, name, value); + } + + @Override + public void setStatusCode(int statusCode) { + apiProxy.webRequestTracer_setStatusCode(agentsNodeObject, statusCode); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallClientProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallClientProxy.java new file mode 100644 index 0000000..cfc799d --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallClientProxy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.OutgoingRemoteCallTracer; + +final class RemoteCallClientProxy extends TraceableProxy implements OutgoingRemoteCallTracer { + + RemoteCallClientProxy(SDK2AgentInternalApiProxy apiProxy, Object oneAgentSDK_createLocalOutgoingRemoteCall) { + super(apiProxy, oneAgentSDK_createLocalOutgoingRemoteCall); + } + + @Override + public String getDynatraceStringTag() { + return apiProxy.outgoingTaggable_getDynatraceStringTag(agentsNodeObject); + } + + @Override + public byte[] getDynatraceByteTag() { + return apiProxy.outgoingTaggable_getDynatraceByteTag(agentsNodeObject); + } + + @Override + public void setProtocolName(String protocolName) { + apiProxy.outgoingRemoteCallTracer_setProtocolName(agentsNodeObject, protocolName); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallServerProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallServerProxy.java new file mode 100644 index 0000000..db41704 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/RemoteCallServerProxy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.IncomingRemoteCallTracer; + +final class RemoteCallServerProxy extends TraceableProxy implements IncomingRemoteCallTracer { + + RemoteCallServerProxy(SDK2AgentInternalApiProxy apiProxy, Object remoteCallObject) { + super(apiProxy, remoteCallObject); + } + + @Override + public void setDynatraceStringTag(String tag) { + apiProxy.incomingTaggable_setDynatraceStringTag(agentsNodeObject, tag); + } + + @Override + public void setDynatraceByteTag(byte[] tag) { + apiProxy.incomingTaggable_setDynatraceByteTag(agentsNodeObject, tag); + } + + @Override + public void setProtocolName(String protocolName) { + apiProxy.incomingRemoteCallTracer_setProtocolName(agentsNodeObject, protocolName); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/SDK2AgentInternalApiProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/SDK2AgentInternalApiProxy.java new file mode 100644 index 0000000..efad0e4 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/SDK2AgentInternalApiProxy.java @@ -0,0 +1,323 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import java.lang.reflect.Method; +import java.util.Map; + +import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; + +/** + * class forwards every API call to OneAgent impl via pre loaded reflection + * calls. + * + * @author Alram.Lechner + * + */ +public final class SDK2AgentInternalApiProxy { + + private Object agentImpl; + private final Method oneAgentSDKFactory_createSdk; + private final Method oneAgentSDK_traceIncomingRemoteCall; + private final Method oneAgentSDK_traceOutgoingRemoteCall; + private final Method oneAgentSDK_createInProcessLink; + private final Method oneAgentSDK_traceInProcessLink; + private final Method oneAgentSDK_setLoggingCallback; + private final Method oneAgentSDK_isCapturing; + private final Method oneAgentSDK_addCustomRequestAttribute_1; // String, String + private final Method oneAgentSDK_addCustomRequestAttribute_2; // String, long + private final Method oneAgentSDK_addCustomRequestAttribute_3; // String, double + private final Method oneAgentSDK_traceIncomingWebRequest; + private final Method oneAgentSDK_traceOutgoingWebRequest; + private final Method oneAgentSDK_traceIncomingMessageReceive; + private final Method oneAgentSDK_traceIncomingMessageProcess; + private final Method oneAgentSDK_traceOutgoingMessage; + private final Method oneAgentSDK_traceSQLDatabaseRequest; + private final Method oneAgentSDK_traceCustomService; + private final Method tracer_start; + private final Method tracer_end; + private final Method tracer_error_1; // string + private final Method tracer_error_2; // throwable + private final Method outgoingTaggable_getDynatraceStringTag; + private final Method outgoingTaggable_getDynatraceByteTag; + private final Method incomingTaggable_setDynatraceStringTag; + private final Method incomingTaggable_setDynatraceByteTag; + private final Method outgoingRemoteCallTracer_setProtocolName; + private final Method incomingRemoteCallTracer_setProtocolName; + private final Method webRequestTracer_setStatusCode; + private final Method webRequestTracer_addResponseHeader; + private final Method webRequestTracer_addRequestHeader; + private final Method incomingWebRequestTracer_setRemoteAddress; + private final Method incomingWebRequestTracer_addParameter; + private final Method messageTracer_setVendorMessageId; + private final Method messageTracer_setCorrelationId; + private final Method databaseRequestTracer_setRowsReturned; + private final Method databaseRequestTracer_setRoundTripCount; + + private final Method oneAgentSDK_getCurrentTraceAndSpanId; + + public SDK2AgentInternalApiProxy(Object agentImpl) throws NoSuchMethodException, SecurityException { + this.agentImpl = agentImpl; + oneAgentSDKFactory_createSdk = findMethod("oneAgentSDKFactory_createSDK", new Class[] {}); + oneAgentSDK_traceIncomingRemoteCall = findMethod("oneAgentSDK_traceIncomingRemoteCall", + new Class[] { Object.class, String.class, String.class, String.class }); + oneAgentSDK_traceOutgoingRemoteCall = findMethod("oneAgentSDK_traceOutgoingRemoteCall", + new Class[] { Object.class, String.class, String.class, String.class, Integer.TYPE, String.class }); + oneAgentSDK_createInProcessLink = findMethod("oneAgentSDK_createInProcessLink", new Class[] { Object.class }); + oneAgentSDK_traceInProcessLink = findMethod("oneAgentSDK_traceInProcessLink", + new Class[] { Object.class, Object.class }); + oneAgentSDK_setLoggingCallback = findMethod("oneAgentSDK_setLoggingCallback", + new Class[] { Object.class, Object.class }); + oneAgentSDK_isCapturing = findMethod("oneAgentSDK_isCapturing", new Class[] { Object.class }); + oneAgentSDK_addCustomRequestAttribute_1 = findMethod("oneAgentSDK_addCustomRequestAttribute", + new Class[] { Object.class, String.class, String.class }); + oneAgentSDK_addCustomRequestAttribute_2 = findMethod("oneAgentSDK_addCustomRequestAttribute", + new Class[] { Object.class, String.class, Long.TYPE }); + oneAgentSDK_addCustomRequestAttribute_3 = findMethod("oneAgentSDK_addCustomRequestAttribute", + new Class[] { Object.class, String.class, Double.TYPE }); + oneAgentSDK_traceIncomingWebRequest = findMethod("oneAgentSDK_traceIncomingWebRequest", + new Class[] { Object.class, String.class, String.class, String.class, String.class, String.class }); + oneAgentSDK_traceOutgoingWebRequest = findMethod("oneAgentSDK_traceOutgoingWebRequest", + new Class[] { Object.class, String.class, String.class }); + oneAgentSDK_traceIncomingMessageReceive = findMethod("oneAgentSDK_traceIncomingMessageReceive", + new Class[] { Object.class, String.class, String.class, String.class, Integer.TYPE, String.class }); + oneAgentSDK_traceIncomingMessageProcess = findMethod("oneAgentSDK_traceIncomingMessageProcess", + new Class[] { Object.class, String.class, String.class, String.class, Integer.TYPE, String.class }); + oneAgentSDK_traceOutgoingMessage = findMethod("oneAgentSDK_traceOutgoingMessage", + new Class[] { Object.class, String.class, String.class, String.class, Integer.TYPE, String.class }); + oneAgentSDK_traceSQLDatabaseRequest = findMethod("oneAgentSDK_traceSQLDatabaseRequest", + new Class[] { Object.class, String.class, String.class, Integer.TYPE, String.class, String.class }); + oneAgentSDK_traceCustomService = findMethod("oneAgentSDK_traceCustomService", + new Class[] { Object.class, String.class, String.class }); + tracer_start = findMethod("tracer_start", new Class[] { Object.class }); + tracer_end = findMethod("tracer_end", new Class[] { Object.class }); + tracer_error_1 = findMethod("tracer_error", new Class[] { Object.class, String.class }); + tracer_error_2 = findMethod("tracer_error", new Class[] { Object.class, Throwable.class }); + outgoingTaggable_getDynatraceStringTag = findMethod("outgoingTaggable_getDynatraceStringTag", + new Class[] { Object.class }); + outgoingTaggable_getDynatraceByteTag = findMethod("outgoingTaggable_getDynatraceByteTag", + new Class[] { Object.class }); + incomingTaggable_setDynatraceStringTag = findMethod("incomingTaggable_setDynatraceStringTag", + new Class[] { Object.class, String.class }); + incomingTaggable_setDynatraceByteTag = findMethod("incomingTaggable_setDynatraceByteTag", + new Class[] { Object.class, byte[].class }); + outgoingRemoteCallTracer_setProtocolName = findMethod("outgoingRemoteCallTracer_setProtocolName", + new Class[] { Object.class, String.class }); + incomingRemoteCallTracer_setProtocolName = findMethod("incomingRemoteCallTracer_setProtocolName", + new Class[] { Object.class, String.class }); + webRequestTracer_setStatusCode = findMethod("webRequestTracer_setStatusCode", + new Class[] { Object.class, Integer.TYPE }); + webRequestTracer_addResponseHeader = findMethod("webRequestTracer_addResponseHeader", + new Class[] { Object.class, String.class, String.class }); + webRequestTracer_addRequestHeader = findMethod("webRequestTracer_addRequestHeader", + new Class[] { Object.class, String.class, String.class }); + incomingWebRequestTracer_setRemoteAddress = findMethod("incomingWebRequestTracer_setRemoteAddress", + new Class[] { Object.class, String.class }); + incomingWebRequestTracer_addParameter = findMethod("incomingWebRequestTracer_addParameter", + new Class[] { Object.class, String.class, String.class }); + messageTracer_setVendorMessageId = findMethod("messageTracer_setVendorMessageId", + new Class[] { Object.class, String.class }); + messageTracer_setCorrelationId = findMethod("messageTracer_setCorrelationId", + new Class[] { Object.class, String.class }); + databaseRequestTracer_setRowsReturned = findMethod("databaseRequestTracer_setRowsReturned", + new Class[] { Object.class, Integer.TYPE }); + databaseRequestTracer_setRoundTripCount = findMethod("databaseRequestTracer_setRoundTripCount", + new Class[] { Object.class, Integer.TYPE }); + + oneAgentSDK_getCurrentTraceAndSpanId = findMethod("oneAgentSDK_getCurrentTraceAndSpanId", + new Class[] {Object.class}); + } + + private Method findMethod(String name, Class... args) throws NoSuchMethodException, SecurityException { + return agentImpl.getClass().getMethod(name, args); + } + + private Object invoke(Method m, Object... args) { + try { + return m.invoke(agentImpl, args); + } catch (Exception e) { + if (OneAgentSDKFactoryImpl.debugOneAgentSdkStub) { + e.printStackTrace(); + } + return null; + } + } + + public Object oneAgentSDKFactory_createSdk() { + return invoke(oneAgentSDKFactory_createSdk); + } + + Object oneAgentSDK_traceIncomingRemoteCall(Object sdk, String remoteMethod, String remoteService, + String serviceEndpoint) { + return invoke(oneAgentSDK_traceIncomingRemoteCall, sdk, remoteMethod, remoteService, serviceEndpoint); + } + + Object oneAgentSDK_traceOutgoingRemoteCall(Object sdk, String remoteMethod, String remoteService, + String serverEndpoint, int channelType, String channelEndpoint) { + return invoke(oneAgentSDK_traceOutgoingRemoteCall, sdk, remoteMethod, remoteService, serverEndpoint, + channelType, channelEndpoint); + } + + Object oneAgentSDK_createInProcessLink(Object agentSdkImpl) { + return invoke(oneAgentSDK_createInProcessLink, agentSdkImpl); + } + + Object oneAgentSDK_traceInProcessLink(Object agentSdkImpl, InProcessLinkImpl inProcessLink) { + return invoke(oneAgentSDK_traceInProcessLink, agentSdkImpl, inProcessLink.getAgentProvidedLink()); + } + + Object oneAgentSDK_traceIncomingWebRequest(Object agentSdkImpl, WebApplicationInfoImpl webApplicationInfo, + String url, String method) { + return invoke(oneAgentSDK_traceIncomingWebRequest, agentSdkImpl, webApplicationInfo.getWebServerName(), + webApplicationInfo.getApplicationID(), webApplicationInfo.getContextRoot(), url, method); + } + + Object oneAgentSDK_traceOutgoingWebRequest(Object agentSdkImpl, String url, String method) { + return invoke(oneAgentSDK_traceOutgoingWebRequest, agentSdkImpl, url, method); + } + + Object oneAgentSDK_traceOutgoingMessage(Object agentSdkImpl, MessagingSystemInfoImpl messagingSystem) { + return invoke(oneAgentSDK_traceOutgoingMessage, agentSdkImpl, messagingSystem.getVendorName(), + messagingSystem.getDestinationName(), messagingSystem.getDestinationType().getName(), + messagingSystem.getChannelType() == null ? -1 : messagingSystem.getChannelType().getSDKConstant(), + messagingSystem.getChannelEndpoint()); + } + + Object oneAgentSDK_traceIncomingMessageReceive(Object agentSdkImpl, MessagingSystemInfoImpl messagingSystem) { + return invoke(oneAgentSDK_traceIncomingMessageReceive, agentSdkImpl, messagingSystem.getVendorName(), + messagingSystem.getDestinationName(), messagingSystem.getDestinationType().getName(), + messagingSystem.getChannelType() == null ? -1 : messagingSystem.getChannelType().getSDKConstant(), + messagingSystem.getChannelEndpoint()); + } + + Object oneAgentSDK_traceIncomingMessageProcess(Object agentSdkImpl, MessagingSystemInfoImpl messagingSystem) { + return invoke(oneAgentSDK_traceIncomingMessageProcess, agentSdkImpl, messagingSystem.getVendorName(), + messagingSystem.getDestinationName(), messagingSystem.getDestinationType().getName(), + messagingSystem.getChannelType() == null ? -1 : messagingSystem.getChannelType().getSDKConstant(), + messagingSystem.getChannelEndpoint()); + } + + Object oneAgentSDK_traceSQLDatabaseRequest(Object agentSdkImpl, DatabaseInfoImpl databaseInfo, String sql) { + return invoke(oneAgentSDK_traceSQLDatabaseRequest, agentSdkImpl, databaseInfo.getName(), databaseInfo.getVendor(), + databaseInfo.getChannelType() == null ? -1 : databaseInfo.getChannelType().getSDKConstant(), + databaseInfo.getChannelEndpoint(), sql); + } + + Object oneAgentSDK_traceCustomService(Object agentSdkImpl, String serviceMethod, String serviceName) { + return invoke(oneAgentSDK_traceCustomService, agentSdkImpl, serviceMethod, serviceName); + } + + void oneAgentSDK_setLoggingCallback(Object sdk, Object loggingCallback) { + invoke(oneAgentSDK_setLoggingCallback, sdk, loggingCallback); + } + + Boolean oneAgentSDK_isCapturing(Object sdk) { + return (Boolean) invoke(oneAgentSDK_isCapturing, sdk); + } + + public void oneAgentSDK_addCustomRequestAttribute(Object agentSdkImpl, String key, String value) { + invoke(oneAgentSDK_addCustomRequestAttribute_1, agentSdkImpl, key, value); + } + + public void oneAgentSDK_addCustomRequestAttribute(Object agentSdkImpl, String key, long value) { + invoke(oneAgentSDK_addCustomRequestAttribute_2, agentSdkImpl, key, value); + } + + public void oneAgentSDK_addCustomRequestAttribute(Object agentSdkImpl, String key, double value) { + invoke(oneAgentSDK_addCustomRequestAttribute_3, agentSdkImpl, key, value); + } + + void tracer_start(Object node) { + invoke(tracer_start, node); + } + + void tracer_end(Object node) { + invoke(tracer_end, node); + } + + void tracer_error(Object node, String message) { + invoke(tracer_error_1, node, message); + } + + void tracer_error(Object node, Throwable error) { + invoke(tracer_error_2, node, error); + } + + String outgoingTaggable_getDynatraceStringTag(Object taggableClient) { + return (String) invoke(outgoingTaggable_getDynatraceStringTag, taggableClient); + } + + byte[] outgoingTaggable_getDynatraceByteTag(Object taggableClient) { + return (byte[]) invoke(outgoingTaggable_getDynatraceByteTag, taggableClient); + } + + void incomingTaggable_setDynatraceStringTag(Object taggableServer, String tag) { + invoke(incomingTaggable_setDynatraceStringTag, taggableServer, tag); + } + + void incomingTaggable_setDynatraceByteTag(Object taggableServer, byte[] tag) { + invoke(incomingTaggable_setDynatraceByteTag, taggableServer, tag); + } + + void outgoingRemoteCallTracer_setProtocolName(Object remoteCallClient, String protocolname) { + invoke(outgoingRemoteCallTracer_setProtocolName, remoteCallClient, protocolname); + } + + void incomingRemoteCallTracer_setProtocolName(Object remoteCallServer, String protocolname) { + invoke(incomingRemoteCallTracer_setProtocolName, remoteCallServer, protocolname); + } + + void webRequestTracer_setStatusCode(Object webRequestTracer, int statusCode) { + invoke(webRequestTracer_setStatusCode, webRequestTracer, statusCode); + } + + void webRequestTracer_addResponseHeader(Object webRequestTracer, String name, String value) { + invoke(webRequestTracer_addResponseHeader, webRequestTracer, name, value); + } + + void webRequestTracer_addRequestHeader(Object webRequestTracer, String name, String value) { + invoke(webRequestTracer_addRequestHeader, webRequestTracer, name, value); + } + + void incomingWebRequestTracer_setRemoteAddress(Object incomingWebRequestTracer, String remoteAddress) { + invoke(incomingWebRequestTracer_setRemoteAddress, incomingWebRequestTracer, remoteAddress); + } + + void incomingWebRequestTracer_addParameter(Object incomingWebRequestTracer, String name, String value) { + invoke(incomingWebRequestTracer_addParameter, incomingWebRequestTracer, name, value); + } + + void messageTracer_setVendorMessageId(Object messageTracer, String vendorMessageId) { + invoke(messageTracer_setVendorMessageId, messageTracer, vendorMessageId); + } + + void messageTracer_setCorrelationId(Object messageTracer, String correlationId) { + invoke(messageTracer_setCorrelationId, messageTracer, correlationId); + } + + void databaseRequestTracer_setRowsReturned(Object databaseRequestTracer, int rowsReturned) { + invoke(databaseRequestTracer_setRowsReturned, databaseRequestTracer, rowsReturned); + } + + void databaseRequestTracer_setRoundTripCount(Object databaseRequestTracer, int roundTripCount) { + invoke(databaseRequestTracer_setRoundTripCount, databaseRequestTracer, roundTripCount); + } + + @SuppressWarnings("unchecked") + public Map.Entry oneAgentSDK_getCurrentTraceAndSpanId(Object sdk) { + return (Map.Entry) invoke(oneAgentSDK_getCurrentTraceAndSpanId, sdk); + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceContextInfoImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceContextInfoImpl.java new file mode 100644 index 0000000..fb18621 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceContextInfoImpl.java @@ -0,0 +1,45 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.infos.TraceContextInfo; + +final class TraceContextInfoImpl implements TraceContextInfo { + + private final String traceId; + private final String spanId; + + public TraceContextInfoImpl(String traceId, String spanId) { + this.traceId = traceId; + this.spanId = spanId; + } + + @Override + public boolean isValid() { + // Always true; for the invalid trace context, TraceContextInfoNoop is used. + return true; + } + + @Override + public String getTraceId() { + return traceId; + } + + @Override + public String getSpanId() { + return spanId; + } +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceableProxy.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceableProxy.java new file mode 100644 index 0000000..a7c050c --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/TraceableProxy.java @@ -0,0 +1,53 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.Tracer; + +abstract class TraceableProxy implements Tracer { + + protected final SDK2AgentInternalApiProxy apiProxy; + protected final Object agentsNodeObject; + + TraceableProxy(SDK2AgentInternalApiProxy apiProxy, Object agentsNodeObject) { + this.apiProxy = apiProxy; + this.agentsNodeObject = agentsNodeObject; + } + + @Override + public void start() { + apiProxy.tracer_start(agentsNodeObject); + + } + + @Override + public void end() { + apiProxy.tracer_end(agentsNodeObject); + + } + + @Override + public void error(String message) { + apiProxy.tracer_error(agentsNodeObject, message); + + } + + @Override + public void error(Throwable throwable) { + apiProxy.tracer_error(agentsNodeObject, throwable); + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/WebApplicationInfoImpl.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/WebApplicationInfoImpl.java new file mode 100644 index 0000000..a587d80 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/WebApplicationInfoImpl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; + +import com.dynatrace.oneagent.sdk.api.infos.WebApplicationInfo; + +final class WebApplicationInfoImpl implements WebApplicationInfo { + + private final String webServerName; + private final String applicationID; + private final String contextRoot; + + WebApplicationInfoImpl(String webServerName, String applicationID, String contextRoot) { + this.webServerName = webServerName; + this.applicationID = applicationID; + this.contextRoot = contextRoot; + } + + String getWebServerName() { + return webServerName; + } + + String getApplicationID() { + return applicationID; + } + + String getContextRoot() { + return contextRoot; + } + +} diff --git a/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/package-info.java b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/package-info.java new file mode 100644 index 0000000..50d88d6 --- /dev/null +++ b/src/main/java/com/dynatrace/oneagent/sdk/impl/proxy/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2023 Dynatrace LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * internal SDK implementation. direct usage is forbidden. package provides + * proxy classes for forwarding requests to OneAgent. + */ +package com.dynatrace.oneagent.sdk.impl.proxy; diff --git a/src/test/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImplTest.java b/src/test/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImplTest.java new file mode 100644 index 0000000..f873598 --- /dev/null +++ b/src/test/java/com/dynatrace/oneagent/sdk/impl/OneAgentSDKFactoryImplTest.java @@ -0,0 +1,26 @@ +package com.dynatrace.oneagent.sdk.impl; + +import org.assertj.core.api.Assertions; +import org.junit.Test; + +import com.dynatrace.oneagent.sdk.impl.OneAgentSDKFactoryImpl; + +public class OneAgentSDKFactoryImplTest { + + @Test + public void versionCheckTest() { + // *** public version of SDK + String buildVersion = System.getProperty("sdk.version"); + Assertions.assertThat(buildVersion).isEqualTo("1.9.0"); + + // *** internal version (between SDK and agent) + String[] splitted = buildVersion.split("\\."); + int major = Integer.parseInt(splitted[0]); + int minor = Integer.parseInt(splitted[1]); + int fix = Integer.parseInt(splitted[2]); + + Assertions.assertThat(major).isEqualTo(OneAgentSDKFactoryImpl.oneSdkMajor); + Assertions.assertThat(minor).isEqualTo(OneAgentSDKFactoryImpl.oneSdkMinor); + Assertions.assertThat(fix).isEqualTo(OneAgentSDKFactoryImpl.oneSdkFix); + } +} diff --git a/src/test/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProviderTest.java b/src/test/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProviderTest.java new file mode 100644 index 0000000..88e732b --- /dev/null +++ b/src/test/java/com/dynatrace/oneagent/sdk/impl/SDKInstanceProviderTest.java @@ -0,0 +1,18 @@ +package com.dynatrace.oneagent.sdk.impl; + +import static org.junit.Assert.assertThat; + +import org.hamcrest.core.IsEqual; +import org.junit.Test; + +import com.dynatrace.oneagent.sdk.impl.SDKInstanceProvider; + +public class SDKInstanceProviderTest { + + @Test + public void testClassName() { + assertThat("class name changed. incompatible with older agents.", SDKInstanceProvider.class.getName(), + IsEqual.equalTo("com.dynatrace.oneagent.sdk.impl.SDKInstanceProvider")); + } + +}