https://github.com/couchbase/phosphor
High performance event tracing
https://github.com/couchbase/phosphor
Last synced: 9 months ago
JSON representation
High performance event tracing
- Host: GitHub
- URL: https://github.com/couchbase/phosphor
- Owner: couchbase
- License: other
- Created: 2016-05-19T15:36:20.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-10-02T05:39:58.000Z (9 months ago)
- Last Synced: 2025-10-02T07:20:49.133Z (9 months ago)
- Language: C++
- Homepage:
- Size: 3.3 MB
- Stars: 17
- Watchers: 40
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Phosphor
[](LICENSE.txt)
Phosphor is a high-performance event tracing framework for C++11 applications
designed for use in Couchbase Server - specifically KV Engine and ForestDB.
Event tracing is implemented in an application by instrumenting it as
described in [phosphor.h](include/phosphor/phosphor.h). You can then enable
and manage tracing using the management API described in
[trace_log.h](include/phosphor/trace_log.h).
## Example
The following is an example of hypothetical instrumentation in memcached:
void performSet(ENGINE_HANDLE* engine, const char* key, const char* value) {
TRACE_EVENT_START1("Memcached:Operation", "performSet", "key", key);
// Perform a set operation
TRACE_EVENT_END0("Memcached:Operation", "performSet");
}
The following is an example of enabling tracing with a fixed-style 5MB buffer:
phosphor::TraceConfig config(phosphor::BufferMode::fixed, 5 * 1024 * 1024);
phosphor::TraceLog::getInstance().start(config);
Once the trace buffer becomes full you can retrieve it and iterate over it:
auto trace_buffer = phosphor::TraceLog::getInstance().getBuffer();
for(auto& event : *trace_buffer) {
std::cout << event << '\n';
}
## Build
Phosphor is written in C++17 and requires a mostly conforming compiler.
Phosphor is built as part of the full server build.
See [Build Couchbase server](https://github.com/couchbase/tlm#how-to-build) for
more information.
## Documentation
Documentation for Phosphor can be found on
[couchbase.github.io/phosphor](http://couchbase.github.io/phosphor/). The
documentation is generated by Doxygen and can be done using `make
docs` with the top level Makefile.