bugsnag / bugsnag-unity-performance

Monitor the start-up, scene loading and network requests of your Unity game and see the results in your BugSnag dashboard.
https://docs.bugsnag.com/performance/integration-guides/unity
MIT License
1 stars 2 forks source link

PLAT-9703 ensure span and trace ID generation have required randomness #20

Closed richardelms closed 1 year ago

richardelms commented 1 year ago

Goal

ensure the span and trace IDs are generated appropriately:

Span ID

16 character hex string

Randomly generated to avoid likelihood of collision, particularly in first 8 characters which will be visible on the dashboard

Trace ID:

32 character hex string

Guaranteed unique - insofar as is reasonably possible

Design

Made use of the RNGCryptoServiceProvider class to generate a cryptographically secure random byte array of the appropriate size. Then convert each byte of the array to its hexadecimal representation and concatenate these values into a string. The Trace ID version returns the full 32 character string, whereas the Span ID version returns the first 16 characters of the generated string.

Changeset

Testing

Covered by existing tests