@@ -41,68 +41,67 @@ internal static Activity CommandStart(FbCommand command)
4141 }
4242
4343 var activity = Source . StartActivity ( activityName , ActivityKind . Client ) ;
44- if ( activity . IsAllDataRequested )
44+ if ( activity is not { IsAllDataRequested : true } )
45+ return activity ;
46+
47+ activity . SetTag ( "db.system" , "firebird" ) ;
48+
49+ if ( dbCollectionName != null )
4550 {
46- activity . SetTag ( "db.system" , "firebird" ) ;
51+ activity . SetTag ( "db.collection.name" , dbCollectionName ) ;
52+ }
4753
48- if ( dbCollectionName != null )
49- {
50- activity . SetTag ( "db.collection.name" , dbCollectionName ) ;
51- }
54+ // db.namespace
5255
53- // db.namespace
56+ if ( dbOperationName != null )
57+ {
58+ activity . SetTag ( "db.operation.name" , dbOperationName ) ;
59+ }
5460
55- if ( dbOperationName != null )
56- {
57- activity . SetTag ( "db.operation.name" , dbOperationName ) ;
58- }
61+ // db.response.status_code
5962
60- // db.response.status_code
63+ // error.type (handled by RecordException)
6164
62- // error.type (handled by RecordException)
65+ // server.port
6366
64- // server.port
67+ // db.operation.batch.size
6568
66- // db.operation.batch.size
69+ // db.query_summary
6770
68- // db.query_summary
71+ activity . SetTag ( " db.query.text" , command . CommandText ) ;
6972
70- activity . SetTag ( "db.query.text" , command . CommandText ) ;
73+ // network.peer.address
7174
72- // network.peer.address
75+ // network.peer.port
7376
74- // network.peer.port
77+ if ( command . Connection . DataSource != null )
78+ {
79+ activity . SetTag ( "server.address" , command . Connection . DataSource ) ;
80+ }
7581
76- if ( command . Connection . DataSource != null )
77- {
78- activity . SetTag ( "server.address" , command . Connection . DataSource ) ;
79- }
82+ foreach ( FbParameter p in command . Parameters )
83+ {
84+ var name = p . ParameterName ;
85+ var value = NormalizeDbNull ( p . InternalValue ) ;
86+ activity . SetTag ( $ "db.query.parameter.{ name } ", value ) ;
87+ }
8088
81- foreach ( FbParameter p in command . Parameters )
82- {
83- var name = p . ParameterName ;
84- var value = NormalizeDbNull ( p . InternalValue ) ;
85- activity . SetTag ( $ "db.query.parameter.{ name } ", value ) ;
89+ // Only for explicit transactions.
90+ if ( command . Transaction != null )
91+ {
92+ FbTransactionInfo fbInfo = new FbTransactionInfo ( command . Transaction ) ;
8693
87- }
94+ var transactionId = fbInfo . GetTransactionId ( ) ;
95+ activity . SetTag ( $ "db.transaction_id", transactionId ) ;
8896
89- // Only for explicit transactions.
90- if ( command . Transaction != null )
97+ // TODO: Firebird 4+ only (or remove?)
98+ /*
99+ var snapshotId = fbInfo.GetTransactionSnapshotNumber();
100+ if (snapshotId != 0)
91101 {
92- FbTransactionInfo fbInfo = new FbTransactionInfo ( command . Transaction ) ;
93-
94- var transactionId = fbInfo . GetTransactionId ( ) ;
95- activity . SetTag ( $ "db.transaction_id", transactionId ) ;
96-
97- // TODO: Firebird 4+ only (or remove?)
98- /*
99- var snapshotId = fbInfo.GetTransactionSnapshotNumber();
100- if (snapshotId != 0)
101- {
102- activity.SetTag($"db.snapshot_id", snapshotId);
103- }
104- */
102+ activity.SetTag($"db.snapshot_id", snapshotId);
105103 }
104+ */
106105 }
107106
108107 return activity ;
0 commit comments