26
26
namespace dingofs {
27
27
namespace blockaccess {
28
28
29
- using stub::metric::MetricGuard;
30
- using stub::metric::S3Metric;
31
-
32
29
bool S3Accesser::Init () {
33
30
const auto & s3_info = options_.s3_info ;
34
31
LOG (INFO) << fmt::format (
@@ -57,12 +54,7 @@ bool S3Accesser::ContainerExist() { return client_->BucketExist(); }
57
54
58
55
Status S3Accesser::Put (const std::string& key, const char * buffer,
59
56
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);
66
58
if (rc < 0 ) {
67
59
LOG (ERROR) << fmt::format (" [accesser] put object({}) fail, retcode: {}." ,
68
60
key, rc);
@@ -77,21 +69,14 @@ void S3Accesser::AsyncPut(std::shared_ptr<PutObjectAsyncContext> context) {
77
69
auto start_time = butil::cpuwide_time_us ();
78
70
context->cb = [&, start_time,
79
71
origin_cb](const std::shared_ptr<PutObjectAsyncContext>& ctx) {
80
- MetricGuard guard (&ctx->ret_code , &S3Metric::GetInstance ().write_s3 ,
81
- ctx->buffer_size , start_time);
82
72
ctx->cb = origin_cb;
83
73
ctx->cb (ctx);
84
74
};
85
75
client_->PutObjectAsync (context);
86
76
}
87
77
88
78
Status 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);
95
80
if (rc < 0 ) {
96
81
if (!client_->ObjectExist (S3Key (key))) { // TODO: more efficient
97
82
LOG (WARNING) << fmt::format (" [accesser] object({}) not found." , key);
@@ -108,11 +93,7 @@ Status S3Accesser::Get(const std::string& key, std::string* data) {
108
93
109
94
Status S3Accesser::Range (const std::string& key, off_t offset, size_t length,
110
95
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);
116
97
if (rc < 0 ) {
117
98
if (!client_->ObjectExist (S3Key (key))) { // TODO: more efficient
118
99
LOG (WARNING) << fmt::format (" [accesser] object({}) not found." , key);
@@ -132,8 +113,6 @@ void S3Accesser::AsyncGet(std::shared_ptr<GetObjectAsyncContext> context) {
132
113
auto start_time = butil::cpuwide_time_us ();
133
114
context->cb = [&, start_time,
134
115
origin_cb](const std::shared_ptr<GetObjectAsyncContext>& ctx) {
135
- MetricGuard guard (&ctx->ret_code , &S3Metric::GetInstance ().read_s3 ,
136
- ctx->len , start_time);
137
116
ctx->cb = origin_cb;
138
117
ctx->cb (ctx);
139
118
};
0 commit comments