The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OpenTracing::Implementation::Test::Tracer - OpenTracing Test for Tracer

DESCRIPTION

This tracer keeps track of created spans by itself, using an internal structure. It can be used with Test::Builder tests to check the correctness of OpenTracing utilites or to easily inspect your instrumentation.

INSTANCE METHODS

get_spans_as_struct

Returns a list of hashes representing all spans, including information from SpanContexts. Example structure:

  (
    {
      operation_name => 'begin',
      span_id        => '7a7da90',
      trace_id       => 'cacbd7a',
      level          => 0,
      parent_id      => undef,
      has_finished   => '',
      start_time     => 1592863360.000000,
      finish_time    => undef,
      duration       => undef,
      baggage_items  => {},
      tags           => { a => 1 },
    },
    {
      operation_name => 'sub',
      span_id        => 'e0be9cc',
      trace_id       => 'cacbd7a'
      level          => 1,
      parent_id      => '7a7da90',
      has_finished   => 1,
      start_time     => 1592863360.000000,
      finish_time    => 1592863360.811969,
      duration       => 0.811956882476807,
      baggage_items  => {},
      tags           => { a => 2 },
    };
  )

span_tree

Return a string representation of span relationships.

cmp_deeply

    $tracer->cmp_deeply $all_expected, $test_message;

This Test::Builder-enabled test method, will emit a single test with $test_message. The test will compare current saved spans (same as returned by get_spans_as_struct) with $all_expected using cmp_deeply from Test::Deep.

cmp_easy

    $tracer->cmp_easy $any_expected, $test_message;

Same as cmp_deeply but transforms $any_expected into a super bag of super hashes before the comparison, so that not all keys need to be specified and order doesn't matter.

clear_spans

Removes all saved spans from the tracer, useful for starting fresh before new test cases.

AUTHOR

Szymon Nieznanski <snieznanski@perceptyx.com>

COPYRIGHT AND LICENSE

'Test::OpenTracing::Integration' is Copyright (C) 2019 .. 2020, Perceptyx Inc

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This package is distributed in the hope that it will be useful, but it is provided "as is" and without any express or implied warranties.

For details, see the full text of the license in the file LICENSE.