NAME

DBIx::OpenTracing - automatically create OpenTracing spans around DBI queries

VERSION

v0.0.2

SYNOPSIS

use DBI;
use DBIx::OpenTracing;

# use DBI as usual
my $dbh = DBI->connect(...);
$dbh->do(...);

DBIx::OpenTracing->disable();
$dbh->do($secret_query);
DBIx::OpenTracing->enable();

sub process_secrets {
    DBIx::OpenTracing->suspend();
    ...
}

DESCRIPTION

This module overrides DBI methods to create spans around all queries. It will also try to extract information like the query SQL and the number of rows returned. OpenTracing::GlobalTracer is used to accomplish this, so make sure you set your tracer there.

Spans created by this module will be named after the DBI method they wrap and prefixed with "dbi_", a call to $dbh-execute()> would produce a span called "dbi_execute". Note that the span method name may differ from the one used in your code, since many methods are simply wrappers around others. The following tags will be added to each span (if possible) in accordance with OpenTracing conventions:

  • db.type - always set to "sql"

  • db.instance - the database name

  • db.user - the user associated with the handle (not always available)

  • db.statement - the query SQL

  • db.rows - the number of rows affected (not always available)

  • error - will be set to true if the query failed

METHODS

disable

You can call DBIx::OpenTracing->disable to turn off all of this modules functionality. It can be re-enabled later with enable.

enable

Enable the module features again after being disabled. It's safe to call this multiple times.

disable_temporarily

Disable the module until the end of current scope.

enable_temporarily

Enable the module until the end of current scope.

suspend

Similarly to disable_temporarily, will disable the module until the end of current scope. However, until that scope is over, calls to enable and enable_temprarily will be ignored. Use this if you want to make sure absolutely nothing is traced within the scope, regardless of what any called functions are doing.

AUTHOR

Szymon Nieznański <snieznanski@perceptyx.com>

LICENSE

'DBIx::OpenTracing' is Copyright (C) 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.