taildev / php
PHP integration for tail.dev
Installs: 1 569
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- monolog/monolog: 1.*||2.*
- psr/log: 1.*
- ramsey/uuid: ^3.9||^4.0
Requires (Dev)
- illuminate/contracts: 5.*||6.*||7.*||8.*
- laravel/framework: 5.*||6.*||7.*||8.*
- mockery/mockery: ^1.3
- orchestra/testbench: ^6.12
- phpunit/phpunit: ^7.0||^8.0||^9.0
- squizlabs/php_codesniffer: 3.*
README
For Laravel integration, see taildev/laravel
Docs
See full documentation at tail.dev/documentation/php/get-started
Quickstart
Install the taildev/php
package using Composer
composer require taildev/php
Make sure that the composer autoloader is being required somewhere in your project:
require __DIR__ . '/vendor/autoload.php';
APM
Initialize APM with your auth token and service name (any name you'd like to identify this service)
use Tail\Apm; Apm::init('secret_token', 'service-name'); Apm::startRequest(); register_shutdown_function(function () { Apm::finish(); });
Alternatively you can use startJob($name)
for background jobs, CLI commands, etc. or startCustom($name)
To add spans to the transaction
$span = Apm::newDatabaseSpan('fetch-config'); // ... code fetching config $span->finish();
Span "types" are used to categorize operations.
Apm::newSpan(string $type, string $name); // to use your own custom type Apm::newCustomSpan($name); // type = "custom" Apm::newDatabaseSpan($name); // type = "database" Apm::newCacheSpan($name); // type = "cache" Apm::newFilesystemSpan($name); // type = "filesystem"
Logs
Initialize logging with your auth token. You may optionally provide a service name and environment if you wish
use Tail\Log; Log::init('secret_token', 'optional-service-name', 'optional-environment');
You can now use the logger anywhere to log a message
use Tail\Log; Log::get()->debug('my debug message'); Log::get()->alert('something went wrong', ['custom_tag' => 'some-value']);
More
For full documentation see tail.dev/documentation/php/get-started