CernVM-FS
2.12.0
|
#include <tracer.h>
Classes | |
struct | BufferEntry |
Public Types | |
enum | TraceEvents { kEventOpen = 1, kEventOpenDir, kEventReadlink, kEventLookup, kEventStatFs, kEventGetAttr, kEventListAttr, kEventGetXAttr } |
Public Member Functions | |
Tracer () | |
~Tracer () | |
void | Activate (const int buffer_size, const int flush_threshold, const std::string &trace_file) |
void | Spawn () |
void | Flush () |
void | __attribute__ ((used)) Trace(const int event |
bool | __attribute__ ((used)) IsActive() |
Public Attributes | |
void const PathString & | path |
void const PathString const std::string & | msg |
Private Member Functions | |
void | GetTimespecRel (const int64_t ms, timespec *ts) |
int | WriteCsvFile (FILE *fp, const std::string &field) |
int32_t | DoTrace (const int event, const PathString &path, const std::string &msg) |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Static Private Member Functions | |
static void * | MainFlush (void *data) |
Private Attributes | |
bool | active_ |
bool | spawned_ |
std::string | trace_file_ |
int | buffer_size_ |
int | flush_threshold_ |
BufferEntry * | ring_buffer_ |
atomic_int32 * | commit_buffer_ |
pthread_t | thread_flush_ |
pthread_cond_t | sig_flush_ |
pthread_mutex_t | sig_flush_mutex_ |
pthread_cond_t | sig_continue_trace_ |
pthread_mutex_t | sig_continue_trace_mutex_ |
atomic_int32 | seq_no_ |
atomic_int32 | flushed_ |
atomic_int32 | terminate_flush_thread_ |
atomic_int32 | flush_immediately_ |
Static Private Attributes | |
static const int | kEventStart = -1 |
static const int | kEventStop = -2 |
static const int | kEventFlush = -3 |
This file is part of the CernVM File System. Tracer is a thread-safe logging helper. It uses a ring buffer and spawns a helper thread, that flushes the messages onto the disk when necessary. The output file is in csv format. Usually tracing a message is a lock-free process, which therefore should have minimal overhead.
This is not supposed to be a debugging system. It is optimized for speed and does not try to gather any additional information (like threadid, status of variables, etc.).
Csv output is adapted from libcsv.
enum Tracer::TraceEvents |
Tracer::~Tracer | ( | ) |
|
inline |
void Tracer::Activate | ( | const int | buffer_size, |
const int | flush_threshold, | ||
const std::string & | trace_file | ||
) |
Definition at line 25 of file tracer.cc.
Referenced by MountPoint::CreateTracer().
|
private |
Trace a message. This is usually a lock-free procedure that just requires two fetch_and_add operations and a gettimeofday syscall. There are two exceptions:
[in] | event | Arbitrary code, for consistency applications should use one of the TraceEvents constants. Negative codes are reserved for internal use. |
[in] | id | Arbitrary id, for example file name or module name which is doing the trace. |
Definition at line 69 of file tracer.cc.
Referenced by ~Tracer().
void Tracer::Flush | ( | ) |
Definition at line 106 of file tracer.cc.
Referenced by TalkManager::MainResponder().
|
private |
Definition at line 133 of file tracer.cc.
Referenced by MainFlush().
|
staticprivate |
void Tracer::Spawn | ( | ) |
|
private |
Definition at line 269 of file tracer.cc.
Referenced by MainFlush().
|
private |
Definition at line 103 of file tracer.h.
Referenced by __attribute__(), and ~Tracer().
|
private |
Definition at line 106 of file tracer.h.
Referenced by MainFlush().
|
private |
Has the same size as the ring buffer. If a message is actually copied to the ring buffer memory, the respective flag is set to 1. Flags are reset to 0 by the flush thread.
Definition at line 114 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Definition at line 131 of file tracer.h.
Referenced by MainFlush(), and Tracer().
|
private |
Definition at line 107 of file tracer.h.
Referenced by MainFlush().
|
private |
Starts with 0 and gets incremented by the flush thread. Points to the first non-flushed message. flushed <= seq_no holds.
Definition at line 129 of file tracer.h.
Referenced by MainFlush(), and Tracer().
|
staticprivate |
|
staticprivate |
|
staticprivate |
void const PathString const std::string& Tracer::msg |
void const PathString& Tracer::path |
|
private |
Definition at line 108 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Starts with 0 and gets incremented by each call to trace. Contains the first non-used sequence number.
Definition at line 124 of file tracer.h.
Referenced by MainFlush(), and Tracer().
|
private |
Definition at line 118 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Definition at line 119 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Definition at line 116 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Definition at line 117 of file tracer.h.
Referenced by MainFlush(), and ~Tracer().
|
private |
Definition at line 130 of file tracer.h.
Referenced by MainFlush(), Tracer(), and ~Tracer().
|
private |
|
private |
Definition at line 105 of file tracer.h.
Referenced by MainFlush().