2626namespace dingofs {
2727namespace blockaccess {
2828
29- using stub::metric::MetricGuard;
30- using stub::metric::S3Metric;
31-
3229bool S3Accesser::Init () {
3330 const auto & s3_info = options_.s3_info ;
3431 LOG (INFO) << fmt::format (
@@ -57,12 +54,7 @@ bool S3Accesser::ContainerExist() { return client_->BucketExist(); }
5754
5855Status S3Accesser::Put (const std::string& key, const char * buffer,
5956 size_t length) {
60- int rc = 0 ;
61- // write s3 metrics
62- auto start = butil::cpuwide_time_us ();
63- MetricGuard guard (&rc, &S3Metric::GetInstance ().write_s3 , length, start);
64-
65- rc = client_->PutObject (S3Key (key), buffer, length);
57+ int rc = client_->PutObject (S3Key (key), buffer, length);
6658 if (rc < 0 ) {
6759 LOG (ERROR) << fmt::format (" [accesser] put object({}) fail, retcode: {}." ,
6860 key, rc);
@@ -77,21 +69,14 @@ void S3Accesser::AsyncPut(std::shared_ptr<PutObjectAsyncContext> context) {
7769 auto start_time = butil::cpuwide_time_us ();
7870 context->cb = [&, start_time,
7971 origin_cb](const std::shared_ptr<PutObjectAsyncContext>& ctx) {
80- MetricGuard guard (&ctx->ret_code , &S3Metric::GetInstance ().write_s3 ,
81- ctx->buffer_size , start_time);
8272 ctx->cb = origin_cb;
8373 ctx->cb (ctx);
8474 };
8575 client_->PutObjectAsync (context);
8676}
8777
8878Status S3Accesser::Get (const std::string& key, std::string* data) {
89- int rc; // read s3 metrics
90- auto start = butil::cpuwide_time_us ();
91- MetricGuard guard (&rc, &S3Metric::GetInstance ().read_s3 , data->length (),
92- start);
93-
94- rc = client_->GetObject (S3Key (key), data);
79+ int rc = client_->GetObject (S3Key (key), data);
9580 if (rc < 0 ) {
9681 if (!client_->ObjectExist (S3Key (key))) { // TODO: more efficient
9782 LOG (WARNING) << fmt::format (" [accesser] object({}) not found." , key);
@@ -108,11 +93,7 @@ Status S3Accesser::Get(const std::string& key, std::string* data) {
10893
10994Status S3Accesser::Range (const std::string& key, off_t offset, size_t length,
11095 char * buffer) {
111- int rc; // read s3 metrics
112- auto start = butil::cpuwide_time_us ();
113- MetricGuard guard (&rc, &S3Metric::GetInstance ().read_s3 , length, start);
114-
115- rc = client_->RangeObject (S3Key (key), buffer, offset, length);
96+ int rc = client_->RangeObject (S3Key (key), buffer, offset, length);
11697 if (rc < 0 ) {
11798 if (!client_->ObjectExist (S3Key (key))) { // TODO: more efficient
11899 LOG (WARNING) << fmt::format (" [accesser] object({}) not found." , key);
@@ -132,8 +113,6 @@ void S3Accesser::AsyncGet(std::shared_ptr<GetObjectAsyncContext> context) {
132113 auto start_time = butil::cpuwide_time_us ();
133114 context->cb = [&, start_time,
134115 origin_cb](const std::shared_ptr<GetObjectAsyncContext>& ctx) {
135- MetricGuard guard (&ctx->ret_code , &S3Metric::GetInstance ().read_s3 ,
136- ctx->len , start_time);
137116 ctx->cb = origin_cb;
138117 ctx->cb (ctx);
139118 };
0 commit comments