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

NAME

Redis::OpenTracing - Wrap Redis inside OpenTracing

SYNOPSIS

    package My::Awesome::Module;
    
    use strict;
    use warnings;
    
    use Redis
    use Redis::OpenTracing;
    
    my $redis = Redis::OpenTracing->new(
        redis => Redis->new( ),
        tags  => { 'peer.address' => '127.0.0.1:6379' },
    );
    
    my $value = $redis->get( 'my-key' );
    
    1;

DESCRIPTION

The example above will use the default Redis server (from $ENV{REDIS_SERVER}) and the Global Tracer (from $ENV{OPENTRACING_IMPLEMENTATION}.

It will create span with the name Redis::GET, enriched with package / subroutine name and line number for easy debugging.

CLASS METHODS

new

Creates a new Redis::OpenTracing client.

    my $redis = Redis::OpenTracing->new(
        redis => Redis::Fast->new,
        tags  => {
            'component'    => 'Perl5 Redis::Fast 0.31',
            'peer.address' => '127.0.0.1:6379',
        }
    );
Required Named Parameter(s)
redis (Object)

A (existing) Redis client. This must be something like an instance of Redis, and implement its methods to work properly.

Optional Named Parameter(s)
tags (HashRef[Values])

A hash reference that can hold tags being used for span enrichment. OpenTracing expects the following tags: component, db.statement, db.type, span.kind, and peer.address. The component can be set, but defaults to the classname of the redis client. It is strongly advised to provide a the peer.addres, which can not be easily extracted at a reliable way. The other tags can not be changed and are hard coded.

AUTHOR

Theo van Hoesel <tvanhoesel@perceptyx.com>

CONTRIBUTORS

The people listed below have helped to improve the quality of the code and fixed issues. Your work and effort is very much appreciated.

Szymon Nieznanski <s.nez@member.fsf.org>

COPYRIGHT AND LICENSE

Redis::OpenTracing is Copyright (C) 2021, 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 library 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.