| 1 | package OpenTracing::Role::SpanContext; | ||||||||||
| 2 | |||||||||||
| 3 | 16 | our $VERSION = 'v0.80.0-TRIAL_006'; | |||||||||
| 4 | |||||||||||
| 5 | 16 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 16 | ▶ | use MooX::HandlesVia; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 16 | ▶ | use Data::GUID; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 16 | ▶ | use Sub::Trigger::Lock; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 16 | ▶ | use Types::Standard qw/HashRef Str/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | has trace_id => ( | ||||||||||
| 13 | is => 'rw', | ||||||||||
| 14 | # isa => Uuid, # not restraints here, do so when consuming this | ||||||||||
| 15 | init_arg => undef, | ||||||||||
| 16 | 8 | ▶ | default => sub { Data::GUID->new }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 16 | trigger => Lock, | |||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | has span_id => ( | ||||||||||
| 21 | is => 'rw', | ||||||||||
| 22 | # isa => Uuid, # not restraints here, do so when consuming this | ||||||||||
| 23 | init_arg => undef, | ||||||||||
| 24 | 8 | ▶ | default => sub { Data::GUID->new }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 16 | trigger => Lock, | |||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | has baggage_items => ( | ||||||||||
| 29 | is => 'rwp', | ||||||||||
| 30 | isa => HashRef[Str], | ||||||||||
| 31 | handles_via => 'Hash', | ||||||||||
| 32 | handles => { | ||||||||||
| 33 | # get_baggage_item => 'get', | ||||||||||
| 34 | get_baggage_items => 'all', | ||||||||||
| 35 | }, | ||||||||||
| 36 | 1 | ▶ | default => sub{ {} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 16 | trigger => Lock, | |||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | # XXX: trigger and $obj->get_baggage_item( 'foo' ) do not play well together | ||||||||||
| 41 | # feels like a bug in Moo or Sub::Trigger::Lock | ||||||||||
| 42 | # | ||||||||||
| 43 | sub get_baggage_item { | ||||||||||
| 44 | 6 | ▶ | my $self = shift; | ||||||||
|
Subroutine
get_baggage_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 45 | 6 | my $item_key = shift; | |||||||||
| 46 | |||||||||||
| 47 | 6 | return { $self->get_baggage_items() }->{ $item_key } | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub new_clone { | ||||||||||
| 51 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
new_clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | |||||||||||
| 53 | 1 | my $class = ref $self; | |||||||||
| 54 | |||||||||||
| 55 | 1 | $class->new( %$self ) | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 2 | ▶ | sub with_trace_id { $_[0]->clone_with( trace_id => $_[1] ) } | ||||||||
|
Subroutine
with_trace_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 1 | ▶ | sub with_span_id { $_[0]->clone_with( span_id => $_[1] ) } | ||||||||
|
Subroutine
with_span_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | sub with_baggage_item { | ||||||||||
| 63 | 1 | ▶ | my ( $self, $key, $value ) = @_; | ||||||||
|
Subroutine
with_baggage_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 64 | |||||||||||
| 65 | 1 | $self->clone_with( | |||||||||
| 66 | baggage_items => { $self->get_baggage_items(), $key => $value }, | ||||||||||
| 67 | ); | ||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | sub with_baggage_items { | ||||||||||
| 71 | 3 | ▶ | my ( $self, %args ) = @_; | ||||||||
|
Subroutine
with_baggage_items: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 72 | |||||||||||
| 73 | 3 | $self->clone_with( | |||||||||
| 74 | baggage_items => { $self->get_baggage_items(), %args }, | ||||||||||
| 75 | ); | ||||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | sub clone_with { | ||||||||||
| 79 | 7 | ▶ | my ( $self, @args ) = @_; | ||||||||
|
Subroutine
clone_with: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 80 | |||||||||||
| 81 | 7 | bless { %$self, @args }, ref $self; | |||||||||
| 82 | |||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | |||||||||||
| 87 | BEGIN { | ||||||||||
| 88 | # use Role::Tiny::With; | ||||||||||
| 89 | with 'OpenTracing::Interface::SpanContext' | ||||||||||
| 90 | 16 | ▶ | if $ENV{OPENTRACING_INTERFACE}; | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 16 | 1; | |||||||||