if (name == nullptr || nameLen == 0 || type == nullptr || description == nullptr) {
return false;
}
- // TODO: add labels options?
auto result = dnsdist::metrics::declareCustomMetric(name, type, description, customName != nullptr ? std::optional<std::string>(customName) : std::nullopt, false);
return !result;
}
void dnsdist_ffi_metric_inc(const char* metricName, size_t metricNameLen)
{
- // TODO: add labels?
auto result = dnsdist::metrics::incrementCustomCounter(std::string_view(metricName, metricNameLen), 1U, {});
if (std::get_if<dnsdist::metrics::Error>(&result) != nullptr) {
return;
void dnsdist_ffi_metric_inc_by(const char* metricName, size_t metricNameLen, uint64_t value)
{
- // TODO: add labels?
auto result = dnsdist::metrics::incrementCustomCounter(std::string_view(metricName, metricNameLen), value, {});
if (std::get_if<dnsdist::metrics::Error>(&result) != nullptr) {
return;
void dnsdist_ffi_metric_dec(const char* metricName, size_t metricNameLen)
{
- // TODO: add labels?
auto result = dnsdist::metrics::decrementCustomCounter(std::string_view(metricName, metricNameLen), 1U, {});
if (std::get_if<dnsdist::metrics::Error>(&result) != nullptr) {
return;
void dnsdist_ffi_metric_set(const char* metricName, size_t metricNameLen, double value)
{
- // TODO: add labels?
auto result = dnsdist::metrics::setCustomGauge(std::string_view(metricName, metricNameLen), value, {});
if (std::get_if<dnsdist::metrics::Error>(&result) != nullptr) {
return;
double dnsdist_ffi_metric_get(const char* metricName, size_t metricNameLen, bool isCounter)
{
- // TODO: add labels?
auto result = dnsdist::metrics::getCustomMetric(std::string_view(metricName, metricNameLen), {});
if (std::get_if<dnsdist::metrics::Error>(&result) != nullptr) {
return 0.;