Skip to content

Commit

Permalink
fix: add endpoint override flag (#3050)
Browse files Browse the repository at this point in the history
* fix: add endpoint override flag

This change is needed because the parameter `endpoint` will always be populated even if a value was not provided at client construction, and
therefore we can not relay on it to determine its source.

* chore: fix endpoint override test
  • Loading branch information
yenfryherrerafeliz authored Dec 18, 2024
1 parent 473bc80 commit 937e1f2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ClientResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ public static function _apply_endpoint($value, array &$args, HandlerList $list)
return;
}

$args['endpoint_override'] = true;
$args['endpoint'] = $value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/UserAgentMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private function getMetrics(): string
*/
private function appendEndpointMetric(): void
{
if (!empty($this->args['endpoint'])) {
if (!empty($this->args['endpoint_override'])) {
$this->metricsBuilder->append(MetricsBuilder::ENDPOINT_OVERRIDE);
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/UserAgentMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ public function userAgentCasesDataProvider(): \Generator
'metricsWithEndpoint' => function (): array {
$expectedEndpoint = "https://foo-endpoint.com";
$args = [
'endpoint' => $expectedEndpoint
'endpoint' => $expectedEndpoint,
'endpoint_override' => true,
];

return [$args, 'm/' . MetricsBuilder::ENDPOINT_OVERRIDE];
Expand Down

0 comments on commit 937e1f2

Please sign in to comment.