Module: Zipkin::TraceId
- Defined in:
- lib/zipkin/trace_id.rb
Constant Summary collapse
- TRACE_ID_UPPER_BOUND =
2**64
- RANDOM =
Random number generator for generating IDs. This is an object that can respond to ‘#bytes` and uses the system PRNG. The current logic is compatible with Ruby 2.5 (which does not implement the `Random.bytes` class method) and with Ruby 3.0+ (which deprecates `Random::DEFAULT`). When we drop support for Ruby 2.5, this can simply be replaced with the class `Random`.
Random.respond_to?(:bytes) ? Random : Random::DEFAULT
- INVALID_TRACE_ID =
An invalid trace identifier, an 8-byte string with all zero bytes.
("\0" * 8).b
Class Method Summary collapse
-
.generate ⇒ String
Generates a valid trace identifier, an 8-byte string with at least one non-zero byte.
Class Method Details
.generate ⇒ String
Generates a valid trace identifier, an 8-byte string with at least one non-zero byte.
24 25 26 27 28 29 |
# File 'lib/zipkin/trace_id.rb', line 24 def self.generate loop do id = RANDOM.bytes(8) return id.unpack1('H*') if id != INVALID_TRACE_ID end end |