Skip to content
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

Feature/webhook transfer time #60

Closed

Conversation

roncodes
Copy link

This uses the on_stats request options to set the transferTime metric

Copy link
Member

@freekmurze freekmurze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test to make sure that this works?

Tests seem to be failing now.

], $body));
'on_stats' => function (TransferStats $stats) {

$this->response = $stats->getResponse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to do this, the response is already captured on line 72, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is redundant I've removed this and just set the entire TransferStats instead.

'on_stats' => function (TransferStats $stats) {

$this->response = $stats->getResponse();
$this->transferTime = $stats->getTransferTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just passing transfertime, let's pass the entire $stats

@@ -133,6 +141,7 @@ private function dispatchEvent(string $eventClass)
$this->response,
$this->errorType,
$this->errorMessage,
$this->transferTime,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Move the added option as the last one and make it optional.


$this->dispatchEvent(WebhookCallSucceededEvent::class);
if (! Str::startsWith($response->getStatusCode(), 2)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we throw the exception in on_stats? The previous code looks cleaner in this regard. Imho we just get the stats and nothing more here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally under the impression that stats would not get set since the on_stats hook is called after the responsee
and the event would be dispatched without the stats var set. Anyway, I've reverted and it works the same. I'll be adding test ASAP and updating the branch.

@freekmurze
Copy link
Member

The tests are failing for this PR, could you take a look at that?

@freekmurze
Copy link
Member

The code seems fine, but the tests are failing. Can you take a look at that.

Could you also add an example of the new functionality in the readme?

@freekmurze
Copy link
Member

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants