Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/plugins/telemetry/doca/doca_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,12 @@ nixlTelemetryDocaExporter::appendCounterSample(const nixlTelemetryEvent &event,
const char *label_values[]) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
const std::string event_name(nixlEnumStrings::telemetryEventTypeStr(event.eventType_));
const char *event_name = nixlEnumStrings::telemetryEventTypeStr(event.eventType_).data();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling data() on a string_view and using the result as C-string should not be done, even in this case where the views happen to be, for now (!), constructed from C-strings, it's just such an anti-pattern. Perhaps return C-strings from the enum-to-name function?

// Counter events carry a per-operation delta; increment so the exported
// counter is a monotonic cumulative total (add_counter would instead push
// each delta as an absolute value, yielding a non-monotonic series).
return doca_telemetry_exporter_metrics_add_counter_increment(ctx_->source,
docaTimestamp(),
event_name.c_str(),
event.value_,
ctx_->label_set_id,
label_values);
return doca_telemetry_exporter_metrics_add_counter_increment(
ctx_->source, docaTimestamp(), event_name, event.value_, ctx_->label_set_id, label_values);
#pragma GCC diagnostic pop
}

Expand Down
Loading