C++ error tracking
Know when your C++ app breaks, before your users do
ForgeOps connects the errors your C++ app reports to the deploys, traces, and changes around them, so when production breaks, the incident already says who's affected, what changed, and where to look.
A captured exception's backtrace comes from backtrace_symbols, ready to report from any C++ codebase. Running on ForgeOps' own dedicated infrastructure, so nothing about a C++ app's errors or its users' data gets routed through a third-party error-tracking vendor. See an incident investigated →
Install
// Clone github.com/Luke-Popwell/forge-ops-tracker-cpp (tag v0.9.0), add its include/ and src/ to your own build, and link nlohmann/json + libcurl
#include <forge_ops_tracker/forge_ops_tracker.hpp>
forge_ops_tracker::init([](auto& config) {
config.dsn = "https://<api_key>@getforgeops.net/api/v1/events";
});
forge_ops_tracker::install_terminate_handler();
A captured exception's backtrace comes from backtrace_symbols, ready to report from any C++ codebase.
Every client reports the same shape
Wherever it comes from, an event arrives with an exception class, a message, and a backtrace, plus whatever environment/release/server context that client can gather on its own. ForgeOps fingerprints and groups on the first three, so a C++ app's issues list works exactly the same way every other language's does: report the same bug a thousand times and it's still one row, not a thousand.
No agent, no sidecar: it's a plain HTTPS POST to ForgeOps' own ingestion API, so nothing about a C++ app's traffic gets routed through a third-party pipeline first.
Works with your framework
The C++ client hooks in at the framework level, not by wrapping individual calls, so nothing about how you already write C++ code has to change.
std::terminate handler
install_terminate_handler reports whatever exception is in flight and sends it (waiting at most 2 seconds) before chaining to the previously-installed handler, the closest C++ equivalent to an uncaught-exception hook. Call flush_errors() before std::quick_exit or std::_Exit, which skip it.
Plain try/catch
capture_exception reports an exception you've already caught, from any C++ codebase, framework or not.
What it looks like
The issue list
Every C++ issue reported into a project shows up here: title, status, assignee, event count, and when it was last seen, the same columns as any other language's project.
The issue detail
Every occurrence keeps its own timestamp, environment, release, and server, plus the backtrace exactly as C++ reported it, expandable per occurrence rather than flattened into one generic stack.
Alerting
A new C++ issue, a regression, or a spike past a threshold you set can reach Slack, Microsoft Teams, email, PagerDuty, Opsgenie, or a generic webhook, configured per project, per trigger.
Heartbeats
For the failure mode error tracking can't see on its own: a C++ cron job or recurring task that's supposed to run but silently stopped. Each heartbeat gets its own ping URL and its own grace period before it alerts.
Performance monitoring
Times whatever you wrap and reports one small aggregate per transaction, flushed on Configuration::performance_flush_interval, never one network call per timed call. This client has no web framework integration, so nothing is timed automatically: you choose what to wrap. Keep transaction names low-cardinality ("GET /users/:id", not "GET /users/42"), since every distinct name is its own row. ScopedTransaction is timed even when its scope throws, because its destructor runs during stack unwinding. Turn it off with track_performance = false. What's left is flushed when the process exits normally; flush_performance() sends it right now. Each report also carries a small latency histogram, so ForgeOps shows an approximate p50/p95/p99 per transaction, not just an average, accurate to the width of the latency bucket a duration falls into. Requires a plan that includes performance monitoring; on a plan that doesn't, the periodic reports are accepted but not recorded (the response says why), so a working setup never looks broken.
// RAII: records how long the scope lived, even if it throws.
{
forge_ops_tracker::ScopedTransaction timing("GET /users/:id");
handle_request(request);
}
// Or wrap a callable, and keep its return value:
auto user = forge_ops_tracker::time_transaction("load-user", [&] { return load_user(id); });
// Or record a duration you measured yourself, in milliseconds:
forge_ops_tracker::record_performance("nightly-export", elapsed_ms);
Distributed tracing
There is no web framework here, so you wrap the unit of work you want traced in a ScopedTrace, and anything inside it on the same thread can add spans. Both RAII types record from their destructor, so a scope that throws is still recorded. Only a slow call's trace is ever sent: whether it crossed the threshold (one second by default, configurable) is decided entirely inside your process, so a fast call costs nothing over the wire. Requires a plan that includes distributed tracing.
{
forge_ops_tracker::ScopedTrace trace("GET /checkout");
forge_ops_tracker::ScopedSpan load("load order", "database", {{"order_id", 42}});
auto order = repo.find(42);
forge_ops_tracker::span("charge card", "service", [&] { return gateway.charge(order); });
// Something you timed yourself (kind is one of controller/service/database/redis/http/job/other):
forge_ops_tracker::record_span("SELECT orders", "database", started_at, duration_ms);
}
Make a request inside a trace through http_span (or a ScopedHttpSpan) and it's recorded as its own http span and handed the standard traceparent header to send, so the service you call nests its request under it. Pass a request's own traceparent to ScopedTrace to continue the caller's trace instead. An error captured inside the trace carries its trace id: with the other service on the current ForgeOps server SDK and the two projects linked in ForgeOps, the failed checkout shows the API error from the very same request. Limit which hosts get the header with trace_propagation_targets. Needs tag v0.4.0.
{
forge_ops_tracker::ScopedTrace trace("POST /checkout", request.header("traceparent")); // std::nullopt starts a new one
try {
auto response = forge_ops_tracker::http_span("POST", url, [&](const std::optional<std::string>& traceparent) {
if (traceparent) payment.set_header(forge_ops_tracker::trace_parent::header, *traceparent);
return client.send(payment);
});
if (response.status != 201) throw std::runtime_error("payment was declined");
} catch (const std::exception& e) {
forge_ops_tracker::capture_exception(e, {{"order_id", "42"}}); // carries this trace's id
}
}
SQL in a request
When the request an issue failed in was traced, the issue opens with its slowest query: how long it took, its share of the request's time, how many queries the request ran, and a likely N+1 warning when the same statement ran five or more times. This client doesn't instrument a database library, so give a database span its SQL with set_statement, or use database_span around a callable. The statement is masked before it leaves your process, every string and number replaced with a question mark, and the same SQL shows under that span's bar in the trace's waterfall. Needs tag v0.6.0, on a plan that includes distributed tracing.
const std::string sql = "SELECT * FROM readings WHERE sensor_id = 42 AND label = 'boiler'";
{
forge_ops_tracker::ScopedTrace trace("GET /readings");
forge_ops_tracker::ScopedSpan query("Load readings", "database");
query.set_statement(sql, "sqlite");
sqlite3_exec(db, sql.c_str(), on_row, nullptr, nullptr);
}
// Sent as "SELECT * FROM readings WHERE sensor_id = ? AND label = ?"
// Or around a callable:
auto rows = forge_ops_tracker::database_span("Load readings", sql, "sqlite", [&] { return load(sql); });
What changed
When a feature flag flips or a config value changes on a device or a server, record it from your flag client's callback, and it shows under What changed on any issue that starts in the next two hours, and on the project's Changes page beside your deploys, labeled potentially relevant, never as the cause. Delivery runs on a background thread, so the call never blocks on the network or throws, and anything still queued is sent when the process exits normally. There's no automatic startup snapshot here; every change is one you record. Needs tag v0.5.0, on a plan that includes change tracking.
#include <forge_ops_tracker/forge_ops_tracker.hpp>
// Your flag client's change callback, with the key and the old and new values
flag_client.on_change([](const std::string& key, bool from, bool to) {
forge_ops_tracker::ChangeOptions options;
options.actor = "flag-service";
forge_ops_tracker::record_change("feature_flag", key + (to ? " turned on" : " turned off"),
{{"flag", key}, {"from", from}, {"to", to}}, options);
});
Custom metrics and infrastructure monitoring
Track a business event you name yourself (a signup, a payment) or a reading from one of your own hosts, with one explicit call each; nothing is automatic. The value defaults to 1, so a bare call is a counter; pass a real amount for anything else (it can be negative, for a refund). A captured value is stored as its own row, so counts and sums you compute later are exact. Calls are buffered and flushed as one batch in the background, so they are safe to make inside a request, and flush_metrics sends whatever is buffered right now. The hostname of an infrastructure reading defaults to the configured server name. Requires a plan that includes custom metrics and infrastructure monitoring.
forge_ops_tracker::capture_metric("signup"); // value defaults to 1.0: a bare counter
forge_ops_tracker::capture_metric("payment", 49.0); // a real magnitude; it may be negative (a refund)
forge_ops_tracker::capture_infrastructure_metric("cpu", 0.42); // hostname defaults to server_name
forge_ops_tracker::capture_infrastructure_metric("disk", 0.81, "db-1");
forge_ops_tracker::flush_metrics(); // send right now
Database errors
When an error comes from a database call, the issue shows which stored procedure, table or view its SQL touched, so you know where to start looking. A C++ exception carries no SQL of its own, so hand it over where you ran the query: throw a SqlException, or report the driver's own exception with capture_exception_with_sql. The names are sent by default and are identifiers, never values. The SQL statement itself is opt-in, with every string and number replaced by a question mark before it leaves your app, and a project setting can stop ForgeOps storing the statement at all.
try {
session << query, soci::use(id);
} catch (const std::exception& e) {
forge_ops_tracker::capture_exception_with_sql(e, query);
throw;
}
// Opt in to also sending the masked statement (default false).
forge_ops_tracker::init([](forge_ops_tracker::Configuration& c) { c.capture_sql_statement = true; });
Questions
Do I need to change how I already handle errors?
Almost never. Every client hooks the framework's own exception handling directly, the same way the install snippet above shows, so your own logs, error pages, and rescue blocks keep working exactly as they did before, and ForgeOps just also finds out about it. The one common exception is a background-job runner that doesn't forward through that same mechanism on its own; that needs one small hook added instead, not a change to anything already there.
Where does the data actually go?
Straight to ForgeOps' own ingestion API over plain HTTPS. No agent, no sidecar, and no third-party ingestion service in between, so nothing about your app's traffic or its users' data gets routed through anyone else's pipeline first.
What happens if the same bug fires a thousand times?
It's fingerprinted from its exception class, message, and backtrace, so a thousand reports of the same bug still show up as one issue with an event count of 1,000, not a thousand separate rows to dig through. And a runaway loop can't use up your monthly event quota: once one issue repeats faster than your plan's hourly limit (50 an hour on Free), further repeats are still counted, and still count toward spike alerts, but they aren't stored or charged to your quota.
Is anything scrubbed before it's stored?
Yes. Emails, credit card numbers, and known API key/token formats are redacted out of every event before it's even written, on every plan, with room for per-project custom field names on top of the defaults.
Try it with your own C++ app
Free plan included, no credit card required. New organizations start with 14 days of Business.
Get started freeGet