Git Product home page Git Product logo

openkit-java's Introduction

Dynatrace OpenKit - Java Reference Implementation

License Build Status Coverage Status

ℹ️ We changed the default branch name to main. You can find the necessary steps to update your local clone on Scott Hanselman's Blog.
We encourage you to rename the default branch in your forks too.

What is the OpenKit?

The OpenKit provides an easy and lightweight way to get insights into applications with Dynatrace by instrumenting the source code of those applications.

It is best suited for applications running separated from their backend and communicating via HTTP, like rich-client-applications, embedded devices, terminals, and so on.

The big advantages of the OpenKit are that it's designed to

  • be as easy-to-use as possible
  • be as dependency-free as possible (no third party libraries or Dynatrace Agent needed)
  • be easily portable to other languages and platforms

This repository contains the reference implementation in pure Java. Other implementations are listed as follows:

What you can do with the OpenKit

  • Create Sessions and User Actions
  • Report values, events, errors and crashes
  • Trace web requests to server-side PurePaths
  • Tag Sessions with a user tag
  • Use it together with Dynatrace

What you cannot do with the OpenKit

Design Principles

  • API should be as simple and easy-to-understand as possible
  • Incorrect usage of the OpenKit should still lead to valid results, if possible
  • In case of errors, the API should not throw exceptions, but only log those errors (in verbose mode)
  • No usage of third-party libraries, should run without any dependencies
  • Avoid usage of newest Java APIs, should be running on older Java VMs, too
  • Avoid usage of too much Java-specific APIs to allow rather easy porting to other languages
  • Design reentrant APIs and document them

General Remarks

  • All non binary files within the repository are formatted with UNIX style (LF) line endings.

Getting started

Advanced topics

openkit-java's People

Contributors

andreas-doppelhofer avatar bonifazkaufmann avatar christian-schwarzbauer avatar daroli avatar dominikp avatar kavindu-dodan avatar laubi avatar mariojonke avatar nickmcdyna avatar openkitdt avatar renepanzar avatar robinwyss avatar stefaneberl avatar thehighriser avatar thomasgrassauer avatar y0chanan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openkit-java's Issues

TrustAllX509TrustManager android lint warning SSLBlindTrustManager

Environment

  • Android Studio Chipmunk | 2021.2.1 Patch 2
  • openkit-java v2.2.0

Problem
warning [TrustAllX509TrustManager](https://github.com/Dynatrace/openkit-java/issues/new#TrustAllX509TrustManager): Insecure TLS/SSL trust manager

Insecure TLS/SSL trust manager [../../com/dynatrace/openkit/protocol/ssl/SSLBlindTrustManager%24BlindX509TrustManager.class](https://github.com/Dynatrace/com/dynatrace/openkit/protocol/ssl/SSLBlindTrustManager%24BlindX509TrustManager.class): checkClientTrusted is empty, which could cause insecure network traffic due to trusting arbitrary TLS/SSL certificates presented by peers [../../com/dynatrace/openkit/protocol/ssl/SSLBlindTrustManager%24BlindX509TrustManager.class](https://github.com/Dynatrace/com/dynatrace/openkit/protocol/ssl/SSLBlindTrustManager%24BlindX509TrustManager.class): checkServerTrusted is empty, which could cause insecure network traffic due to trusting arbitrary TLS/SSL certificates presented by peers

Steps to reproduce

  • Run lintDebug Gradle task
    ./gradlew lintDebug

openkit-1.0.1-java6.jar is not usable with Java 6

When DynatraceOpenKitBuilder is initialized with build() - it fails with the stacktrace below on Java 6.

Calling this:

openKit = new DynatraceOpenKitBuilder(BEACON_URL, APP_ID, deviceID).withApplicationName(APP_NAME).withApplicationVersion("1.0.0.0").withOperatingSystem(os).withManufacturer(domain).withModelID(ProcessUtil.getProcessIdAndHost()).enableVerbose().build();

Gives the following error at runtime:

java.lang.ExceptionInInitializerError at java.lang.J9VMInternals.initialize(J9VMInternals.java:222) at com.dynatrace.openkit.AbstractOpenKitBuilder.getLogger(AbstractOpenKitBuilder.java:260) at com.dynatrace.openkit.AbstractOpenKitBuilder.build(AbstractOpenKitBuilder.java:207) at UDynatrace.initDynatraceOpenKit(UDynatrace.java:144)

... cut out ...

Caused by: java.lang.IllegalArgumentException: Illegal pattern character 'X' at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:786) at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:587) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:512) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:487) at com.dynatrace.openkit.core.util.DefaultLogger.<clinit>(DefaultLogger.java:32) at java.lang.J9VMInternals.initializeImpl(Native Method) at java.lang.J9VMInternals.initialize(J9VMInternals.java:200) ... 75 more

The error arises because Java 6 does not support the SimpleDateFormat type 'X' -> https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Workaround

Create a new Logger implementation and change the DATEFORMAT so it does not contain X in the format.

static final String DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";

Suggestion to add more information on deviceID

Can I suggest to add a bit more information about how to specify the deviceID?

Because it is not very clear for the customer that the deviceID is used for identifying each user that connects to the application.
And needs to be used with only digits.
image

Based on a conversation on Slack:
Custom applications have the same behavior then mobile applications: Not every session is tagged, especially when the user did not accept the privacy settings. Therefore the metric is based on the device id.

The official documentation is also not very clear: https://docs.dynatrace.com/docs/shortlink/user-session#user-session-identification
image

My customer has implemented it by specifying the ID of the application and not the ID of the users so in consequence, only 1 unique user was reported:
image

Thank you!

Make Action, WebRequestTracer extend java.lang.Closeable

Action#close() and WebRequestTracer#close() would simply delegate to Action#leaveAction() and WebRequestTracer#stop(), respectively.

This would make both objects transparently usable with try-with-resources in Java 7+ without breaking compatibility with Java 6.

Add a getNumRemainingStatusRequests() function to SessionImpl to get the current integer as it decreases

I'm interested in creating a PriorityQueue containing n sessions, prioritized by the remaining status requests. The queue would provide a session that is most likely to be configured and open. At the moment there doesn't seem to be public method that obtains that integer. I believe the closest thing is statically referencing the MAX_STATUS_RETRY int declared inside SessionImpl

This seems more robust than using the most recent timestamp

OpenKit does not work on Android

I seems like the HTTPClient implementation will not work on Android.

I get this INFO trace when trying to use the sample code in the "instrumenting your app" section of the docs

INFO  [BeaconSender] Exception occurred during connection establishment. Cause : java.net.ProtocolException: content-length promised 473 bytes, but received 295 . Retry in progress.

In HTTPClient, the Content Length used is data.length

Since this class uses java.util.zip.GZIPOutputStream, it would seem the version given in the Android framework isn't compatible.

Should it be changed to use the gzipped length?

e.g.

connection.setRequestProperty("Content-Length", String.valueOf(gzippedData.length));

Use a string in the deviceID

This request is related to my previous suggestion #207

Would it be possible to use a string in the deviceID?
In my customer context, every user is identified with a unique string identifier (Ex. Z1234567) or with the “Hostname” (Ex. INHL0007777) which are unfortunately alpha numeric characters.

Thank you!

Openkit for Server Side Tracing

Hey,

Can this library be used to do the server side tracing. I know the tracer which exists is for outgoing web request equivalent, however if we extend the library we might be able to write an incoming web request tracer.
The reason I ask is because oneagent SDK is not behaving well with vertx due to the way thread models work in vertx. The oneagent jumbles up the purepath.

Will we be able to extend this kit to construct the same by extending this SDK.

Abhishek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.