-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improves readme. #10
Improves readme. #10
Changes from 3 commits
fc1b5b1
c6bb38c
ca9c61d
b2810a4
245a00d
7332068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,106 @@ | ||
# DD Trace PHP | ||
|
||
[![CircleCI](https://circleci.com/gh/DataDog/dd-trace-php/tree/master.svg?style=svg)](https://circleci.com/gh/DataDog/dd-trace-php/tree/master) | ||
[![OpenTracing Badge](https://img.shields.io/badge/OpenTracing-enabled-blue.svg)](http://opentracing.io) | ||
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net/) | ||
|
||
PHP APM Client | ||
Datadog APM client that implements an [OpenTracing](http://opentracing.io) Tracer. | ||
|
||
## Install | ||
## Installation | ||
|
||
``` | ||
composer require datadog/dd-trace | ||
``` | ||
|
||
## Contribution | ||
## Requirements | ||
|
||
### Run tests | ||
- PHP 5.6 or later | ||
|
||
## Usage | ||
|
||
In order to be familiar with tracing elements it is recommended to read the [OpenTracing specification](https://github.com/opentracing/specification/blob/master/specification.md). | ||
|
||
### Creating a tracer | ||
|
||
To start using the Datadog Tracer with the OpenTracing API, you should first initialize the tracer: | ||
|
||
```php | ||
use DDTrace\Encoders\Json; | ||
use DDTrace\Propagators\TextMap; | ||
use DDTrace\Tracer; | ||
use DDTrace\Transport\Http; | ||
use OpenTracing\Formats; | ||
|
||
... | ||
|
||
// Transport layer that communicates with the agent | ||
$transport = new Http(new Json(), $logger, [ | ||
'endpoint_url' => 'http://localhost:8126/v0.3/traces', | ||
]); | ||
|
||
// Propagation for inject/extract contexts to/from the wire | ||
$textMap = new TextMap(); | ||
|
||
// Config for tracer | ||
$config = [ | ||
'service_name' => 'my_service', | ||
'enabled' => true, | ||
'global_tags' => ['host' => 'hostname'], | ||
]; | ||
|
||
$tracer = new Tracer($transport, [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. general design: can't we provide reasonable defaults to avoid all this configuration? it's quite long to configure the tracer. If it already has defaults, let's create an advanced section with this snippet and a simple "Getting Started" where you initialize the tracer with defaults + trace a code-block There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tracer comes with all this defaults, the reason why I included it in the example was to show all accepted arguments in the config. We can definitively move them to a advanced config or simply add a link in the bottom to the actual code (which also includes information). |
||
Formats\TEXT_MAP => $textMap, | ||
$config, | ||
]); | ||
|
||
// Sets a global tracer (singleton). Ideally tracer should be | ||
// injected as a dependency | ||
GlobalTracer::set($tracer); | ||
``` | ||
|
||
### Creating Spans | ||
|
||
- [Starting a root span](https://github.com/opentracing/opentracing-php#starting-an-empty-trace-by-creating-a-root-span) | ||
- [Starting a span for a given request](https://github.com/opentracing/opentracing-php#creating-a-span-given-an-existing-request) | ||
- [Active span and scope manager](https://github.com/opentracing/opentracing-php#active-spans-and-scope-manager) | ||
- [Creating a child span assigning parent manually](https://github.com/opentracing/opentracing-php#creating-a-child-span-assigning-parent-manually) | ||
- [Creating a child span using automatic active span management](https://github.com/opentracing/opentracing-php#creating-a-child-span-using-automatic-active-span-management) | ||
- [Using span options](https://github.com/opentracing/opentracing-php#using-span-options) | ||
|
||
### Propagation of context | ||
|
||
- [Serializing context to the wire](https://github.com/opentracing/opentracing-php#serializing-to-the-wire) | ||
- [Deserializing context from the wire](https://github.com/opentracing/opentracing-php#deserializing-from-the-wire) | ||
- [Propagation formats](https://github.com/opentracing/opentracing-php#propagation-formats) | ||
|
||
### Flushing Spans to the agent | ||
|
||
PHP as a request scoped language has no simple means to pass the collected spans data to a background process without blocking the main request thread/process. It is mandatory to execute the `Tracer::flush()` after the response is served to the client by using [`register_shutdown_function`](http://php.net/manual/en/function.register-shutdown-function.php). | ||
|
||
```php | ||
use OpenTracing\GlobalTracer; | ||
|
||
$application->run(); | ||
|
||
register_shutdown_function(function() { | ||
GlobalTracer::get()->flush(); | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
### Run tests | ||
|
||
```bash | ||
composer test | ||
``` | ||
|
||
### Fix lint | ||
|
||
``` | ||
```bash | ||
composer fix-lint | ||
``` | ||
|
||
## Releasing | ||
|
||
See [RELEASING](RELEASING.md) for more information on releasing new versions. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Releasing DD Trace PHP | ||
|
||
## Packagist Package | ||
|
||
1. Create a GitHub release. | ||
|
||
1. Click `Update` from the admin view of the [datadog/dd-trace][packagist] package. | ||
|
||
[packagist]: https://packagist.org/packages/datadog/dd-trace |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
"minimum-stability": "dev", | ||
"require": { | ||
"php": "^5.6||^7.0", | ||
"ext-bcmath": "*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevinlebrun removed the dependency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! |
||
"opentracing/opentracing": "1.0.0-beta2", | ||
"symfony/polyfill": "~1.7.0", | ||
"guzzlehttp/psr7": "^1.4@dev", | ||
|
@@ -43,6 +42,9 @@ | |
"DDTrace\\Tests\\": "./tests/" | ||
} | ||
}, | ||
"provide": { | ||
"opentracing/opentracing": "1.0.0-beta2" | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"@test-unit", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miss
bcmath
extension. I know this is still wip but that way I don't forget :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.