12
12
use OpenTelemetry \Context \Context ;
13
13
use function OpenTelemetry \Instrumentation \hook ;
14
14
use OpenTelemetry \SDK \Common \Configuration \Configuration ;
15
- use OpenTelemetry \SemConv \TraceAttributes ;
15
+ use OpenTelemetry \SemConv \Attributes \CodeAttributes ;
16
+ use OpenTelemetry \SemConv \Attributes \DbAttributes ;
16
17
use OpenTelemetry \SemConv \Version ;
17
18
use PDO ;
18
19
use PDOStatement ;
@@ -27,7 +28,7 @@ public static function register(): void
27
28
$ instrumentation = new CachedInstrumentation (
28
29
'io.opentelemetry.contrib.php.pdo ' ,
29
30
null ,
30
- Version::VERSION_1_32_0 ->url (),
31
+ Version::VERSION_1_36_0 ->url (),
31
32
);
32
33
$ pdoTracker = new PDOTracker ();
33
34
@@ -112,7 +113,7 @@ public static function register(): void
112
113
$ builder = self ::makeBuilder ($ instrumentation , 'PDO::query ' , $ function , $ class , $ filename , $ lineno )
113
114
->setSpanKind (SpanKind::KIND_CLIENT );
114
115
if ($ class === PDO ::class) {
115
- $ builder ->setAttribute (TraceAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
116
+ $ builder ->setAttribute (DbAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
116
117
}
117
118
$ parent = Context::getCurrent ();
118
119
$ span = $ builder ->startSpan ();
@@ -135,7 +136,7 @@ public static function register(): void
135
136
$ builder = self ::makeBuilder ($ instrumentation , 'PDO::exec ' , $ function , $ class , $ filename , $ lineno )
136
137
->setSpanKind (SpanKind::KIND_CLIENT );
137
138
if ($ class === PDO ::class) {
138
- $ builder ->setAttribute (TraceAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
139
+ $ builder ->setAttribute (DbAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
139
140
}
140
141
$ parent = Context::getCurrent ();
141
142
$ span = $ builder ->startSpan ();
@@ -158,7 +159,7 @@ public static function register(): void
158
159
$ builder = self ::makeBuilder ($ instrumentation , 'PDO::prepare ' , $ function , $ class , $ filename , $ lineno )
159
160
->setSpanKind (SpanKind::KIND_CLIENT );
160
161
if ($ class === PDO ::class) {
161
- $ builder ->setAttribute (TraceAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
162
+ $ builder ->setAttribute (DbAttributes ::DB_QUERY_TEXT , mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' ));
162
163
}
163
164
$ parent = Context::getCurrent ();
164
165
$ span = $ builder ->startSpan ();
@@ -244,7 +245,7 @@ public static function register(): void
244
245
$ attributes = $ pdoTracker ->trackedAttributesForStatement ($ statement );
245
246
if (self ::isDistributeStatementToLinkedSpansEnabled ()) {
246
247
/** @psalm-suppress InvalidArrayAssignment */
247
- $ attributes [TraceAttributes ::DB_QUERY_TEXT ] = $ statement ->queryString ;
248
+ $ attributes [DbAttributes ::DB_QUERY_TEXT ] = $ statement ->queryString ;
248
249
}
249
250
/** @psalm-suppress ArgumentTypeCoercion */
250
251
$ builder = self ::makeBuilder ($ instrumentation , 'PDOStatement::fetchAll ' , $ function , $ class , $ filename , $ lineno )
@@ -271,7 +272,7 @@ public static function register(): void
271
272
272
273
if (self ::isDistributeStatementToLinkedSpansEnabled ()) {
273
274
/** @psalm-suppress InvalidArrayAssignment */
274
- $ attributes [TraceAttributes ::DB_QUERY_TEXT ] = $ statement ->queryString ;
275
+ $ attributes [DbAttributes ::DB_QUERY_TEXT ] = $ statement ->queryString ;
275
276
}
276
277
277
278
/** @psalm-suppress ArgumentTypeCoercion */
@@ -301,9 +302,9 @@ private static function makeBuilder(
301
302
/** @psalm-suppress ArgumentTypeCoercion */
302
303
return $ instrumentation ->tracer ()
303
304
->spanBuilder ($ name )
304
- ->setAttribute (TraceAttributes ::CODE_FUNCTION_NAME , sprintf ('%s::%s ' , $ class , $ function ))
305
- ->setAttribute (TraceAttributes ::CODE_FILE_PATH , $ filename )
306
- ->setAttribute (TraceAttributes ::CODE_LINE_NUMBER , $ lineno );
305
+ ->setAttribute (CodeAttributes ::CODE_FUNCTION_NAME , sprintf ('%s::%s ' , $ class , $ function ))
306
+ ->setAttribute (CodeAttributes ::CODE_FILE_PATH , $ filename )
307
+ ->setAttribute (CodeAttributes ::CODE_LINE_NUMBER , $ lineno );
307
308
}
308
309
private static function end (?Throwable $ exception ): void
309
310
{
0 commit comments