An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Phosphor

[![License](https://img.shields.io/github/license/couchbaselabs/phosphor.svg)](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.