jaegertracing / jaeger-client-csharp

šŸ›‘ This library is DEPRECATED!
https://jaegertracing.io/
Apache License 2.0
302 stars 67 forks source link

Duplicate Span IDs because of default Random Number Generator #177

Closed phxnsharp closed 4 years ago

phxnsharp commented 4 years ago

Requirement - what kind of business use case are you trying to solve?

Instrumenting a Managed C++ application with Jaeger using jaeger-client-csharp. The application is a short-lived process that is often run multiple times in parallel to solve portions of a larger problem.

Problem - what in Jaeger blocks you from solving the requirement?

This library uses the default .NET Random() constructor, which initializes the seed with the current time. Since we are starting multiple processes in parallel at the same time, we have intermittently seen multiple processes sending duplicate span IDs to the server. This leads to bad data on the server.

https://docs.microsoft.com/en-us/dotnet/api/system.random.-ctor?view=netcore-3.1#System_Random__ctor

Proposal - what do you suggest to solve the problem or improve the existing situation?

Proposal 1) Use a combination of the current time and the current process ID to initialize Random() Proposal 2) Use https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.rngcryptoserviceprovider?view=netcore-3.1 to generate the initial seed for Random().

Any open questions to address

yurishkuro commented 4 years ago

I think at minimum we should have the ability to allow the user to provide their own RNG (I'm not sure if it's currently exposed in C# client the way it is exposed in Go).

phxnsharp commented 4 years ago

I'm not sure if it's currently exposed in C# client the way it is exposed in Go

No, it is hardcoded in: https://github.com/jaegertracing/jaeger-client-csharp/blob/5fe4c9becb4653262ed41ecc151b264533852ca1/src/Jaeger.Core/Util/Utils.cs#L8

yurishkuro commented 4 years ago

That seems like a simple abstraction to lift out to configuration. Would you like to make a PR?

phxnsharp commented 4 years ago

@yurishkuro Hopefully I have been faithful to the project rules. Thanks!