44
55namespace  OpenTelemetry \Contrib \Instrumentation \PostgreSql ;
66
7- use  PgSql \Connection ;
87use  OpenTelemetry \API \Behavior \LogsMessagesTrait ;
98use  OpenTelemetry \API \Instrumentation \CachedInstrumentation ;
109use  OpenTelemetry \API \Trace \Span ;
1110use  OpenTelemetry \API \Trace \SpanInterface ;
1211use  OpenTelemetry \API \Trace \SpanKind ;
1312use  OpenTelemetry \API \Trace \StatusCode ;
14- 
1513use  OpenTelemetry \Context \Context ;
16- use   PgSql \ Lob ; 
14+ 
1715use  function  OpenTelemetry \Instrumentation \hook ;
1816use  OpenTelemetry \SemConv \TraceAttributes ;
1917use  OpenTelemetry \SemConv \Version ;
18+ use  PgSql \Connection ;
19+ use  PgSql \Lob ;
2020
2121/** 
2222 * @phan-file-suppress PhanParamTooFewUnpack 
@@ -69,8 +69,6 @@ public static function register(): void
6969            }
7070        );
7171
72- 
73- 
7472        hook (
7573            null ,
7674            'pg_copy_from ' ,
@@ -122,7 +120,7 @@ public static function register(): void
122120                self ::basicPreHook ('pg_execute ' , $ instrumentation$ tracker$ args
123121            },
124122            post: static  function  (...$ argsuse  ($ instrumentation$ tracker
125-                 self ::executePostHook ($ instrumentation$ trackerfalse ,   ...$ args
123+                 self ::executePostHook ($ instrumentation$ trackerfalse , ...$ args
126124            }
127125        );
128126
@@ -137,7 +135,6 @@ public static function register(): void
137135            }
138136        );
139137
140- 
141138        hook (
142139            null ,
143140            'pg_select ' ,
@@ -156,7 +153,7 @@ public static function register(): void
156153                self ::basicPreHook ('pg_send_prepare ' , $ instrumentation$ tracker$ args
157154            },
158155            post: static  function  (...$ argsuse  ($ instrumentation$ tracker
159-                 self ::preparePostHook ($ instrumentation$ trackertrue ,   ...$ args
156+                 self ::preparePostHook ($ instrumentation$ trackertrue , ...$ args
160157            }
161158        );
162159
@@ -167,7 +164,7 @@ public static function register(): void
167164                self ::basicPreHook ('pg_send_execute ' , $ instrumentation$ tracker$ args
168165            },
169166            post: static  function  (...$ argsuse  ($ instrumentation$ tracker
170-                 self ::executePostHook ($ instrumentation$ trackertrue ,   ...$ args
167+                 self ::executePostHook ($ instrumentation$ trackertrue , ...$ args
171168            }
172169        );
173170        hook (
@@ -292,7 +289,7 @@ private static function connectPostHook(CachedInstrumentation $instrumentation,
292289        if  ($ retValinstanceof  Connection) {
293290            $ trackerstoreConnectionAttributes ($ retVal$ params0 ]);
294291        }
295-         self ::endSpan ([], $ exception$ retValfalse  ? " Connection error " null );
292+         self ::endSpan ([], $ exception$ retValfalse  ? ' Connection error ' null );
296293    }
297294
298295    /** @param non-empty-string $spanName */ 
@@ -301,16 +298,6 @@ private static function basicPreHook(string $spanName, CachedInstrumentation $in
301298        self ::startSpan ($ spanName$ instrumentation$ class$ function$ filename$ lineno
302299    }
303300
304-     private  static  function  basicPostHook (CachedInstrumentation $ instrumentationPgSqlTracker $ trackerarray  $ attributesbool  $ dropIfNoError$ objarray  $ paramsmixed  $ retVal\Throwable   $ exception
305-     {
306-         $ errorStatus$ retValfalse  ? pg_last_error ($ params0 ]) : null ;
307-         if  ($ dropIfNoError$ errorStatusnull  && $ exceptionnull ) {
308-             self ::dropSpan ();
309-             return ;
310-         }
311-         self ::endSpan ($ attributes$ exception$ errorStatus
312-     }
313- 
314301    private  static  function  tableOperationsPostHook (CachedInstrumentation $ instrumentationPgSqlTracker $ trackerbool  $ dropIfNoErrorstring  $ operationName$ objarray  $ paramsmixed  $ retVal\Throwable   $ exception
315302    {
316303        $ connection$ params0 ];
@@ -326,6 +313,7 @@ private static function tableOperationsPostHook(CachedInstrumentation $instrumen
326313        $ errorStatus$ retValfalse  ? pg_last_error ($ params0 ]) : null ;
327314        if  ($ dropIfNoError$ errorStatusnull  && $ exceptionnull ) {
328315            self ::dropSpan ();
316+ 
329317            return ;
330318        }
331319        self ::endSpan ($ attributes$ exception$ errorStatus
@@ -352,7 +340,6 @@ private static function preparePostHook(CachedInstrumentation $instrumentation,
352340        self ::endSpan ($ attributes$ exception$ errorStatus
353341    }
354342
355- 
356343    private  static  function  sendQueryParamsPostHook (CachedInstrumentation $ instrumentationPgSqlTracker $ tracker$ objarray  $ paramsmixed  $ retVal\Throwable   $ exception
357344    {
358345        $ attributes$ trackergetConnectionAttributes ($ params0 ]);
@@ -453,7 +440,7 @@ private static function selectPostHook(CachedInstrumentation $instrumentation, P
453440                }
454441            } else  {
455442                $ whereimplode (' AND  ' , array_map (
456-                     fn ( $ k$ vis_null ( $ v )  ? " $ k IS NULL " " $ k  = ' $ v' "
443+                     fn  ( string   $ k$ vnull  ===  $ v $ k.  '   IS NULL' $ k  .  "  = ' $ v' "
457444                    array_keys ($ conditions
458445                    $ conditions
459446                ));
@@ -545,7 +532,6 @@ private static function loUnlinkPostHook(CachedInstrumentation $instrumentation,
545532        self ::endSpan ($ attributes$ exception$ errorStatus
546533    }
547534
548- 
549535    private  static  function  loImportExportPostHook (CachedInstrumentation $ instrumentationPgSqlTracker $ trackerstring  $ operation$ objarray  $ paramsmixed  $ retVal\Throwable   $ exception
550536    {
551537        $ attributes$ trackergetConnectionAttributes ($ params0 ]);
@@ -626,5 +612,4 @@ private static function extractQueryCommand($query) : ?string
626612        return  null ;
627613    }
628614
629- 
630615}
0 commit comments