]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_log.h
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
;
38 std::vector
<string
> token_claims
;
40 void encode(bufferlist
&bl
) const {
41 ENCODE_START(11, 5, bl
);
42 encode(object_owner
.id
, bl
);
43 encode(bucket_owner
.id
, bl
);
46 encode(remote_addr
, bl
);
51 encode(http_status
, bl
);
52 encode(error_code
, bl
);
53 encode(bytes_sent
, bl
);
55 encode(total_time
, bl
);
56 encode(user_agent
, bl
);
58 encode(bytes_received
, bl
);
59 encode(bucket_id
, bl
);
61 encode(object_owner
, bl
);
62 encode(bucket_owner
, bl
);
63 encode(x_headers
, bl
);
65 encode(token_claims
, bl
);
68 void decode(bufferlist::const_iterator
&p
) {
69 DECODE_START_LEGACY_COMPAT_LEN(11, 5, 5, p
);
70 decode(object_owner
.id
, p
);
72 decode(bucket_owner
.id
, p
);
75 decode(remote_addr
, p
);
80 decode(http_status
, p
);
81 decode(error_code
, p
);
82 decode(bytes_sent
, p
);
84 decode(total_time
, p
);
85 decode(user_agent
, p
);
88 decode(bytes_received
, p
);
97 snprintf(buf
, sizeof(buf
), "%" PRIu64
, id
);
100 decode(bucket_id
, p
);
109 decode(object_owner
, p
);
110 decode(bucket_owner
, p
);
113 decode(x_headers
, p
);
115 if (struct_v
>= 10) {
118 if (struct_v
>= 11) {
119 decode(token_claims
, p
);
123 void dump(ceph::Formatter
*f
) const;
124 static void generate_test_instances(list
<rgw_log_entry
*>& o
);
126 WRITE_CLASS_ENCODER(rgw_log_entry
)
128 class OpsLogSocket
: public OutputDataSocket
{
129 ceph::Formatter
*formatter
;
130 ceph::mutex lock
= ceph::make_mutex("OpsLogSocket");
132 void formatter_to_bl(bufferlist
& bl
);
135 void init_connection(bufferlist
& bl
) override
;
138 OpsLogSocket(CephContext
*cct
, uint64_t _backlog
);
139 ~OpsLogSocket() override
;
141 void log(struct rgw_log_entry
& entry
);
146 int rgw_log_op(RGWRados
*store
, RGWREST
* const rest
, struct req_state
*s
,
147 const string
& op_name
, OpsLogSocket
*olog
);
148 void rgw_log_usage_init(CephContext
*cct
, RGWRados
*store
);
149 void rgw_log_usage_finalize();
150 void rgw_format_ops_log_entry(struct rgw_log_entry
& entry
,
151 ceph::Formatter
*formatter
);
153 #endif /* CEPH_RGW_LOG_H */