Git Product home page Git Product logo

openkit-dotnet's Introduction

Dynatrace OpenKit - .NET Reference Implementation

License Build Status Coverage Status

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 .NET/C#. 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 .NET APIs, should be running on older .NET runtimes, too
  • Avoid usage of too much .NET-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-dotnet's People

Contributors

alexlagler avatar andreas-doppelhofer avatar bonifazkaufmann avatar christian-schwarzbauer avatar dominikp avatar ingohackl avatar mariojonke avatar openkitdt avatar philippraab avatar renepanzar 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

Watchers

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

openkit-dotnet's Issues

Session Properties: Is it possible to add them

Hi,
We are using openkit to monitor user actions inside a WPF application. (Defined as a custom application inside DynaTrace One)
We would like to group users based on their location inside our country (region, office, ...)
We could use custom IP mapping, but we would rather make use of session properties.
This would allow use to create meaningful and powerfull user queries

https://www.dynatrace.com/news/blog/filter-user-sessions-based-on-custom-session-properties-eap/
The link above talks about the availability of this as an upcoming improvement for openkit. (aug 2018)
The current implementation of Openkit however does not allow to send custom properties on the session object. (Only on the action object).

Is it possible to add this feature to openkit?
It would help us a lot.

Thx,

Install/Update with Nuget

Is there a reason these libraries are not hosted in NuGet? I'd prefer to use NuGet to make installing and updating the library versions easier.

User session crash on DoLeaveAction(Boolean discardData)

Describe the bug
We run a C# application where we use Dynatrace as a logging/tracing system.
We have noticed that some users experience a crash with stacktrace below without any clue why this happens.

To Reproduce
The crash appears at random and we can't force a reproduce unfortunately.

Expected behavior
We do not expect a user session to crash by this issue. We want to be able to handle this issue in the background without any issues seen by the enduser

Stacktrace (Slightly redacted)

Exception information


ThreadIdentity:
ClaimsPrincipal:
UserName: XXXXXXX

  1. System.NullReferenceException
    Message: Object reference not set to an instance of an object.
    HResult: 80004003
    Data:
    System.Object:

StackTrace
at Dynatrace.OpenKit.Core.Objects.BaseAction.DoLeaveAction(Boolean discardData)
at Dynatrace.OpenKit.Core.Objects.BaseAction.LeaveAction()
at NinjaProject.Dynatrace.Extensions.UserTrackingTelemetry.Dispose() in D:\BLD1_work\44\s\NinjaProject.Dynatrace.Extensions\Logic\UserTrackingTelemetry.cs:line 88
at System.Threading.Tasks.DynatraceTaskExtensions.d__1`1.MoveNext() in D:\BLD1_work\44\s\NinjaProject.Dynatrace.Extensions\Extensions\DynatraceTaskExtensions.cs:line 37
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

OpenTracing / OpenTelemetry support

Does Dynatrace plan to offer any OpenTracing or OpenTelemetry support through this Sdk in the future? That would make it much easier to integrate with some of the app frameworks commonly used throughout .NET.

Use OpenKit through proxy

I'm trying to use this package to send data to our DynaTrace dashboard, but it seems that it cannot go through our proxy (behind which is our server).

System.AggregateException: One or more errors occurred. (No connection could be made because the target machine actively refused it) ---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   --- End of inner exception stack trace ---
   at Dynatrace.OpenKit.Protocol.HTTPClient.SendRequestInternal(RequestType requestType, String url, String clientIPAddress, Byte[] data, String method)
   at Dynatrace.OpenKit.Protocol.HTTPClient.SendRequest(RequestType requestType, String url, String clientIPAddress, Byte[] data, String method)
---> (Inner Exception #0) System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)<--- 

There is any way to set the proxy info?

All sessions have same cookie identifier

UserSessionTags - strange

We implemented openkit a while ago and all is working well. The only strange thing we see in Dynatrace is that it's difficult to focus on one user. They are all grouped together apparently based on a cookie according to this screen.

Ignoring SSL certificates

The detailed example mentions a ISSLTrustManager can be used to allow untrusted SSL certificates.
Could you provide an example of the setup for the ISSLTrustManager and how to pass it to openkit?

Session creation fails

I am using your example and am trying to run it.

  1. However the session creation returns false.
    So what do I do wrong?
  2. Another issue is that if the IP that I am using for session creation is incorrect (like inactive network adapter then the application hangs forever and I am not able to kill the process neither in Visual Studio (Debug->Stop) not in Task Manager, and in both cases getting "Access is denied" while I am logged in as admin and running the Visual Studio as admin...
    So how do I resolve at least #1? It is really critical...

` string endpointURL = "https://bf28096kgw.bf.dynatrace.com/mbeacon"; // the endpointURL can be found in the Dynatrace UI ?? What UI? Where?
string applicationID = "D2CB8ED1-D63C-4198-B12B-85EFAD1481DB"; // the application id can be found in the Dynatrace UI
long deviceID = 42L; // an ID that uniquely identifies the device

        var openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)
            .WithApplicationVersion("1.0")
            .WithOperatingSystem(Environment.OSVersion.VersionString)
            .Build();

        // we wait for OpenKit to be initialized
        // if you skip the line, OpenKit will be initialized asynchronously

        // create a new session
        var ipAddress = GetIpAddress();
        var session = openKit.CreateSession(ipAddress);

        int timeoutInMilliseconds = 30 * 1000;
       // the returned 'success' is false
        bool success = openKit.WaitForInitCompletion(timeoutInMilliseconds);`

WCF with TCP binding

One of our customers has a rich client application based on WPF with WCF communication towards the backend but with TCP binding.
We have not yet tried the WcfAutoTracerSample.cs, but when I look at the source it seems based on HTTP binding.
As far as I know from UEM and RUM, the correlation is indeed based on an HTTP header. So, I wonder if this would also work for TCP binding. (guess not). And if it doesn't work OOTB, how we would be able to achieve this.
I am not afraid of a little bit of coding ;-)

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.