diff --git a/README.md b/README.md index 12021d4..cdd71be 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,19 @@ pg_tracing is a PostgreSQL extension allows to generate server-side spans for distributed tracing. -When pg_tracing is active, it generates spans on sampled queries. To access these spans, the extension provides two views: `pg_tracing_consume_spans` and `pg_tracing_peek_spans`. The utility functions `pg_tracing_reset` and `pg_tracing_info` provide ways to read and reset extension's statistics. These are not available globally but can be enabled for a specific database with `CREATE EXTENSION pg_tracing`. +When pg_tracing is active, it generates spans on sampled queries. To access these spans, the extension provides two ways: +- `pg_tracing_consume_spans` and `pg_tracing_peek_spans` views output spans as a set of records +- `pg_tracing_json_spans` function outputs spans as a OTLP json -Trace propagation currently relies on [SQLCommenter](https://google.github.io/sqlcommenter/). More mechanisms will be added in the future. +The utility functions `pg_tracing_reset` and `pg_tracing_info` provide ways to read and reset extension's statistics. These are not available globally but can be enabled for a specific database with `CREATE EXTENSION pg_tracing`. -> [!WARNING] +There are currently two mechanisms to propagate trace context: +- As a SQL comment using [SQLCommenter](https://google.github.io/sqlcommenter/) +- As a GUC parameter `pg_tracing.trace_context` + +See [Trace Propagation](#trace-propagation) for more details. + +> [!WARNING] > This extension is still in early development and may be unstable. ## PostgreSQL Version Compatibility @@ -25,7 +33,8 @@ pg_tracing generates spans for the following events: - Execution Plan: A span is created for each node of the execution plan (SeqScan, NestedLoop, HashJoin...) - Nested queries: Statements invoked within another statement (like a function) - Triggers: Statements executed through BEFORE and AFTER trigger are tracked -- Parallel Workers: Processes created to handle queries like Parallel SeqScans are tracked +- Parallel Workers: Processes created to handle queries like Parallel SeqScans are tracked +- Transaction Commit: Time spent fsync changes on the WAL ## Documentation @@ -48,11 +57,14 @@ To compile and install the extension, run: git clone https://github.com/DataDog/pg_tracing.git cd pg_tracing make install +# To compile and install with debug symbols: +PG_CFLAGS="-g" make install ``` ## Setup -The extension must be loaded by adding pg_tracing to the [shared_preload_libraries](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES) in `postgresql.conf`. A server restart is needed to add or remove the extension. +The extension must be loaded by adding pg_tracing to the [shared_preload_libraries](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES) in `postgresql.conf`. +A server restart is needed to add or remove the extension. ``` # postgresql.conf @@ -61,13 +73,17 @@ shared_preload_libraries = 'pg_tracing' compute_query_id = on pg_tracing.max_span = 10000 pg_tracing.track = all + +# Send spans every 2 seconds to an otel collector +pg_tracing.otel_endpoint = http://127.0.0.1:4318/v1/traces +pg_tracing.otel_naptime = 2000 ``` The extension requires additional shared memory proportional to `pg_tracing.max_span`. Note that this memory is consumed whenever the extension is loaded, even if no spans are generated. -When `pg_tracing` is active, it generates spans on sampled queries. To access these spans, the extension provides two views: `pg_tracing_consume_spans` and `pg_tracing_peek_spans`. The utility functions `pg_tracing_reset` and `pg_tracing_info` provide ways to read and reset extension's statistics. These are not available globally but can be enabled for a specific database with `CREATE EXTENSION pg_tracing`. +## Trace Propagation -## Usage +### SQLCommenter Trace context can be propagated through [SQLCommenter](https://google.github.io/sqlcommenter/). By default, all queries with a SQLCommenter with a sampled flag enabled will generate spans. @@ -84,6 +100,32 @@ select trace_id, parent_id, span_id, span_start, span_end, span_type, span_opera 00000000000000000000000000000123 | 4268a4281c5316dd | f5994f9159d8e80d | 2024-03-19 13:46:43.980081+00 | 2024-03-19 13:46:43.980111+00 | Executor | ExecutorRun ``` +### `trace_context` GUC + +The GUC variable `pg_tracing.trace_context` can also be used to propagate trace context. + +```sql +BEGIN; +SET LOCAL pg_tracing.trace_context='traceparent=''00-00000000000000000000000000000005-0000000000000005-01'''; +UPDATE pgbench_accounts SET abalance=1 where aid=1; +COMMIT; + +-- Check generated span +select trace_id, span_start, span_end, span_type, span_operation from pg_tracing_consume_spans order by span_start; + trace_id | span_start | span_end | span_type | span_operation +----------------------------------+-------------------------------+-------------------------------+-------------------+----------------------------------------------------------- + 00000000000000000000000000000005 | 2024-07-05 14:24:55.305234+00 | 2024-07-05 14:24:55.305988+00 | Update query | UPDATE pgbench_accounts SET abalance=$1 where aid=$2; + 00000000000000000000000000000005 | 2024-07-05 14:24:55.305266+00 | 2024-07-05 14:24:55.30552+00 | Planner | Planner + 00000000000000000000000000000005 | 2024-07-05 14:24:55.305586+00 | 2024-07-05 14:24:55.305906+00 | ExecutorRun | ExecutorRun + 00000000000000000000000000000005 | 2024-07-05 14:24:55.305591+00 | 2024-07-05 14:24:55.305903+00 | Update | Update on pgbench_accounts + 00000000000000000000000000000005 | 2024-07-05 14:24:55.305593+00 | 2024-07-05 14:24:55.305806+00 | IndexScan | IndexScan using pgbench_accounts_pkey on pgbench_accounts + 00000000000000000000000000000005 | 2024-07-05 14:24:55.649757+00 | 2024-07-05 14:24:55.649792+00 | Utility query | COMMIT; + 00000000000000000000000000000005 | 2024-07-05 14:24:55.649787+00 | 2024-07-05 14:24:55.649792+00 | ProcessUtility | ProcessUtility + 00000000000000000000000000000005 | 2024-07-05 14:24:55.649816+00 | 2024-07-05 14:24:55.650613+00 | TransactionCommit | TransactionCommit +``` + +### Standalone Sampling + Queries can also be sampled randomly through the `pg_tracing.sample_rate` parameter. Setting this to 1 will trace all queries. ```sql @@ -102,6 +144,14 @@ select trace_id, parent_id, span_id, span_start, span_end, span_type, span_opera 458fbefd7034e670eb3d9c930862c378 | bdecb6e35d429f3d | 8805f7749249536b | 2024-01-10 09:54:16.321485+00 | 2024-01-10 09:54:16.321529+00 | Executor | ExecutorRun ``` -## Authors +## Sending Spans + +Spans can be automatically sent to an otel collector by setting `pg_tracing.otel_endpoint` parameter: + +``` +# postgresql.conf +pg_tracing.otel_endpoint = http://127.0.0.1:4318/v1/traces +pg_tracing.otel_naptime = 2000 +``` -* [Anthonin Bonnefoy](https://github.com/bonnefoa) +If an otel endpoint is defined, a background worker will be started and will send spans every $naptime using OTLP HTTP/JSON. diff --git a/doc/pg_tracing.md b/doc/pg_tracing.md index b89c0c8..2b69e60 100644 --- a/doc/pg_tracing.md +++ b/doc/pg_tracing.md @@ -10,12 +10,18 @@ pg_tracing extension allows to generate spans from with a PostgreSQL instance, p ## Tracecontext Propagation -A query with SQLcommenter can propagate a trace context to the database. It will have the following format: +SQLcommenter or `pg_tracing.trace_context` can be used to propagate a trace context to the database. It will have the following format: ```sql /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000009-0000000000000005-01'*/ select 1; -- SQLCommenter may be added to the end select 1 /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000009-0000000000000005-01'*/ + +-- Propagation through trace_context GUC +BEGIN; +SET LOCAL pg_tracing.trace_context='traceparent=''00-00000000000000000000000000000005-0000000000000005-01'''; +UPDATE pgbench_accounts SET abalance=1 where aid=1; +COMMIT; ``` The traceparent fields are detailed in [w3c's trace-context](https://www.w3.org/TR/trace-context/#traceparent-header-field-values) @@ -26,13 +32,13 @@ The traceparent fields are detailed in [w3c's trace-context](https://www.w3.org/ 01: trace flags (01 == sampled) ``` -When a query with SQLCommenter is detected, the trace context is extracted and used by pg_tracing. +When a query with a trace context is detected, it is extracted and used by pg_tracing. ## Sampling Spans will only be generated for sampled queries. A query is sampled if: -- It has a trace context propagated through SQLCommenter with the sampled flag enabled and it passes the `pg_tracing.caller_sample_rate` -- It has no SQLCommenter but the query randomly passes the global `pg_tracing.sample_rate` +- It has a trace context with the sampled flag enabled and it passes the `pg_tracing.caller_sample_rate` +- It has no trace context but the query randomly passes the global `pg_tracing.sample_rate` With the default values `pg_tracing.caller_sample_rate = 1` and `pg_tracing.sample_rate = 0`, only queries with a trace context and a sampled flag `sampled := 01` will be sampled, effectively offloading sampling decision to the callers. @@ -84,7 +90,7 @@ The spans generated by the module are made available via a view named `pg_tracin | `jit_inlining_time` | double precision | Total time spent by the node on inlining functions, in milliseconds | | `jit_optimization_time` | double precision | Total time spent by the node on optimizing, in milliseconds | | `startup` | bigint | Time to the first tuple in nanoseconds | -| `parameters` | text | Value of the query's parameters | +| `parameters` | text[] | Value of the query's parameters | | `deparse_info` | text | Information extracted from deparsing a plan node | ## Functions @@ -95,14 +101,15 @@ The statistics of the pg_tracing extension itself are tracked and made available | Column | Type | Description | | --- | --- | --- -| `traces` | bigint | Total number of traces captured | -| `spans` | bigint | Total number of spans captured | +| `processed_traces` | bigint | Total number of traces processed | +| `processed_spans` | bigint | Total number of spans processed | +| `dropped_traces` | bigint | Total number of traces dropped due to exceeding `pg_tracing.max_span` spans | | `dropped_spans` | bigint | Total number of spans dropped due to exceeding `pg_tracing.max_span` spans | -| `failed_truncates` | bigint | Total number of times the module couldn't truncate the query file due to conflict lock on pg_tracing's text file | +| `otel_sent_spans` | bigint | Total number of spans dropped successfully sent to the otel collector | +| `otel_failures` | bigint | Total number of failures to send spans to the otel collector | | `last_consume` | timestamp with time zone | Time at which spans were last consumed | | `stats_reset` | timestamp with time zone | Time at which all statistics in the `pg_tracing_info` view were last reset | - ### pg_tracing_reset() Discards all statistics gathered so far by `pg_tracing`. Span buffer is not emptied by this function. By default, this function can only be executed by superusers. Access may be granted to others using `GRANT`. diff --git a/expected/guc.out b/expected/guc.out index b364c96..93e24bb 100644 --- a/expected/guc.out +++ b/expected/guc.out @@ -1,13 +1,23 @@ -- Test trace context propagation through GUCs -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000004-0000000000000004-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000004-0000000000000004-01'''; SELECT 1; ?column? ---------- 1 (1 row) +-- Test trace context propagation through a local GUCs +BEGIN; +SET LOCAL pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000005-0000000000000005-01'''; +SELECT 1; + ?column? +---------- + 1 +(1 row) + +COMMIT; -- Test multiple statements -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'''; SELECT 2; ?column? ---------- @@ -28,6 +38,12 @@ select trace_id, span_operation, parameters, lvl from peek_ordered_spans; 00000000000000000000000000000004 | Planner | | 2 00000000000000000000000000000004 | ExecutorRun | | 2 00000000000000000000000000000004 | Result | | 3 + 00000000000000000000000000000005 | SELECT $1; | {1} | 1 + 00000000000000000000000000000005 | Planner | | 2 + 00000000000000000000000000000005 | ExecutorRun | | 2 + 00000000000000000000000000000005 | Result | | 3 + 00000000000000000000000000000005 | COMMIT; | | 1 + 00000000000000000000000000000005 | ProcessUtility | | 2 fffffffffffffffffffffffffffffff5 | SELECT $1; | {2} | 1 fffffffffffffffffffffffffffffff5 | Planner | | 2 fffffffffffffffffffffffffffffff5 | ExecutorRun | | 2 @@ -36,11 +52,11 @@ select trace_id, span_operation, parameters, lvl from peek_ordered_spans; fffffffffffffffffffffffffffffff5 | Planner | | 2 fffffffffffffffffffffffffffffff5 | ExecutorRun | | 2 fffffffffffffffffffffffffffffff5 | Result | | 3 -(12 rows) +(18 rows) CALL clean_spans(); -- Mix SQLCommenter and GUC propagation -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'''; SELECT 2; ?column? ---------- @@ -97,17 +113,21 @@ SELECT 4; (1 row) -- Test no traceparent field -SET pg_tracing.trace_context='dddbs=''postgres.db'',taceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'; -ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',taceparent='00-fffffffffffffffffffffffffffffff5-0000000000000005-01" +SET pg_tracing.trace_context='dddbs=''postgres.db'',taceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'''; +ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',taceparent='00-fffffffffffffffffffffffffffffff5-0000000000000005-01'" DETAIL: Error parsing tracecontext: No traceparent field found -- Test incorrect trace id -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-ffffffffffffffffffffffffffffff5-0000000000000005-01'; -ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',traceparent='00-ffffffffffffffffffffffffffffff5-0000000000000005-01" +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-ffffffffffffffffffffffffffffff5-0000000000000005-01'''; +ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',traceparent='00-ffffffffffffffffffffffffffffff5-0000000000000005-01'" DETAIL: Error parsing tracecontext: Traceparent field doesn't have the correct size -- Test wrong format -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00f-ffffffffffffffffffffffffffffff5-0000000000000005-01'; -ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',traceparent='00f-ffffffffffffffffffffffffffffff5-0000000000000005-01" +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00f-ffffffffffffffffffffffffffffff5-0000000000000005-01'''; +ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',traceparent='00f-ffffffffffffffffffffffffffffff5-0000000000000005-01'" DETAIL: Error parsing tracecontext: Incorrect traceparent format +-- Test missing end quote +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'; +ERROR: invalid value for parameter "pg_tracing.trace_context": "dddbs='postgres.db',traceparent='00-fffffffffffffffffffffffffffffff6-0000000000000006-01" +DETAIL: Error parsing tracecontext: Traceparent field doesn't have the correct size -- GUC errors and no GUC tracecontext should not generate spans select count(*) = 0 from peek_ordered_spans; ?column? diff --git a/expected/insert.out b/expected/insert.out index d55cf4f..0b3fa9b 100644 --- a/expected/insert.out +++ b/expected/insert.out @@ -3,26 +3,26 @@ SET pg_tracing.sample_rate = 0.0; SET pg_tracing.caller_sample_rate = 1.0; /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ CREATE TABLE IF NOT EXISTS pg_tracing_test_table_with_constraint (a int, b char(20), CONSTRAINT PK_tracing_test PRIMARY KEY (a)); SELECT span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; - span_type | span_operation | lvl -----------------+-----------------------------------------------------------------------------------------------------------------------------------+----- - Utility query | CREATE TABLE IF NOT EXISTS pg_tracing_test_table_with_constraint (a int, b char(20), CONSTRAINT PK_tracing_test PRIMARY KEY (a)); | 1 - ProcessUtility | ProcessUtility | 2 - Utility query | CREATE TABLE IF NOT EXISTS pg_tracing_test_table_with_constraint (a int, b char(20), CONSTRAINT PK_tracing_test PRIMARY KEY (a)); | 3 - ProcessUtility | ProcessUtility | 4 - Commit | Commit | 1 + span_type | span_operation | lvl +-------------------+-----------------------------------------------------------------------------------------------------------------------------------+----- + Utility query | CREATE TABLE IF NOT EXISTS pg_tracing_test_table_with_constraint (a int, b char(20), CONSTRAINT PK_tracing_test PRIMARY KEY (a)); | 1 + ProcessUtility | ProcessUtility | 2 + Utility query | CREATE TABLE IF NOT EXISTS pg_tracing_test_table_with_constraint (a int, b char(20), CONSTRAINT PK_tracing_test PRIMARY KEY (a)); | 3 + ProcessUtility | ProcessUtility | 4 + TransactionCommit | TransactionCommit | 1 (5 rows) -- Simple insertion /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ INSERT INTO pg_tracing_test_table_with_constraint VALUES(1, 'aaa'); SELECT span_type, span_operation from peek_ordered_spans where trace_id='00000000000000000000000000000002'; - span_type | span_operation ---------------+------------------------------------------------------------------- - Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2); - Planner | Planner - ExecutorRun | ExecutorRun - Insert | Insert on pg_tracing_test_table_with_constraint - Result | Result - Commit | Commit + span_type | span_operation +-------------------+------------------------------------------------------------------- + Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2); + Planner | Planner + ExecutorRun | ExecutorRun + Insert | Insert on pg_tracing_test_table_with_constraint + Result | Result + TransactionCommit | TransactionCommit (6 rows) -- Trigger constraint violation diff --git a/expected/nested.out b/expected/nested.out index a53c71c..f03e131 100644 --- a/expected/nested.out +++ b/expected/nested.out @@ -261,7 +261,7 @@ select span_operation, lvl FROM peek_ordered_spans where trace_id='0000000000000 ExecutorRun | 5 Insert on pg_tracing_test | 6 Result | 7 - Commit | 1 + TransactionCommit | 1 (10 rows) -- Make sure we have 2 query_id associated with the trace diff --git a/expected/planstate_subplans.out b/expected/planstate_subplans.out index 62bc8ea..b048e26 100644 --- a/expected/planstate_subplans.out +++ b/expected/planstate_subplans.out @@ -14,7 +14,7 @@ SELECT span_operation, deparse_info, parameters, lvl from peek_ordered_spans whe Planner | | | 2 ExecutorRun | | | 2 Merge on m | | | 3 - Commit | | | 1 + TransactionCommit | | | 1 (5 rows) -- +----------------------------------------------------------+ diff --git a/expected/select.out b/expected/select.out index 74fa54c..855e9a1 100644 --- a/expected/select.out +++ b/expected/select.out @@ -263,18 +263,18 @@ SELECT lazy_function('{1,2,3,4}'::int[]) FROM (VALUES (1,2)) as t; (4 rows) SELECT span_type, span_operation, parameters, lvl from peek_ordered_spans; - span_type | span_operation | parameters | lvl -----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+----- - Utility query | CREATE OR REPLACE FUNCTION lazy_function(IN anyarray, OUT x anyelement) RETURNS SETOF anyelement LANGUAGE sql AS 'select * from pg_catalog.generate_series(array_lower($1, 1), array_upper($1, 1), 1)'; | | 1 - ProcessUtility | ProcessUtility | | 2 - Commit | Commit | | 1 - Select query | SELECT lazy_function($1::int[]) FROM (VALUES ($2,$3)) as t; | {"'{1,2,3,4}'",1,2} | 1 - Planner | Planner | | 2 - ExecutorRun | ExecutorRun | | 2 - ProjectSet | ProjectSet | | 3 - Result | Result | | 4 - Select query | select * from pg_catalog.generate_series(array_lower($1, $2), array_upper($1, $3), $4) | {1,1,1} | 4 - Planner | Planner | | 5 + span_type | span_operation | parameters | lvl +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+----- + Utility query | CREATE OR REPLACE FUNCTION lazy_function(IN anyarray, OUT x anyelement) RETURNS SETOF anyelement LANGUAGE sql AS 'select * from pg_catalog.generate_series(array_lower($1, 1), array_upper($1, 1), 1)'; | | 1 + ProcessUtility | ProcessUtility | | 2 + TransactionCommit | TransactionCommit | | 1 + Select query | SELECT lazy_function($1::int[]) FROM (VALUES ($2,$3)) as t; | {"'{1,2,3,4}'",1,2} | 1 + Planner | Planner | | 2 + ExecutorRun | ExecutorRun | | 2 + ProjectSet | ProjectSet | | 3 + Result | Result | | 4 + Select query | select * from pg_catalog.generate_series(array_lower($1, $2), array_upper($1, $3), $4) | {1,1,1} | 4 + Planner | Planner | | 5 (10 rows) CALL clean_spans(); diff --git a/expected/subxact.out b/expected/subxact.out index c58def9..63da254 100644 --- a/expected/subxact.out +++ b/expected/subxact.out @@ -44,7 +44,7 @@ select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; Result | | 2 | 3 COMMIT; | | 2 | 1 ProcessUtility | | 2 | 2 - Commit | | 2 | 1 + TransactionCommit | | 2 | 1 (27 rows) -- Cleaning diff --git a/expected/trigger.out b/expected/trigger.out index aeef85e..d38e778 100644 --- a/expected/trigger.out +++ b/expected/trigger.out @@ -132,25 +132,25 @@ SELECT :span_o_start >= :span_i_end as second_trigger_starts_after_first, -- Check span_operation SELECT span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; - span_type | span_operation | lvl -----------------+---------------------------------------------------------------------------------------------------------------------+----- - Insert query | INSERT INTO Employee VALUES($1,$2); | 1 - Planner | Planner | 2 - ExecutorRun | ExecutorRun | 2 - Insert | Insert on employee | 3 - Result | Result | 4 - ExecutorFinish | ExecutorFinish | 2 - Insert query | INSERT INTO Employee_Audit (EmployeeId, LastName, EmpAdditionTime) VALUES(NEW.EmployeeId,NEW.LastName,current_date) | 3 - Planner | Planner | 4 - ExecutorRun | ExecutorRun | 4 - Insert | Insert on employee_audit | 5 - Result | Result | 6 - Insert query | INSERT INTO Employee_Audit (EmployeeId, LastName, EmpAdditionTime) VALUES(NEW.EmployeeId,NEW.LastName,current_date) | 3 - Planner | Planner | 4 - ExecutorRun | ExecutorRun | 4 - Insert | Insert on employee_audit | 5 - Result | Result | 6 - Commit | Commit | 1 + span_type | span_operation | lvl +-------------------+---------------------------------------------------------------------------------------------------------------------+----- + Insert query | INSERT INTO Employee VALUES($1,$2); | 1 + Planner | Planner | 2 + ExecutorRun | ExecutorRun | 2 + Insert | Insert on employee | 3 + Result | Result | 4 + ExecutorFinish | ExecutorFinish | 2 + Insert query | INSERT INTO Employee_Audit (EmployeeId, LastName, EmpAdditionTime) VALUES(NEW.EmployeeId,NEW.LastName,current_date) | 3 + Planner | Planner | 4 + ExecutorRun | ExecutorRun | 4 + Insert | Insert on employee_audit | 5 + Result | Result | 6 + Insert query | INSERT INTO Employee_Audit (EmployeeId, LastName, EmpAdditionTime) VALUES(NEW.EmployeeId,NEW.LastName,current_date) | 3 + Planner | Planner | 4 + ExecutorRun | ExecutorRun | 4 + Insert | Insert on employee_audit | 5 + Result | Result | 6 + TransactionCommit | TransactionCommit | 1 (17 rows) -- Check count of query_id @@ -181,62 +181,62 @@ CREATE TRIGGER employee_delete_trigger -- Call before trigger insert /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ INSERT INTO before_trigger_table SELECT generate_series(1,2); SELECT trace_id, span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; - trace_id | span_type | span_operation | lvl -----------------------------------+--------------+-----------------------------------------------------------------+----- - 00000000000000000000000000000001 | Insert query | INSERT INTO before_trigger_table SELECT generate_series($1,$2); | 1 - 00000000000000000000000000000001 | Planner | Planner | 2 - 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 2 - 00000000000000000000000000000001 | Insert | Insert on before_trigger_table | 3 - 00000000000000000000000000000001 | ProjectSet | ProjectSet | 4 - 00000000000000000000000000000001 | Result | Result | 5 - 00000000000000000000000000000001 | Select query | SELECT $1 | 5 - 00000000000000000000000000000001 | Planner | Planner | 6 - 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 6 - 00000000000000000000000000000001 | Result | Result | 7 - 00000000000000000000000000000001 | Select query | SELECT 'SELECT 1' | 5 - 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 6 - 00000000000000000000000000000001 | Result | Result | 7 - 00000000000000000000000000000001 | Commit | Commit | 1 + trace_id | span_type | span_operation | lvl +----------------------------------+-------------------+-----------------------------------------------------------------+----- + 00000000000000000000000000000001 | Insert query | INSERT INTO before_trigger_table SELECT generate_series($1,$2); | 1 + 00000000000000000000000000000001 | Planner | Planner | 2 + 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 2 + 00000000000000000000000000000001 | Insert | Insert on before_trigger_table | 3 + 00000000000000000000000000000001 | ProjectSet | ProjectSet | 4 + 00000000000000000000000000000001 | Result | Result | 5 + 00000000000000000000000000000001 | Select query | SELECT $1 | 5 + 00000000000000000000000000000001 | Planner | Planner | 6 + 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 6 + 00000000000000000000000000000001 | Result | Result | 7 + 00000000000000000000000000000001 | Select query | SELECT 'SELECT 1' | 5 + 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | 6 + 00000000000000000000000000000001 | Result | Result | 7 + 00000000000000000000000000000001 | TransactionCommit | TransactionCommit | 1 (14 rows) -- Call before trigger update /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ UPDATE before_trigger_table set a=1; SELECT trace_id, span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000002'; - trace_id | span_type | span_operation | lvl -----------------------------------+--------------+---------------------------------------+----- - 00000000000000000000000000000002 | Update query | UPDATE before_trigger_table set a=$1; | 1 - 00000000000000000000000000000002 | Planner | Planner | 2 - 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 2 - 00000000000000000000000000000002 | Update | Update on before_trigger_table | 3 - 00000000000000000000000000000002 | SeqScan | SeqScan on before_trigger_table | 4 - 00000000000000000000000000000002 | Select query | SELECT $1 | 3 - 00000000000000000000000000000002 | Planner | Planner | 4 - 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 4 - 00000000000000000000000000000002 | Result | Result | 5 - 00000000000000000000000000000002 | Select query | SELECT 'SELECT 1' | 3 - 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 4 - 00000000000000000000000000000002 | Result | Result | 5 - 00000000000000000000000000000002 | Commit | Commit | 1 + trace_id | span_type | span_operation | lvl +----------------------------------+-------------------+---------------------------------------+----- + 00000000000000000000000000000002 | Update query | UPDATE before_trigger_table set a=$1; | 1 + 00000000000000000000000000000002 | Planner | Planner | 2 + 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 2 + 00000000000000000000000000000002 | Update | Update on before_trigger_table | 3 + 00000000000000000000000000000002 | SeqScan | SeqScan on before_trigger_table | 4 + 00000000000000000000000000000002 | Select query | SELECT $1 | 3 + 00000000000000000000000000000002 | Planner | Planner | 4 + 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 4 + 00000000000000000000000000000002 | Result | Result | 5 + 00000000000000000000000000000002 | Select query | SELECT 'SELECT 1' | 3 + 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | 4 + 00000000000000000000000000000002 | Result | Result | 5 + 00000000000000000000000000000002 | TransactionCommit | TransactionCommit | 1 (13 rows) -- Call before trigger delete /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000003-01'*/ DELETE FROM before_trigger_table where a=1; SELECT trace_id, span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000003'; - trace_id | span_type | span_operation | lvl -----------------------------------+--------------+----------------------------------------------+----- - 00000000000000000000000000000003 | Delete query | DELETE FROM before_trigger_table where a=$1; | 1 - 00000000000000000000000000000003 | Planner | Planner | 2 - 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 2 - 00000000000000000000000000000003 | Delete | Delete on before_trigger_table | 3 - 00000000000000000000000000000003 | SeqScan | SeqScan on before_trigger_table | 4 - 00000000000000000000000000000003 | Select query | SELECT $1 | 3 - 00000000000000000000000000000003 | Planner | Planner | 4 - 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 4 - 00000000000000000000000000000003 | Result | Result | 5 - 00000000000000000000000000000003 | Select query | SELECT 'SELECT 1' | 3 - 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 4 - 00000000000000000000000000000003 | Result | Result | 5 - 00000000000000000000000000000003 | Commit | Commit | 1 + trace_id | span_type | span_operation | lvl +----------------------------------+-------------------+----------------------------------------------+----- + 00000000000000000000000000000003 | Delete query | DELETE FROM before_trigger_table where a=$1; | 1 + 00000000000000000000000000000003 | Planner | Planner | 2 + 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 2 + 00000000000000000000000000000003 | Delete | Delete on before_trigger_table | 3 + 00000000000000000000000000000003 | SeqScan | SeqScan on before_trigger_table | 4 + 00000000000000000000000000000003 | Select query | SELECT $1 | 3 + 00000000000000000000000000000003 | Planner | Planner | 4 + 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 4 + 00000000000000000000000000000003 | Result | Result | 5 + 00000000000000000000000000000003 | Select query | SELECT 'SELECT 1' | 3 + 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | 4 + 00000000000000000000000000000003 | Result | Result | 5 + 00000000000000000000000000000003 | TransactionCommit | TransactionCommit | 1 (13 rows) -- Check count of query_id diff --git a/expected/utility.out b/expected/utility.out index e044862..4de7b34 100644 --- a/expected/utility.out +++ b/expected/utility.out @@ -296,7 +296,7 @@ select trace_id, span_operation, parameters, lvl from peek_ordered_spans WHERE t 00000000000000000000000000000001 | ExecutorRun | | 4 00000000000000000000000000000001 | Insert on pg_tracing_test | | 5 00000000000000000000000000000001 | Result | | 6 - 00000000000000000000000000000001 | Commit | | 1 + 00000000000000000000000000000001 | TransactionCommit | | 1 (8 rows) -- We should have only two query_ids @@ -310,8 +310,7 @@ SELECT query_id from pg_tracing_peek_spans where trace_id='000000000000000000000 SELECT query_id = :query_id from pg_tracing_peek_spans where trace_id='00000000000000000000000000000001' AND span_operation = 'Commit'; ?column? ---------- - t -(1 row) +(0 rows) CALL clean_spans(); -- Test prepared statement with generic plan @@ -369,21 +368,21 @@ select span_operation, parameters, sql_error_code, lvl from peek_ordered_spans w /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ CREATE TABLE test_create_table (a int, b char(20)); -- Check create table spans select trace_id, span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000002'; - trace_id | span_type | span_operation | lvl -----------------------------------+----------------+-----------------------------------------------------+----- - 00000000000000000000000000000002 | Utility query | CREATE TABLE test_create_table (a int, b char(20)); | 1 - 00000000000000000000000000000002 | ProcessUtility | ProcessUtility | 2 - 00000000000000000000000000000002 | Commit | Commit | 1 + trace_id | span_type | span_operation | lvl +----------------------------------+-------------------+-----------------------------------------------------+----- + 00000000000000000000000000000002 | Utility query | CREATE TABLE test_create_table (a int, b char(20)); | 1 + 00000000000000000000000000000002 | ProcessUtility | ProcessUtility | 2 + 00000000000000000000000000000002 | TransactionCommit | TransactionCommit | 1 (3 rows) /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000003-01'*/ CREATE INDEX test_create_table_index ON test_create_table (a); -- Check create index spans select trace_id, span_type, span_operation, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000003'; - trace_id | span_type | span_operation | lvl -----------------------------------+----------------+----------------------------------------------------------------+----- - 00000000000000000000000000000003 | Utility query | CREATE INDEX test_create_table_index ON test_create_table (a); | 1 - 00000000000000000000000000000003 | ProcessUtility | ProcessUtility | 2 - 00000000000000000000000000000003 | Commit | Commit | 1 + trace_id | span_type | span_operation | lvl +----------------------------------+-------------------+----------------------------------------------------------------+----- + 00000000000000000000000000000003 | Utility query | CREATE INDEX test_create_table_index ON test_create_table (a); | 1 + 00000000000000000000000000000003 | ProcessUtility | ProcessUtility | 2 + 00000000000000000000000000000003 | TransactionCommit | TransactionCommit | 1 (3 rows) CREATE OR REPLACE FUNCTION function_with_error(IN anyarray, OUT x anyelement, OUT n int) @@ -417,21 +416,21 @@ select trace_id, span_type, span_operation, sql_error_code, lvl from peek_ordere /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000006-0000000000000006-01'*/ DROP TABLE test_create_table; select trace_id, span_type, span_operation, sql_error_code, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000006'; - trace_id | span_type | span_operation | sql_error_code | lvl -----------------------------------+----------------+-------------------------------+----------------+----- - 00000000000000000000000000000006 | Utility query | DROP TABLE test_create_table; | 00000 | 1 - 00000000000000000000000000000006 | ProcessUtility | ProcessUtility | 00000 | 2 - 00000000000000000000000000000006 | Commit | Commit | 00000 | 1 + trace_id | span_type | span_operation | sql_error_code | lvl +----------------------------------+-------------------+-------------------------------+----------------+----- + 00000000000000000000000000000006 | Utility query | DROP TABLE test_create_table; | 00000 | 1 + 00000000000000000000000000000006 | ProcessUtility | ProcessUtility | 00000 | 2 + 00000000000000000000000000000006 | TransactionCommit | TransactionCommit | 00000 | 1 (3 rows) -- Check VACUUM ANALYZE call /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000007-0000000000000007-01'*/ VACUUM ANALYZE pg_tracing_test; select trace_id, span_type, span_operation, sql_error_code, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000007'; - trace_id | span_type | span_operation | sql_error_code | lvl -----------------------------------+----------------+---------------------------------+----------------+----- - 00000000000000000000000000000007 | Utility query | VACUUM ANALYZE pg_tracing_test; | 00000 | 1 - 00000000000000000000000000000007 | ProcessUtility | ProcessUtility | 00000 | 2 - 00000000000000000000000000000007 | Commit | Commit | 00000 | 1 + trace_id | span_type | span_operation | sql_error_code | lvl +----------------------------------+-------------------+---------------------------------+----------------+----- + 00000000000000000000000000000007 | Utility query | VACUUM ANALYZE pg_tracing_test; | 00000 | 1 + 00000000000000000000000000000007 | ProcessUtility | ProcessUtility | 00000 | 2 + 00000000000000000000000000000007 | TransactionCommit | TransactionCommit | 00000 | 1 (3 rows) -- Cleanup diff --git a/expected/wal.out b/expected/wal.out index cb22697..9d8730b 100644 --- a/expected/wal.out +++ b/expected/wal.out @@ -7,27 +7,27 @@ SELECT trace_id, span_type, span_operation, wal_records > 0 as wal_records, wal_bytes > 0 as wal_bytes FROM peek_ordered_spans; - trace_id | span_type | span_operation | wal_records | wal_bytes -----------------------------------+--------------+------------------------------------------------------------------+-------------+----------- - 00000000000000000000000000000001 | Insert query | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | t | t - 00000000000000000000000000000001 | Planner | Planner | f | f - 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | | - 00000000000000000000000000000001 | Insert | Insert on pg_tracing_test | t | t - 00000000000000000000000000000001 | ProjectSet | ProjectSet | f | f - 00000000000000000000000000000001 | Result | Result | f | f - 00000000000000000000000000000001 | Commit | Commit | | - 00000000000000000000000000000002 | Update query | UPDATE pg_tracing_test SET b = $1 WHERE a = $2; | t | t - 00000000000000000000000000000002 | Planner | Planner | f | f - 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | | - 00000000000000000000000000000002 | Update | Update on pg_tracing_test | t | t - 00000000000000000000000000000002 | IndexScan | IndexScan using pg_tracing_index on pg_tracing_test | f | f - 00000000000000000000000000000002 | Commit | Commit | | - 00000000000000000000000000000003 | Delete query | DELETE FROM pg_tracing_test WHERE a = $1; | t | t - 00000000000000000000000000000003 | Planner | Planner | f | f - 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | | - 00000000000000000000000000000003 | Delete | Delete on pg_tracing_test | t | t - 00000000000000000000000000000003 | IndexScan | IndexScan using pg_tracing_index on pg_tracing_test | t | t - 00000000000000000000000000000003 | Commit | Commit | | + trace_id | span_type | span_operation | wal_records | wal_bytes +----------------------------------+-------------------+------------------------------------------------------------------+-------------+----------- + 00000000000000000000000000000001 | Insert query | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | t | t + 00000000000000000000000000000001 | Planner | Planner | f | f + 00000000000000000000000000000001 | ExecutorRun | ExecutorRun | | + 00000000000000000000000000000001 | Insert | Insert on pg_tracing_test | t | t + 00000000000000000000000000000001 | ProjectSet | ProjectSet | f | f + 00000000000000000000000000000001 | Result | Result | f | f + 00000000000000000000000000000001 | TransactionCommit | TransactionCommit | | + 00000000000000000000000000000002 | Update query | UPDATE pg_tracing_test SET b = $1 WHERE a = $2; | t | t + 00000000000000000000000000000002 | Planner | Planner | f | f + 00000000000000000000000000000002 | ExecutorRun | ExecutorRun | | + 00000000000000000000000000000002 | Update | Update on pg_tracing_test | t | t + 00000000000000000000000000000002 | IndexScan | IndexScan using pg_tracing_index on pg_tracing_test | f | f + 00000000000000000000000000000002 | TransactionCommit | TransactionCommit | | + 00000000000000000000000000000003 | Delete query | DELETE FROM pg_tracing_test WHERE a = $1; | t | t + 00000000000000000000000000000003 | Planner | Planner | f | f + 00000000000000000000000000000003 | ExecutorRun | ExecutorRun | | + 00000000000000000000000000000003 | Delete | Delete on pg_tracing_test | t | t + 00000000000000000000000000000003 | IndexScan | IndexScan using pg_tracing_index on pg_tracing_test | t | t + 00000000000000000000000000000003 | TransactionCommit | TransactionCommit | | (19 rows) CALL clean_spans(); diff --git a/sql/guc.sql b/sql/guc.sql index d134418..2de86dd 100644 --- a/sql/guc.sql +++ b/sql/guc.sql @@ -1,9 +1,15 @@ -- Test trace context propagation through GUCs -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000004-0000000000000004-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000004-0000000000000004-01'''; SELECT 1; +-- Test trace context propagation through a local GUCs +BEGIN; +SET LOCAL pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-00000000000000000000000000000005-0000000000000005-01'''; +SELECT 1; +COMMIT; + -- Test multiple statements -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'''; SELECT 2; SELECT 3; @@ -12,7 +18,7 @@ select trace_id, span_operation, parameters, lvl from peek_ordered_spans; CALL clean_spans(); -- Mix SQLCommenter and GUC propagation -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'''; SELECT 2; /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ SELECT 1, 1; /*dddbs='postgres.db',traceparent='00-00000000000000000000000000000009-0000000000000009-00'*/ SELECT 1, 2, 3; @@ -27,11 +33,13 @@ SET pg_tracing.trace_context TO default; SELECT 4; -- Test no traceparent field -SET pg_tracing.trace_context='dddbs=''postgres.db'',taceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',taceparent=''00-fffffffffffffffffffffffffffffff5-0000000000000005-01'''; -- Test incorrect trace id -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-ffffffffffffffffffffffffffffff5-0000000000000005-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-ffffffffffffffffffffffffffffff5-0000000000000005-01'''; -- Test wrong format -SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00f-ffffffffffffffffffffffffffffff5-0000000000000005-01'; +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00f-ffffffffffffffffffffffffffffff5-0000000000000005-01'''; +-- Test missing end quote +SET pg_tracing.trace_context='dddbs=''postgres.db'',traceparent=''00-fffffffffffffffffffffffffffffff6-0000000000000006-01'; -- GUC errors and no GUC tracecontext should not generate spans select count(*) = 0 from peek_ordered_spans; diff --git a/src/pg_tracing.c b/src/pg_tracing.c index a8badc7..9a1d455 100644 --- a/src/pg_tracing.c +++ b/src/pg_tracing.c @@ -2025,7 +2025,7 @@ pg_tracing_xact_callback(XactEvent event, void *arg) TimestampTz start_time = GetCurrentTimestamp(); begin_span(traceparent->trace_id, &commit_span, - SPAN_COMMIT, NULL, traceparent->parent_id, + SPAN_TRANSACTION_COMMIT, NULL, traceparent->parent_id, current_query_id, start_time); } break; diff --git a/src/pg_tracing.h b/src/pg_tracing.h index 5c81459..2250256 100644 --- a/src/pg_tracing.h +++ b/src/pg_tracing.h @@ -78,7 +78,7 @@ typedef enum SpanType SPAN_EXECUTOR_RUN, /* Wraps Executor run hook */ SPAN_EXECUTOR_FINISH, /* Wraps Executor finish hook */ - SPAN_COMMIT, /* Wraps time between pre-commit and commit */ + SPAN_TRANSACTION_COMMIT, /* Wraps time between pre-commit and commit */ /* Represents a node execution, generated from planstate */ SPAN_NODE, diff --git a/src/pg_tracing_query_process.c b/src/pg_tracing_query_process.c index 8847c47..fe8b0f2 100644 --- a/src/pg_tracing_query_process.c +++ b/src/pg_tracing_query_process.c @@ -91,7 +91,8 @@ parse_traceparent_value(Traceparent * traceparent, const char *traceparent_str) /* Check that '-' are at the expected places */ if (traceparent_str[2] != '-' || traceparent_str[35] != '-' || - traceparent_str[52] != '-') + traceparent_str[52] != '-' || + traceparent_str[55] != '\'') return PARSE_INCORRECT_FORMAT; /* Parse traceparent parameters */ @@ -175,16 +176,16 @@ parse_trace_context(Traceparent * traceparent, const char *trace_context_str, /* * Locate traceparent parameter and make sure it has the expected size - * "traceparent" + "=" + '' -> 13 characters - * 00-00000000000000000000000000000009-0000000000000005-01 -> 55 - * characters + * "traceparent" + "=" + ' -> 13 characters + * 00-00000000000000000000000000000009-0000000000000005-01 -> 55 ' -> 1 + * character characters */ traceparent_str = strstr(trace_context_str, "traceparent='"); if (traceparent_str == NULL) return PARSE_NO_TRACEPARENT_FIELD; if (traceparent_str > end_trace_context || - end_trace_context - traceparent_str < 55 + 13) + end_trace_context - traceparent_str < 55 + 13 + 1) return PARSE_INCORRECT_TRACEPARENT_SIZE; /* Move to the start of the traceparent values */ diff --git a/src/pg_tracing_span.c b/src/pg_tracing_span.c index 55b3c4a..a5a387e 100644 --- a/src/pg_tracing_span.c +++ b/src/pg_tracing_span.c @@ -131,8 +131,8 @@ span_type_to_str(SpanType span_type) return "ExecutorRun"; case SPAN_EXECUTOR_FINISH: return "ExecutorFinish"; - case SPAN_COMMIT: - return "Commit"; + case SPAN_TRANSACTION_COMMIT: + return "TransactionCommit"; case SPAN_NODE: return "Node";