Skip to content

Utils for the common interface for tracing libraries

Notifications You must be signed in to change notification settings

AAllport/psr-tracing-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSR Tracing

This repository holds utilities related to PSR-22.

Installation

composer require psr/tracing-utils

Usage

Before tracing-utils

function imgResize($size=100) {
    $span = $this->tracer->startSpan('image.resize')
        ->setAttribute('size',$size)
        ->activate();    

    try{
    
      //Resize the image
      return $resizedImage;
    
    } catch (Exception $e) {
        // Ideally, you would attach the exception to the span here
        $span->setStatus(SpanInterface::STATUS_ERROR)
             ->addException($e);
    } finally {
        $span->finish();
    }    
}

After tracing-utils

function imgResize($size=100) {
    return $this->tracingUtils->wrap('imgResize', function() use ($size) {
        // do something expensive
        return img_resize($size);
    });
}

Look at all the removed boilerplate!

About

Utils for the common interface for tracing libraries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages