]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_log.h
e8ac71cc053a150e3245adf6a96a9405b8a8dadd
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
7 #include <boost/container/flat_map.hpp>
8 #include "rgw_common.h"
9 #include "common/OutputDataSocket.h"
13 struct rgw_log_entry
{
15 using headers_map
= boost::container::flat_map
<std::string
, std::string
>;
16 using Clock
= req_state::Clock
;
18 rgw_user object_owner
;
19 rgw_user bucket_owner
;
21 Clock::time_point time
;
29 uint64_t bytes_sent
= 0;
30 uint64_t bytes_received
= 0;
31 uint64_t obj_size
= 0;
32 Clock::duration total_time
{};
36 headers_map x_headers
;
39 void encode(bufferlist
&bl
) const {
40 ENCODE_START(10, 5, bl
);
41 encode(object_owner
.id
, bl
);
42 encode(bucket_owner
.id
, bl
);
45 encode(remote_addr
, bl
);
50 encode(http_status
, bl
);
51 encode(error_code
, bl
);
52 encode(bytes_sent
, bl
);
54 encode(total_time
, bl
);
55 encode(user_agent
, bl
);
57 encode(bytes_received
, bl
);
58 encode(bucket_id
, bl
);
60 encode(object_owner
, bl
);
61 encode(bucket_owner
, bl
);
62 encode(x_headers
, bl
);
66 void decode(bufferlist::const_iterator
&p
) {
67 DECODE_START_LEGACY_COMPAT_LEN(10, 5, 5, p
);
68 decode(object_owner
.id
, p
);
70 decode(bucket_owner
.id
, p
);
73 decode(remote_addr
, p
);
78 decode(http_status
, p
);
79 decode(error_code
, p
);
80 decode(bytes_sent
, p
);
82 decode(total_time
, p
);
83 decode(user_agent
, p
);
86 decode(bytes_received
, p
);
95 snprintf(buf
, sizeof(buf
), "%" PRIu64
, id
);
107 decode(object_owner
, p
);
108 decode(bucket_owner
, p
);
111 decode(x_headers
, p
);
113 if (struct_v
>= 10) {
118 void dump(ceph::Formatter
*f
) const;
119 static void generate_test_instances(list
<rgw_log_entry
*>& o
);
121 WRITE_CLASS_ENCODER(rgw_log_entry
)
123 class OpsLogSocket
: public OutputDataSocket
{
124 ceph::Formatter
*formatter
;
125 ceph::mutex lock
= ceph::make_mutex("OpsLogSocket");
127 void formatter_to_bl(bufferlist
& bl
);
130 void init_connection(bufferlist
& bl
) override
;
133 OpsLogSocket(CephContext
*cct
, uint64_t _backlog
);
134 ~OpsLogSocket() override
;
136 void log(struct rgw_log_entry
& entry
);
141 int rgw_log_op(RGWRados
*store
, RGWREST
* const rest
, struct req_state
*s
,
142 const string
& op_name
, OpsLogSocket
*olog
);
143 void rgw_log_usage_init(CephContext
*cct
, RGWRados
*store
);
144 void rgw_log_usage_finalize();
145 void rgw_format_ops_log_entry(struct rgw_log_entry
& entry
,
146 ceph::Formatter
*formatter
);
148 #endif /* CEPH_RGW_LOG_H */