@@ -25,18 +25,20 @@ import {
2525 isWrapped ,
2626} from '@opentelemetry/instrumentation' ;
2727import {
28- SEMATTRS_DB_NAME ,
29- SEMATTRS_DB_OPERATION ,
30- SEMATTRS_DB_SQL_TABLE ,
31- SEMATTRS_DB_STATEMENT ,
32- SEMATTRS_DB_SYSTEM ,
33- SEMATTRS_DB_USER ,
34- SEMATTRS_NET_PEER_NAME ,
35- SEMATTRS_NET_PEER_PORT ,
36- SEMATTRS_NET_TRANSPORT ,
37- } from '@opentelemetry/semantic-conventions' ;
28+ ATTR_DB_COLLECTION_NAME ,
29+ ATTR_DB_NAMESPACE ,
30+ ATTR_DB_OPERATION_NAME ,
31+ ATTR_DB_QUERY_TEXT ,
32+ ATTR_DB_SYSTEM ,
33+ ATTR_DB_USER ,
34+ } from './semconv' ;
3835import * as utils from './utils' ;
3936import { KnexInstrumentationConfig } from './types' ;
37+ import {
38+ ATTR_NETWORK_TRANSPORT ,
39+ ATTR_SERVER_ADDRESS ,
40+ ATTR_SERVER_PORT ,
41+ } from '@opentelemetry/semantic-conventions' ;
4042
4143const contextSymbol = Symbol ( 'opentelemetry.instrumentation-knex.context' ) ;
4244const DEFAULT_CONFIG : KnexInstrumentationConfig = {
@@ -134,21 +136,21 @@ export class KnexInstrumentation extends InstrumentationBase<KnexInstrumentation
134136 config ?. connection ?. filename || config ?. connection ?. database ;
135137 const { maxQueryLength } = instrumentation . getConfig ( ) ;
136138
137- const attributes : api . SpanAttributes = {
139+ const attributes : api . Attributes = {
138140 'knex.version' : moduleVersion ,
139- [ SEMATTRS_DB_SYSTEM ] : utils . mapSystem ( config . client ) ,
140- [ SEMATTRS_DB_SQL_TABLE ] : table ,
141- [ SEMATTRS_DB_OPERATION ] : operation ,
142- [ SEMATTRS_DB_USER ] : config ?. connection ?. user ,
143- [ SEMATTRS_DB_NAME ] : name ,
144- [ SEMATTRS_NET_PEER_NAME ] : config ?. connection ?. host ,
145- [ SEMATTRS_NET_PEER_PORT ] : config ?. connection ?. port ,
146- [ SEMATTRS_NET_TRANSPORT ] :
141+ [ ATTR_DB_SYSTEM ] : utils . mapSystem ( config . client ) ,
142+ [ ATTR_DB_COLLECTION_NAME ] : table ,
143+ [ ATTR_DB_OPERATION_NAME ] : operation ,
144+ [ ATTR_DB_USER ] : config ?. connection ?. user ,
145+ [ ATTR_DB_NAMESPACE ] : name ,
146+ [ ATTR_SERVER_ADDRESS ] : config ?. connection ?. host ,
147+ [ ATTR_SERVER_PORT ] : config ?. connection ?. port ,
148+ [ ATTR_NETWORK_TRANSPORT ] :
147149 config ?. connection ?. filename === ':memory:' ? 'inproc' : undefined ,
148150 } ;
149151 if ( maxQueryLength ) {
150152 // filters both undefined and 0
151- attributes [ SEMATTRS_DB_STATEMENT ] = utils . limitLength (
153+ attributes [ ATTR_DB_QUERY_TEXT ] = utils . limitLength (
152154 query ?. sql ,
153155 maxQueryLength
154156 ) ;
0 commit comments