Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

basis-company/opentelemetry-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

Use basis-company/telemetry instead!

OpenTelemetry php library

No Maintenance Intended License Build Status Scrutinizer Code Quality Code Coverage Latest Version Total Downloads

Installation

The recommended way to install the library is through Composer:

$ composer require basis-company/opentelemetry

Tracing

Library is under active development, but simple example should be present in readme.
In addition, see tracing tests for full-featured example.

<?php

use OpenTelemetry\Tracing\Builder;
use OpenTelemetry\Tracing\SpanContext;

$spanContext = SpanContext::generate(); // or extract from headers

$tracer = Builder::create()->setSpanContext($spanContext)->getTracer();

// start a span, register some events
$span = $tracer->createSpan('session.generate');

// set attributes as array
$span->setAttributes([ 'remote_ip' => '5.23.99.245' ]);
// set attribute one by one
$span->setAttribute('country', 'Russia');

$span->addEvent('found_login', [
  'id' => 67235,
  'username' => 'nekufa',
]);
$span->addEvent('generated_session', [
  'id' => md5(microtime(true))
]);

$span->end(); // pass status as an optional argument

Testing

To make sure the tests in this repo work as you expect, you can use the included docker test wrapper:

1.) Make sure that you have docker installed
2.) Execute ./resources/test-using-docker from your bash compatible shell.