-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat(http-server): adds middleware instrumentation. #162
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1d18a24
feat(http-server): adds middleware and request handler instrumentation.
jcchavezs bd11c76
tests(http-server): adds integration test for the Middleware.
jcchavezs 14fcc62
docs(http-server): improves documentation.
jcchavezs 1f462b0
chore(http-server): makes linter happy.
jcchavezs 31faf67
chore(http-server): removes RequestHandler as middleware is enough fo…
jcchavezs 754340d
chore: uses span error API.
jcchavezs 9fa99f1
chore(http-server): decouples client/server tracing from PSR implemen…
jcchavezs 64cb9f9
tests(http-server): adds test for next span in the PSR15 server middl…
jcchavezs d737d34
chore(http-server): small tweaks to tests.
jcchavezs d15581c
tests(http-server): improves test naming for client and middleware.
jcchavezs b3866a9
chore: moves RequestHeaders into propagation folder, also adds typing…
jcchavezs 398d4cb
feat: adds request/response objects to HTTP instrumentation.
jcchavezs 71275e2
docs(http-server): improves docs.
jcchavezs a38152e
chore(http-server): makes Request/Response interfaces abstract classe…
jcchavezs d51b511
chore(http-server): removes Parser::spanName to reduce the API surface.
jcchavezs bc571dc
chore(http-server): do not tag success status code.
jcchavezs 2b0c3a2
chore(http-server): removed the need to pass a parser when intended t…
jcchavezs 8b09a44
chore(http-server): adds default implementation for request/response …
jcchavezs 31bfded
chore(http-server): removes getRoute as now we use abstract classes a…
jcchavezs 0406c52
docs(http-server): last tweaks to documentation.
jcchavezs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,28 +4,36 @@ | |
"description": "A Zipkin instrumentation for PHP", | ||
"keywords": [ | ||
"zipkin", | ||
"distributed-tracing", | ||
"tracing", | ||
"openzipkin" | ||
], | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"authors": [ | ||
{ | ||
"name": "José Carlos Chávez", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"homepage": "https://github.com/openzipkin/zipkin-php", | ||
"support": { | ||
"issues": "https://github.com/openzipkin/zipkin-php/issues" | ||
}, | ||
"require": { | ||
"php": "^7.1", | ||
"ext-curl": "*", | ||
"psr/http-message": "~1.0", | ||
"psr/log": "^1.0" | ||
}, | ||
"require-dev": { | ||
"guzzlehttp/psr7": "^1.4", | ||
"guzzlehttp/psr7": "^1.6", | ||
"jcchavezs/httptest": "~0.2", | ||
"phpstan/phpstan": "~0.12.28", | ||
"phpunit/phpunit": "~7.5.20", | ||
"psr/http-client": "^1.0", | ||
"psr/http-server-middleware": "^1.0", | ||
"middlewares/fast-route": "^1.2.1", | ||
"middlewares/request-handler": "^1.4.0", | ||
"squizlabs/php_codesniffer": "3.*" | ||
}, | ||
"config": { | ||
|
@@ -60,7 +68,8 @@ | |
"static-check": "phpstan analyse src --level 8" | ||
}, | ||
"suggest": { | ||
"psr/http-client": "Allows to instrument HTTP clients following PSR18." | ||
"psr/http-client": "Allows to instrument HTTP clients following PSR18.", | ||
"psr/http-server-middleware": "Allows to instrument HTTP servers via middlewares following PSR15." | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
namespace Zipkin\Instrumentation\Http\Client; | ||
|
||
use Zipkin\Tracing; | ||
use Psr\Http\Message\RequestInterface; | ||
use Zipkin\Instrumentation\Http\Request; | ||
|
||
/** | ||
* ClientTracing includes all the elements needed to instrument a | ||
* HTTP client. | ||
*/ | ||
class ClientTracing | ||
class HttpClientTracing | ||
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. Changed the name @adriancole |
||
{ | ||
/** | ||
* @var Tracing | ||
|
@@ -25,13 +25,9 @@ class ClientTracing | |
|
||
/** | ||
* function that decides to sample or not an unsampled | ||
* request. The signature is: | ||
* request. | ||
* | ||
* <pre> | ||
* function (RequestInterface $request): ?bool {} | ||
* </pre> | ||
* | ||
* @var callable(RequestInterface):?bool|null | ||
* @var callable(Request):?bool|null | ||
*/ | ||
private $requestSampler; | ||
|
||
|
@@ -51,7 +47,7 @@ public function getTracing(): Tracing | |
} | ||
|
||
/** | ||
* @return (callable(RequestInterface):?bool)|null | ||
* @return (callable(Request):?bool)|null | ||
*/ | ||
public function getRequestSampler(): ?callable | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zipkin\Instrumentation\Http\Client\Psr18; | ||
|
||
use Zipkin\Instrumentation\Http\Client\Request as ClientRequest; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
final class Request extends ClientRequest | ||
{ | ||
/** | ||
* @var RequestInterface | ||
*/ | ||
private $delegate; | ||
|
||
public function __construct(RequestInterface $delegate) | ||
{ | ||
$this->delegate = $delegate; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getMethod(): string | ||
{ | ||
return $this->delegate->getMethod(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPath(): ?string | ||
{ | ||
return $this->delegate->getUri()->getPath(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getUrl(): string | ||
{ | ||
return $this->delegate->getUri()->__toString(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getHeader(string $name): ?string | ||
{ | ||
return $this->delegate->getHeaderLine($name) ?: null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return RequestInterface | ||
*/ | ||
public function unwrap() | ||
{ | ||
return $this->delegate; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
need also to not accidentally tag 100 as error
https://github.com/openzipkin/brave/blob/master/instrumentation/http/src/main/java/brave/http/HttpResponseParser.java#L123-L128