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

[DO NOT MERGE] tracing template #1194

Open
wants to merge 2 commits into
base: branch-2.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.Storage.Objects.Copy;
import com.google.api.services.storage.Storage.Objects.Get;
import com.google.api.services.storage.StorageRequest;
import com.google.api.services.storage.model.Bucket;
import com.google.api.services.storage.model.Bucket.Lifecycle;
Expand Down Expand Up @@ -2324,8 +2325,11 @@ private StorageObject getObject(StorageResourceId resourceId) throws IOException
// Request only fields used in GoogleCloudStorageItemInfo:
// https://cloud.google.com/storage/docs/json_api/v1/objects#resource-representations
.setFields(OBJECT_FIELDS);

GoogleCloudStorageObjectsRequest getRequest =
new GoogleCloudStorageObjectsRequest<Get>(getObject, "getObject");
try (ITraceOperation op = TraceOperation.addToExistingTrace("gcs.objects.get")) {
return getObject.execute();
return getRequest.execute();
} catch (IOException e) {
if (errorExtractor.itemNotFound(e)) {
logger.atFiner().withCause(e).log("getObject(%s): not found", resourceId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.google.cloud.hadoop.gcsio;

import com.google.api.services.storage.StorageRequest;
import com.google.api.services.storage.model.StorageObject;
import java.io.IOException;

public class GoogleCloudStorageObjectsRequest<T extends StorageRequest<?>>
implements StorageObjectRequest<T> {
private final T request;
private final String operationName;

public GoogleCloudStorageObjectsRequest(T request, String operationName) {
this.request = request;
this.operationName = operationName;
}

@Override
public StorageObject execute() throws IOException {
// Long startTime = System.currentTimeMillis();
return (StorageObject) request.execute();
// increment GCS_API_TOTAL metric by System.currentTimeMillis() - startTime;
// if time is greater > threshold then log
}

@Override
public String getOperationName() {
return operationName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.google.cloud.hadoop.gcsio;

import com.google.api.services.storage.model.StorageObject;
import java.io.IOException;

public interface StorageObjectRequest<T> {
StorageObject execute() throws IOException;

String getOperationName(); // Method to retrieve the operation name
}