Name Date Size

..19-Aug-20204 KiB

.gitignoreH A D19-Aug-2020446

.gitmodulesH A D19-Aug-2020376

CMakeLists.txtH A D19-Aug-20203.5 KiB

docs/H19-Aug-20204 KiB

DoxyfileH A D19-Aug-2020102.7 KiB

examples/H19-Aug-20204 KiB

include/H19-Aug-20204 KiB

LICENSE.txtH A D19-Aug-202011.1 KiB

MakefileH A D19-Aug-20201.4 KiB

NonServerBuild.cmakeH A D19-Aug-20201.6 KiB

README.mdH A D19-Aug-20201.9 KiB

scripts/H19-Aug-20204 KiB

src/H19-Aug-20204 KiB

tests/H19-Aug-20204 KiB

thirdparty/H19-Aug-20204 KiB

README.md

1# Phosphor
2
3[![License](https://img.shields.io/github/license/couchbaselabs/phosphor.svg)](LICENSE.txt)
4
5Phosphor is a high-performance event tracing framework for C++11 applications
6designed for use in Couchbase Server - specifically KV Engine and ForestDB.
7
8Event tracing is implemented in an application by instrumenting it as
9described in [phosphor.h](include/phosphor/phosphor.h). You can then enable
10and manage tracing using the management API described in
11[trace_log.h](include/phosphor/trace_log.h).
12
13## Example
14The following is an example of hypothetical instrumentation in memcached:
15
16    void performSet(ENGINE_HANDLE* engine, const char* key, const char* value) {
17        TRACE_EVENT_START1("Memcached:Operation", "performSet", "key", key);
18        // Perform a set operation
19        TRACE_EVENT_END0("Memcached:Operation", "performSet");
20    }
21
22The following is an example of enabling tracing with a fixed-style 5MB buffer:
23
24    phosphor::TraceConfig config(phosphor::BufferMode::fixed, 5 * 1024 * 1024);
25    phosphor::TraceLog::getInstance().start(config);
26
27Once the trace buffer becomes full you can retrieve it and iterate over it:
28
29    auto trace_buffer = phosphor::TraceLog::getInstance().getBuffer();
30    for(auto& event : *trace_buffer) {
31        std::cout << event << '\n';
32    }
33
34## Build
35
36Phosphor is written in C++11 and requires a mostly conforming compiler. Many
37early C++11 implementations used slow or even inaccurate clock sources which can
38cause issues with tracing.
39
40Phosphor can be built with CMake, a top level Makefile is provided for
41convenience. A simple `make compile` and `make test` will compile and run the
42tests.
43
44Phosphor can be built and tested with code coverage by running `make covered`.
45
46## Documentation
47
48Documentation for Phosphor can be found on
49[couchbase.github.io/phosphor](http://couchbase.github.io/phosphor/). The
50documentation is generated by Doxygen and can be done using `make
51docs` with the top level Makefile.
52