Skip to content

Commit 73e34bf

Browse files
committed
Fix snippet test
1 parent 122f5fa commit 73e34bf

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

Spanner/src/Middleware/BuiltInMetricsAttemptMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function __invoke(Call $call, array $options)
120120
$originalCallback = $options['metadataCallback'] ?? null;
121121

122122
// This gets the metadata on an ok status meaning we can get the GFE latency header for unary calls
123-
$options['metadataCallback'] = function($metadata) use ($originalCallback, $call, $options) {
123+
$options['metadataCallback'] = function ($metadata) use ($originalCallback, $call, $options) {
124124
$this->recordGfeLatency($metadata, $call, $options);
125125
if ($originalCallback) {
126126
$originalCallback($metadata);
@@ -134,7 +134,7 @@ public function __invoke(Call $call, array $options)
134134
);
135135
} catch (Exception $e) {
136136
// In case that the call is not a unary call and it is a streaming call error.
137-
$this->recordAttempt($startTime,$e->getCode(), $call->getMethod(), $options);
137+
$this->recordAttempt($startTime, $e->getCode(), $call->getMethod(), $options);
138138
$this->recordGfeError($e, $call, $options);
139139
throw $e;
140140
}

Spanner/src/OpenTelemetry/BuiltInMetricsExporter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ private function createTimeSeries(
193193
NumberDataPoint|HistogramDataPoint $otelPoint,
194194
?string $unit,
195195
DataInterface $otelData
196-
): TimeSeries
197-
{
196+
): TimeSeries {
198197
$ts = new TimeSeries();
199198
$unit = $unit ?? '1';
200199

Spanner/src/SpannerClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ private function configureBuiltinMetrics(bool $disabled): void
10561056
$this->meter = $this->meterProvider->getMeter('google-cloud-spanner');
10571057
ShutdownHandler::register([$this->meterProvider, 'shutdown']);
10581058

1059-
$attemptMetricsMiddleware = function (MiddlewareInterface $handler) use ($metricsClientId){
1059+
$attemptMetricsMiddleware = function (MiddlewareInterface $handler) use ($metricsClientId) {
10601060
return new BuiltInMetricsAttemptMiddleware(
10611061
$handler,
10621062
$this->meter,
@@ -1066,7 +1066,7 @@ private function configureBuiltinMetrics(bool $disabled): void
10661066
);
10671067
};
10681068

1069-
$operationMetricsMiddleware = function (MiddlewareInterface $handler) use ($metricsClientId){
1069+
$operationMetricsMiddleware = function (MiddlewareInterface $handler) use ($metricsClientId) {
10701070
return new BuiltInMetricsOperationMiddleware(
10711071
$handler,
10721072
$this->meter,

Spanner/tests/Snippet/CommitTimestampTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ public function testClass()
5757
{
5858
$id = 'abc';
5959

60+
// One add for the SpannerMiddleware and one for the Metrics middleware
6061
$this->spannerClient->addMiddleware(Argument::type('callable'))
61-
->shouldBeCalledOnce();
62+
->shouldBeCalled(2);
63+
64+
// One prepend for the Spanner Header Id and one for the Metrics middleware
6265
$this->spannerClient->prependMiddleware(Argument::type('callable'))
63-
->shouldBeCalledOnce();
66+
->shouldBeCalled(2);
6467

6568
// ensure cache hit
6669
$cacheItem = $this->prophesize(CacheItemInterface::class);

0 commit comments

Comments
 (0)