How to use the aiozipkin.utils.generate_random_64bit_string function in aiozipkin

To help you get started, we’ve selected a few aiozipkin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiozipkin / tests / test_utils.py View on Github external
def test_generate_random_64bit_string(rand):
    rand.return_value = b'17133d482ba4f605'
    random_string = utils.generate_random_64bit_string()
    assert random_string == '17133d482ba4f605'
    # This acts as a contract test of sorts. This should return a str
    # in both py2 and py3. IOW, no unicode objects.
    assert isinstance(random_string, str)
github aio-libs / aiozipkin / aiozipkin / tracer.py View on Github external
def _next_context(self,
                      context: Optional[TraceContext] = None,
                      sampled: OptBool = None,
                      debug: bool = False) -> TraceContext:
        span_id = generate_random_64bit_string()
        if context is not None:
            new_context = context._replace(
                span_id=span_id,
                parent_id=context.span_id,
                shared=False)
            return new_context

        trace_id = generate_random_128bit_string()
        if sampled is None:
            sampled = self._sampler.is_sampled(trace_id)

        new_context = TraceContext(
            trace_id=trace_id,
            parent_id=None,
            span_id=span_id,
            sampled=sampled,