]> git.proxmox.com Git - ceph.git/blob - ceph/doc/dev/logs.rst
update ceph source to reef 18.2.1
[ceph.git] / ceph / doc / dev / logs.rst
1 ============
2 Debug logs
3 ============
4
5 The main debugging tool for Ceph is the dout and derr logging functions.
6 Collectively, these are referred to as "dout logging."
7
8 Dout has several log faculties, which can be set at various log
9 levels using the configuration management system. So it is possible to enable
10 debugging just for the messenger, by setting debug_ms to 10, for example.
11
12 The dout macro avoids even generating log messages which are not going to be
13 used, by enclosing them in an "if" statement. What this means is that if you
14 have the debug level set at 0, and you run this code::
15
16 dout(20) << "myfoo() = " << myfoo() << dendl;
17
18
19 myfoo() will not be called here.
20
21 Unfortunately, the performance of debug logging is relatively low. This is
22 because there is a single, process-wide mutex which every debug output
23 statement takes, and every debug output statement leads to a write() system
24 call or a call to syslog(). There is also a computational overhead to using C++
25 streams to consider. So you will need to be parsimonious in your logging to get
26 the best performance.
27
28 Sometimes, enabling logging can hide race conditions and other bugs by changing
29 the timing of events. Keep this in mind when debugging.
30
31 Performance counters
32 ====================
33
34 Ceph daemons use performance counters to track key statistics like number of
35 inodes pinned. Performance counters are essentially sets of integers and floats
36 which can be set, incremented, and read using the PerfCounters API.
37
38 A PerfCounters object is usually associated with a single subsystem. It
39 contains multiple counters. This object is thread-safe because it is protected
40 by an internal mutex. You can create multiple PerfCounters objects.
41
42 Currently, three types of performance counters are supported: u64 counters,
43 float counters, and long-run floating-point average counters. These are created
44 by PerfCountersBuilder::add_u64, PerfCountersBuilder::add_fl, and
45 PerfCountersBuilder::add_fl_avg, respectively. u64 and float counters simply
46 provide a single value which can be updated, incremented, and read atomically.
47 floating-pointer average counters provide two values: the current total, and
48 the number of times the total has been changed. This is intended to provide a
49 long-run average value.
50
51 Performance counter information can be read in JSON format from the
52 administrative socket (admin_sock). This is implemented as a UNIX domain
53 socket. The Ceph performance counter plugin for collectd shows an example of how
54 to access this information. Another example can be found in the unit tests for
55 the administrative sockets.