Skip to content

Commit

Permalink
Group attributes in otel json
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Jun 24, 2024
1 parent 337e689 commit 8bdd85d
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/pg_tracing_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ append_resource(StringInfo str)
static void
append_plan_counters(StringInfo str, const PlanCounters * plan_counters)
{
append_attribute_double(str, "startup_cost", plan_counters->startup_cost, true);
append_attribute_double(str, "startup_cost", plan_counters->total_cost, true);
append_attribute_double(str, "plan_rows", plan_counters->plan_rows, true);
append_attribute_int(str, "plan_width", plan_counters->plan_width, true);
append_attribute_double(str, "plan.cost.startup", plan_counters->startup_cost, true);
append_attribute_double(str, "plan.cost.total", plan_counters->total_cost, true);
append_attribute_double(str, "plan.rows", plan_counters->plan_rows, true);
append_attribute_int(str, "plan.width", plan_counters->plan_width, true);
}

static void
Expand All @@ -135,15 +135,15 @@ append_node_counters(StringInfo str, const NodeCounters * node_counters)
append_attribute_int(str, "nloops", node_counters->nloops, true);

/* Block usage */
append_attribute_int(str, "shared_blks_hit", node_counters->buffer_usage.shared_blks_hit, true);
append_attribute_int(str, "shared_blks_read", node_counters->buffer_usage.shared_blks_read, true);
append_attribute_int(str, "shared_blks_dirtied", node_counters->buffer_usage.shared_blks_dirtied, true);
append_attribute_int(str, "shared_blks_written", node_counters->buffer_usage.shared_blks_written, true);
append_attribute_int(str, "blocks.shared.hit", node_counters->buffer_usage.shared_blks_hit, true);
append_attribute_int(str, "blocks.shared.read", node_counters->buffer_usage.shared_blks_read, true);
append_attribute_int(str, "blocks.shared.dirtied", node_counters->buffer_usage.shared_blks_dirtied, true);
append_attribute_int(str, "blocks.shared.written", node_counters->buffer_usage.shared_blks_written, true);

append_attribute_int(str, "local_blks_hit", node_counters->buffer_usage.local_blks_hit, true);
append_attribute_int(str, "local_blks_read", node_counters->buffer_usage.local_blks_read, true);
append_attribute_int(str, "local_blks_dirtied", node_counters->buffer_usage.local_blks_dirtied, true);
append_attribute_int(str, "local_blks_written", node_counters->buffer_usage.local_blks_written, true);
append_attribute_int(str, "blocks.local.hit", node_counters->buffer_usage.local_blks_hit, true);
append_attribute_int(str, "blocks.local.read", node_counters->buffer_usage.local_blks_read, true);
append_attribute_int(str, "blocks.local.dirtied", node_counters->buffer_usage.local_blks_dirtied, true);
append_attribute_int(str, "blocks.local.written", node_counters->buffer_usage.local_blks_written, true);

#if PG_VERSION_NUM >= 170000
blk_read_time = INSTR_TIME_GET_MILLISEC(node_counters->buffer_usage.shared_blk_read_time);
Expand All @@ -152,34 +152,32 @@ append_node_counters(StringInfo str, const NodeCounters * node_counters)
blk_read_time = INSTR_TIME_GET_MILLISEC(node_counters->buffer_usage.blk_read_time);
blk_write_time = INSTR_TIME_GET_MILLISEC(node_counters->buffer_usage.blk_write_time);
#endif
append_attribute_double(str, "blocks.read_time", blk_read_time, true);
append_attribute_double(str, "blocks.write_time", blk_write_time, true);

temp_blk_read_time = INSTR_TIME_GET_MILLISEC(node_counters->buffer_usage.temp_blk_read_time);
temp_blk_write_time = INSTR_TIME_GET_MILLISEC(node_counters->buffer_usage.temp_blk_write_time);

append_attribute_double(str, "blk_read_time", blk_read_time, true);
append_attribute_double(str, "blk_write_time", blk_write_time, true);
append_attribute_double(str, "temp_blk_read_time", temp_blk_read_time, true);
append_attribute_double(str, "temp_blk_write_time", temp_blk_write_time, true);

append_attribute_int(str, "temp_blks_read", node_counters->buffer_usage.temp_blks_read, true);
append_attribute_int(str, "temp_blks_written", node_counters->buffer_usage.temp_blks_written, true);
append_attribute_double(str, "temp_blocks.read_time", temp_blk_read_time, true);
append_attribute_double(str, "temp_blocks.write_time", temp_blk_write_time, true);
append_attribute_int(str, "temp_blocks.read", node_counters->buffer_usage.temp_blks_read, true);
append_attribute_int(str, "temp_blocks.written", node_counters->buffer_usage.temp_blks_written, true);

/* WAL usage */
append_attribute_int(str, "wal_records", node_counters->wal_usage.wal_records, true);
append_attribute_int(str, "wal_fpi", node_counters->wal_usage.wal_fpi, true);
append_attribute_int(str, "wal_bytes", node_counters->wal_usage.wal_bytes, true);
append_attribute_int(str, "wal.records", node_counters->wal_usage.wal_records, true);
append_attribute_int(str, "wal.fpi", node_counters->wal_usage.wal_fpi, true);
append_attribute_int(str, "wal.bytes", node_counters->wal_usage.wal_bytes, true);

/* JIT usage */
generation_counter = INSTR_TIME_GET_MILLISEC(node_counters->jit_usage.generation_counter);
inlining_counter = INSTR_TIME_GET_MILLISEC(node_counters->jit_usage.inlining_counter);
optimization_counter = INSTR_TIME_GET_MILLISEC(node_counters->jit_usage.optimization_counter);
emission_counter = INSTR_TIME_GET_MILLISEC(node_counters->jit_usage.emission_counter);
jit_created_functions = node_counters->jit_usage.created_functions;
append_attribute_int(str, "jit_created_functions", jit_created_functions, true);
append_attribute_double(str, "generation_counter", generation_counter, true);
append_attribute_double(str, "inlining_counter", inlining_counter, true);
append_attribute_double(str, "optimization_counter", optimization_counter, true);
append_attribute_double(str, "emission_counter", emission_counter, true);
append_attribute_int(str, "jit.created_functions", jit_created_functions, true);
append_attribute_double(str, "jit.generation_counter", generation_counter, true);
append_attribute_double(str, "jit.inlining_counter", inlining_counter, true);
append_attribute_double(str, "jit.optimization_counter", optimization_counter, true);
append_attribute_double(str, "jit.emission_counter", emission_counter, true);
}

static void
Expand Down

0 comments on commit 8bdd85d

Please sign in to comment.