Skip to content

auxmoney/OpentracingBundle-Monolog

Repository files navigation

auxmoney OpentracingBundle - Monolog

test GitHub release (latest SemVer) Codacy Badge Code Climate maintainability Scrutinizer code quality (GitHub/Bitbucket) GitHub

This bundle adds a monolog processor to the OpentracingBundle to automatically enrich log contexts with the current span context.

Installation

Prerequisites

This bundle is only an additional plugin and should not be installed independently. See its documentation for more information on installing the OpentracingBundle first.

Require dependencies

After you have installed the OpentracingBundle:

  • require the dependencies:
    composer req auxmoney/opentracing-bundle-monolog

Enable the bundle

If you are using Symfony Flex, you are all set!

If you are not using it, you need to manually enable the bundle:

  • add bundle to your application:
    # Symfony 3: AppKernel.php
    $bundles[] = new Auxmoney\OpentracingMonologBundle\OpentracingMonologBundle();
    # Symfony 4+: bundles.php
    Auxmoney\OpentracingMonologBundle\OpentracingMonologBundle::class => ['all' => true],

Configuration

No configuration is necessary, the Monolog bundle extension will automatically load the provided Processor by tag.

Usage

Whenever a message is logged, the content is extended with extra information of the span context.

    [2020-01-10 11:38:03] php.INFO: .... {"exception":"[object] (ErrorException(code: 0) ...."} {"opentracing-context":"{\"UBER-TRACE-ID\":\"15e880402e1a194715e880402e19a3e0:15e880402e19a3e0:0:1\"}"}

Development

Be sure to run

    composer run-script quality

every time before you push code changes. The tools run by this script are also run in the CI pipeline.