Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: send attempt and timestamp in headers (#935)
* feat: send attempt and timestamp in headers * refactor * update clirr files * refactor * review updates * remove "x-" * update * Add epoch precision to the header * use microseconds * update micro seconds calculation * fix formatting * Rename headers class * rename local variables * update comment
- Loading branch information
Showing
10 changed files
with
474 additions
and
44 deletions.
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
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
46 changes: 46 additions & 0 deletions
46
...a/com/google/cloud/bigtable/data/v2/stub/metrics/StatsHeadersServerStreamingCallable.java
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,46 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.bigtable.data.v2.stub.metrics; | ||
|
||
import com.google.api.core.InternalApi; | ||
import com.google.api.gax.rpc.ApiCallContext; | ||
import com.google.api.gax.rpc.ResponseObserver; | ||
import com.google.api.gax.rpc.ServerStreamingCallable; | ||
|
||
/** | ||
* A callable that injects client timestamp and current attempt number to request headers. Attempt | ||
* number starts from 0. | ||
*/ | ||
@InternalApi("For internal use only") | ||
public final class StatsHeadersServerStreamingCallable<RequestT, ResponseT> | ||
extends ServerStreamingCallable<RequestT, ResponseT> { | ||
private final ServerStreamingCallable innerCallable; | ||
|
||
public StatsHeadersServerStreamingCallable(ServerStreamingCallable innerCallable) { | ||
this.innerCallable = innerCallable; | ||
} | ||
|
||
@Override | ||
public void call( | ||
RequestT request, | ||
ResponseObserver<ResponseT> responseObserver, | ||
ApiCallContext apiCallContext) { | ||
ApiCallContext newCallContext = | ||
apiCallContext.withExtraHeaders(Util.createStatsHeaders(apiCallContext)); | ||
innerCallable.call(request, responseObserver, newCallContext); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...c/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/StatsHeadersUnaryCallable.java
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,43 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.bigtable.data.v2.stub.metrics; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.core.InternalApi; | ||
import com.google.api.gax.rpc.ApiCallContext; | ||
import com.google.api.gax.rpc.UnaryCallable; | ||
|
||
/** | ||
* A callable that injects client timestamp and current attempt number to request headers. Attempt | ||
* number starts from 0. | ||
*/ | ||
@InternalApi("For internal use only") | ||
public final class StatsHeadersUnaryCallable<RequestT, ResponseT> | ||
extends UnaryCallable<RequestT, ResponseT> { | ||
private final UnaryCallable innerCallable; | ||
|
||
public StatsHeadersUnaryCallable(UnaryCallable innerCallable) { | ||
this.innerCallable = innerCallable; | ||
} | ||
|
||
@Override | ||
public ApiFuture futureCall(RequestT request, ApiCallContext apiCallContext) { | ||
ApiCallContext newCallContext = | ||
apiCallContext.withExtraHeaders(Util.createStatsHeaders(apiCallContext)); | ||
return innerCallable.futureCall(request, newCallContext); | ||
} | ||
} |
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
Oops, something went wrong.