* Florian octo Forster <octo at collectd.org>
**/
-/* write_open_telemetry plugin configuration example
- *
- * <Plugin write_open_telemetry>
- * <Node "name">
- * Host "localhost"
- * Port "8080"
- * Path "/v1/metrics"
- * </Node>
- * </Plugin>
- */
-
extern "C" {
#include "collectd.h"
grpc::Status status = cb->stub->Export(&context, *req, &resp);
if (!status.ok()) {
- ERROR("write_open_telemetry plugin: Exporting metrics failed: %s",
+ ERROR("open_telemetry plugin: Exporting metrics failed: %s",
status.error_message().c_str());
return -1;
}
if (resp.has_partial_success() &&
resp.partial_success().rejected_data_points() > 0) {
auto ps = resp.partial_success();
- NOTICE("write_open_telemetry plugin: %" PRId64
- " data points were rejected: %s",
+ NOTICE("open_telemetry plugin: %" PRId64 " data points were rejected: %s",
ps.rejected_data_points(), ps.error_message().c_str());
}
int exporter_config(oconfig_item_t *ci) {
ot_callback_t *cb = (ot_callback_t *)calloc(1, sizeof(*cb));
if (cb == NULL) {
- ERROR("write_open_telemetry plugin: calloc failed.");
+ ERROR("open_telemetry plugin: calloc failed.");
return -1;
}
else if (strcasecmp("Port", child->key) == 0)
status = cf_util_get_service(child, &cb->port);
else {
- ERROR("write_open_telemetry plugin: Invalid configuration "
- "option: %s.",
- child->key);
+ ERROR("open_telemetry plugin: invalid config option: %s.", child->key);
status = -1;
}
}
strbuf_t callback_name = STRBUF_CREATE;
- strbuf_printf(&callback_name, "write_open_telemetry/%s", cb->name);
+ strbuf_printf(&callback_name, "open_telemetry/%s", cb->name);
user_data_t user_data = {
.data = cb,
f.open(filename);
if (!f.is_open()) {
- ERROR("open_telemetry_collector: Failed to open '%s'", filename);
+ ERROR("open_telemetry plugin: Failed to open '%s'", filename);
return "";
}
static grpc::Status unmarshal_sum_metric(Sum sum, metric_family_t *fam) {
if (!sum.is_monotonic()) {
// TODO(octo): convert to gauge instead?
- DEBUG("open_telemetry_collector: non-monotonic sums (aka. UpDownCounters) "
+ DEBUG("open_telemetry plugin: non-monotonic sums (aka. UpDownCounters) "
"are unsupported");
return grpc::Status(
grpc::StatusCode::UNIMPLEMENTED,
for (auto rm : req->resource_metrics()) {
grpc::Status s = dispatch_resource_metrics(rm, ps);
if (!s.ok()) {
- ERROR("open_telemetry_collector: dispatch_resource_metrics failed: %s",
+ ERROR("open_telemetry plugin: dispatch_resource_metrics failed: %s",
s.error_message().c_str());
return s;
}
if (listeners.empty()) {
builder.AddListeningPort(default_addr, auth);
- INFO("open_telemetry_collector: Listening on %s", default_addr.c_str());
+ INFO("open_telemetry plugin: Listening on %s", default_addr.c_str());
} else {
for (auto l : listeners) {
grpc::string addr = l.addr + ":" + l.port;
}
builder.AddListeningPort(addr, a);
- INFO("open_telemetry_collector: Listening on %s%s", addr.c_str(),
+ INFO("open_telemetry plugin: Listening on %s%s", addr.c_str(),
use_ssl.c_str());
}
}
server = new CollectorServer();
if (!server) {
- ERROR("open_telemetry_collector: Failed to create server");
+ ERROR("open_telemetry plugin: Failed to create server");
return -1;
}
static void receiver_install_callbacks(void) {
static bool done;
- if (done) {
- return;
+ if (!done) {
+ plugin_register_init("open_telemetry_receiver", receiver_init);
+ plugin_register_shutdown("open_telemetry_receiver", receiver_shutdown);
}
- plugin_register_init("open_telemetry_collector", receiver_init);
- plugin_register_shutdown("open_telemetry_collector", receiver_shutdown);
-
done = true;
}
int receiver_config(oconfig_item_t *ci) {
if ((ci->values_num != 2) || (ci->values[0].type != OCONFIG_TYPE_STRING) ||
(ci->values[1].type != OCONFIG_TYPE_STRING)) {
- ERROR("open_telemetry_collector: The `%s` config option needs exactly "
+ ERROR("open_telemetry plugin: The `%s` config option needs exactly "
"two string argument (address and port).",
ci->key);
return -1;
if (!strcasecmp("EnableSSL", child->key)) {
if (cf_util_get_boolean(child, &use_ssl)) {
- ERROR("open_telemetry_collector: Option `%s` expects a boolean value",
+ ERROR("open_telemetry plugin: Option `%s` expects a boolean value",
child->key);
return -1;
}
} else if (!strcasecmp("SSLCACertificateFile", child->key)) {
char *certs = NULL;
if (cf_util_get_string(child, &certs)) {
- ERROR("open_telemetry_collector: Option `%s` expects a string value",
+ ERROR("open_telemetry plugin: Option `%s` expects a string value",
child->key);
return -1;
}
} else if (!strcasecmp("SSLCertificateKeyFile", child->key)) {
char *key = NULL;
if (cf_util_get_string(child, &key)) {
- ERROR("open_telemetry_collector: Option `%s` expects a string value",
+ ERROR("open_telemetry plugin: Option `%s` expects a string value",
child->key);
return -1;
}
} else if (!strcasecmp("SSLCertificateFile", child->key)) {
char *cert = NULL;
if (cf_util_get_string(child, &cert)) {
- ERROR("open_telemetry_collector: Option `%s` expects a string value",
+ ERROR("open_telemetry plugin: Option `%s` expects a string value",
child->key);
return -1;
}
verify ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
: GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
} else {
- WARNING(
- "open_telemetry_collector: Option `%s` not allowed in <%s> block.",
- child->key, ci->key);
+ WARNING("open_telemetry plugin: Option `%s` not allowed in <%s> block.",
+ child->key, ci->key);
}
}