Debian Codegraph @

semconv/v1.32.0/dbconv/metric.go

raw
1 // Code generated from semantic convention specification. DO NOT EDIT.
2
3 // Copyright The OpenTelemetry Authors
4 // SPDX-License-Identifier: Apache-2.0
5
6 // Package dbconv provides types and functionality for OpenTelemetry semantic
7 // conventions in the "db" namespace.
8 package dbconv
9
10 import (
11 "context"
12 "sync"
13
14 "go.opentelemetry.io/otel/attribute"
15 "go.opentelemetry.io/otel/metric"
16 "go.opentelemetry.io/otel/metric/noop"
17 )
18
19 var (
20 addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
21 recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
22 )
23
24 // ClientConnectionStateAttr is an attribute conforming to the
25 // db.client.connection.state semantic conventions. It represents the state of a
26 // connection in the pool.
27 type ClientConnectionStateAttr string
28
29 var (
30 // ClientConnectionStateIdle is the none.
31 ClientConnectionStateIdle ClientConnectionStateAttr = "idle"
32 // ClientConnectionStateUsed is the none.
33 ClientConnectionStateUsed ClientConnectionStateAttr = "used"
34 )
35
36 // ClientConnectionsStateAttr is an attribute conforming to the
37 // db.client.connections.state semantic conventions. It represents the
38 // deprecated, use `db.client.connection.state` instead.
39 type ClientConnectionsStateAttr string
40
41 var (
42 // ClientConnectionsStateIdle is the none.
43 ClientConnectionsStateIdle ClientConnectionsStateAttr = "idle"
44 // ClientConnectionsStateUsed is the none.
45 ClientConnectionsStateUsed ClientConnectionsStateAttr = "used"
46 )
47
48 // CosmosDBConsistencyLevelAttr is an attribute conforming to the
49 // db.cosmosdb.consistency_level semantic conventions. It represents the
50 // deprecated, use `cosmosdb.consistency.level` instead.
51 type CosmosDBConsistencyLevelAttr string
52
53 var (
54 // CosmosDBConsistencyLevelStrong is the none.
55 CosmosDBConsistencyLevelStrong CosmosDBConsistencyLevelAttr = "Strong"
56 // CosmosDBConsistencyLevelBoundedStaleness is the none.
57 CosmosDBConsistencyLevelBoundedStaleness CosmosDBConsistencyLevelAttr = "BoundedStaleness"
58 // CosmosDBConsistencyLevelSession is the none.
59 CosmosDBConsistencyLevelSession CosmosDBConsistencyLevelAttr = "Session"
60 // CosmosDBConsistencyLevelEventual is the none.
61 CosmosDBConsistencyLevelEventual CosmosDBConsistencyLevelAttr = "Eventual"
62 // CosmosDBConsistencyLevelConsistentPrefix is the none.
63 CosmosDBConsistencyLevelConsistentPrefix CosmosDBConsistencyLevelAttr = "ConsistentPrefix"
64 )
65
66 // SystemNameAttr is an attribute conforming to the db.system.name semantic
67 // conventions. It represents the database management system (DBMS) product as
68 // identified by the client instrumentation.
69 type SystemNameAttr string
70
71 var (
72 // SystemNameOtherSQL is the some other SQL database. Fallback only.
73 SystemNameOtherSQL SystemNameAttr = "other_sql"
74 // SystemNameSoftwareagAdabas is the [Adabas (Adaptable Database System)].
75 //
76 // [Adabas (Adaptable Database System)]: https://documentation.softwareag.com/?pf=adabas
77 SystemNameSoftwareagAdabas SystemNameAttr = "softwareag.adabas"
78 // SystemNameActianIngres is the [Actian Ingres].
79 //
80 // [Actian Ingres]: https://www.actian.com/databases/ingres/
81 SystemNameActianIngres SystemNameAttr = "actian.ingres"
82 // SystemNameAWSDynamoDB is the [Amazon DynamoDB].
83 //
84 // [Amazon DynamoDB]: https://aws.amazon.com/pm/dynamodb/
85 SystemNameAWSDynamoDB SystemNameAttr = "aws.dynamodb"
86 // SystemNameAWSRedshift is the [Amazon Redshift].
87 //
88 // [Amazon Redshift]: https://aws.amazon.com/redshift/
89 SystemNameAWSRedshift SystemNameAttr = "aws.redshift"
90 // SystemNameAzureCosmosDB is the [Azure Cosmos DB].
91 //
92 // [Azure Cosmos DB]: https://learn.microsoft.com/azure/cosmos-db
93 SystemNameAzureCosmosDB SystemNameAttr = "azure.cosmosdb"
94 // SystemNameIntersystemsCache is the [InterSystems Caché].
95 //
96 // [InterSystems Caché]: https://www.intersystems.com/products/cache/
97 SystemNameIntersystemsCache SystemNameAttr = "intersystems.cache"
98 // SystemNameCassandra is the [Apache Cassandra].
99 //
100 // [Apache Cassandra]: https://cassandra.apache.org/
101 SystemNameCassandra SystemNameAttr = "cassandra"
102 // SystemNameClickHouse is the [ClickHouse].
103 //
104 // [ClickHouse]: https://clickhouse.com/
105 SystemNameClickHouse SystemNameAttr = "clickhouse"
106 // SystemNameCockroachDB is the [CockroachDB].
107 //
108 // [CockroachDB]: https://www.cockroachlabs.com/
109 SystemNameCockroachDB SystemNameAttr = "cockroachdb"
110 // SystemNameCouchbase is the [Couchbase].
111 //
112 // [Couchbase]: https://www.couchbase.com/
113 SystemNameCouchbase SystemNameAttr = "couchbase"
114 // SystemNameCouchDB is the [Apache CouchDB].
115 //
116 // [Apache CouchDB]: https://couchdb.apache.org/
117 SystemNameCouchDB SystemNameAttr = "couchdb"
118 // SystemNameDerby is the [Apache Derby].
119 //
120 // [Apache Derby]: https://db.apache.org/derby/
121 SystemNameDerby SystemNameAttr = "derby"
122 // SystemNameElasticsearch is the [Elasticsearch].
123 //
124 // [Elasticsearch]: https://www.elastic.co/elasticsearch
125 SystemNameElasticsearch SystemNameAttr = "elasticsearch"
126 // SystemNameFirebirdSQL is the [Firebird].
127 //
128 // [Firebird]: https://www.firebirdsql.org/
129 SystemNameFirebirdSQL SystemNameAttr = "firebirdsql"
130 // SystemNameGCPSpanner is the [Google Cloud Spanner].
131 //
132 // [Google Cloud Spanner]: https://cloud.google.com/spanner
133 SystemNameGCPSpanner SystemNameAttr = "gcp.spanner"
134 // SystemNameGeode is the [Apache Geode].
135 //
136 // [Apache Geode]: https://geode.apache.org/
137 SystemNameGeode SystemNameAttr = "geode"
138 // SystemNameH2database is the [H2 Database].
139 //
140 // [H2 Database]: https://h2database.com/
141 SystemNameH2database SystemNameAttr = "h2database"
142 // SystemNameHBase is the [Apache HBase].
143 //
144 // [Apache HBase]: https://hbase.apache.org/
145 SystemNameHBase SystemNameAttr = "hbase"
146 // SystemNameHive is the [Apache Hive].
147 //
148 // [Apache Hive]: https://hive.apache.org/
149 SystemNameHive SystemNameAttr = "hive"
150 // SystemNameHSQLDB is the [HyperSQL Database].
151 //
152 // [HyperSQL Database]: https://hsqldb.org/
153 SystemNameHSQLDB SystemNameAttr = "hsqldb"
154 // SystemNameIBMDB2 is the [IBM Db2].
155 //
156 // [IBM Db2]: https://www.ibm.com/db2
157 SystemNameIBMDB2 SystemNameAttr = "ibm.db2"
158 // SystemNameIBMInformix is the [IBM Informix].
159 //
160 // [IBM Informix]: https://www.ibm.com/products/informix
161 SystemNameIBMInformix SystemNameAttr = "ibm.informix"
162 // SystemNameIBMNetezza is the [IBM Netezza].
163 //
164 // [IBM Netezza]: https://www.ibm.com/products/netezza
165 SystemNameIBMNetezza SystemNameAttr = "ibm.netezza"
166 // SystemNameInfluxDB is the [InfluxDB].
167 //
168 // [InfluxDB]: https://www.influxdata.com/
169 SystemNameInfluxDB SystemNameAttr = "influxdb"
170 // SystemNameInstantDB is the [Instant].
171 //
172 // [Instant]: https://www.instantdb.com/
173 SystemNameInstantDB SystemNameAttr = "instantdb"
174 // SystemNameMariaDB is the [MariaDB].
175 //
176 // [MariaDB]: https://mariadb.org/
177 SystemNameMariaDB SystemNameAttr = "mariadb"
178 // SystemNameMemcached is the [Memcached].
179 //
180 // [Memcached]: https://memcached.org/
181 SystemNameMemcached SystemNameAttr = "memcached"
182 // SystemNameMongoDB is the [MongoDB].
183 //
184 // [MongoDB]: https://www.mongodb.com/
185 SystemNameMongoDB SystemNameAttr = "mongodb"
186 // SystemNameMicrosoftSQLServer is the [Microsoft SQL Server].
187 //
188 // [Microsoft SQL Server]: https://www.microsoft.com/sql-server
189 SystemNameMicrosoftSQLServer SystemNameAttr = "microsoft.sql_server"
190 // SystemNameMySQL is the [MySQL].
191 //
192 // [MySQL]: https://www.mysql.com/
193 SystemNameMySQL SystemNameAttr = "mysql"
194 // SystemNameNeo4j is the [Neo4j].
195 //
196 // [Neo4j]: https://neo4j.com/
197 SystemNameNeo4j SystemNameAttr = "neo4j"
198 // SystemNameOpenSearch is the [OpenSearch].
199 //
200 // [OpenSearch]: https://opensearch.org/
201 SystemNameOpenSearch SystemNameAttr = "opensearch"
202 // SystemNameOracleDB is the [Oracle Database].
203 //
204 // [Oracle Database]: https://www.oracle.com/database/
205 SystemNameOracleDB SystemNameAttr = "oracle.db"
206 // SystemNamePostgreSQL is the [PostgreSQL].
207 //
208 // [PostgreSQL]: https://www.postgresql.org/
209 SystemNamePostgreSQL SystemNameAttr = "postgresql"
210 // SystemNameRedis is the [Redis].
211 //
212 // [Redis]: https://redis.io/
213 SystemNameRedis SystemNameAttr = "redis"
214 // SystemNameSAPHANA is the [SAP HANA].
215 //
216 // [SAP HANA]: https://www.sap.com/products/technology-platform/hana/what-is-sap-hana.html
217 SystemNameSAPHANA SystemNameAttr = "sap.hana"
218 // SystemNameSAPMaxDB is the [SAP MaxDB].
219 //
220 // [SAP MaxDB]: https://maxdb.sap.com/
221 SystemNameSAPMaxDB SystemNameAttr = "sap.maxdb"
222 // SystemNameSQLite is the [SQLite].
223 //
224 // [SQLite]: https://www.sqlite.org/
225 SystemNameSQLite SystemNameAttr = "sqlite"
226 // SystemNameTeradata is the [Teradata].
227 //
228 // [Teradata]: https://www.teradata.com/
229 SystemNameTeradata SystemNameAttr = "teradata"
230 // SystemNameTrino is the [Trino].
231 //
232 // [Trino]: https://trino.io/
233 SystemNameTrino SystemNameAttr = "trino"
234 )
235
236 // ErrorTypeAttr is an attribute conforming to the error.type semantic
237 // conventions. It represents the describes a class of error the operation ended
238 // with.
239 type ErrorTypeAttr string
240
241 var (
242 // ErrorTypeOther is a fallback error value to be used when the instrumentation
243 // doesn't define a custom value.
244 ErrorTypeOther ErrorTypeAttr = "_OTHER"
245 )
246
247 // ClientConnectionCount is an instrument used to record metric values conforming
248 // to the "db.client.connection.count" semantic conventions. It represents the
249 // number of connections that are currently in state described by the `state`
250 // attribute.
251 type ClientConnectionCount struct {
252 metric.Int64UpDownCounter
253 }
254
255 // NewClientConnectionCount returns a new ClientConnectionCount instrument.
256 func NewClientConnectionCount(
257 m metric.Meter,
258 opt ...metric.Int64UpDownCounterOption,
259 ) (ClientConnectionCount, error) {
260 // Check if the meter is nil.
261 if m == nil {
262 return ClientConnectionCount{noop.Int64UpDownCounter{}}, nil
263 }
264
265 i, err := m.Int64UpDownCounter(
266 "db.client.connection.count",
267 append([]metric.Int64UpDownCounterOption{
268 metric.WithDescription("The number of connections that are currently in state described by the `state` attribute"),
269 metric.WithUnit("{connection}"),
270 }, opt...)...,
271 )
272 if err != nil {
273 return ClientConnectionCount{noop.Int64UpDownCounter{}}, err
274 }
275 return ClientConnectionCount{i}, nil
276 }
277
278 // Inst returns the underlying metric instrument.
279 func (m ClientConnectionCount) Inst() metric.Int64UpDownCounter {
280 return m.Int64UpDownCounter
281 }
282
283 // Name returns the semantic convention name of the instrument.
284 func (ClientConnectionCount) Name() string {
285 return "db.client.connection.count"
286 }
287
288 // Unit returns the semantic convention unit of the instrument
289 func (ClientConnectionCount) Unit() string {
290 return "{connection}"
291 }
292
293 // Description returns the semantic convention description of the instrument
294 func (ClientConnectionCount) Description() string {
295 return "The number of connections that are currently in state described by the `state` attribute"
296 }
297
298 // Add adds incr to the existing count.
299 //
300 // The clientConnectionPoolName is the the name of the connection pool; unique
301 // within the instrumented application. In case the connection pool
302 // implementation doesn't provide a name, instrumentation SHOULD use a
303 // combination of parameters that would make the name unique, for example,
304 // combining attributes `server.address`, `server.port`, and `db.namespace`,
305 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
306 // generate connection pool name following different patterns SHOULD document it.
307 //
308 // The clientConnectionState is the the state of a connection in the pool
309 func (m ClientConnectionCount) Add(
310 ctx context.Context,
311 incr int64,
312 clientConnectionPoolName string,
313 clientConnectionState ClientConnectionStateAttr,
314 attrs ...attribute.KeyValue,
315 ) {
316 o := addOptPool.Get().(*[]metric.AddOption)
317 defer func() {
318 *o = (*o)[:0]
319 addOptPool.Put(o)
320 }()
321
322 *o = append(
323 *o,
324 metric.WithAttributes(
325 append(
326 attrs,
327 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
328 attribute.String("db.client.connection.state", string(clientConnectionState)),
329 )...,
330 ),
331 )
332
333 m.Int64UpDownCounter.Add(ctx, incr, *o...)
334 }
335
336 // ClientConnectionCreateTime is an instrument used to record metric values
337 // conforming to the "db.client.connection.create_time" semantic conventions. It
338 // represents the time it took to create a new connection.
339 type ClientConnectionCreateTime struct {
340 metric.Float64Histogram
341 }
342
343 // NewClientConnectionCreateTime returns a new ClientConnectionCreateTime
344 // instrument.
345 func NewClientConnectionCreateTime(
346 m metric.Meter,
347 opt ...metric.Float64HistogramOption,
348 ) (ClientConnectionCreateTime, error) {
349 // Check if the meter is nil.
350 if m == nil {
351 return ClientConnectionCreateTime{noop.Float64Histogram{}}, nil
352 }
353
354 i, err := m.Float64Histogram(
355 "db.client.connection.create_time",
356 append([]metric.Float64HistogramOption{
357 metric.WithDescription("The time it took to create a new connection"),
358 metric.WithUnit("s"),
359 }, opt...)...,
360 )
361 if err != nil {
362 return ClientConnectionCreateTime{noop.Float64Histogram{}}, err
363 }
364 return ClientConnectionCreateTime{i}, nil
365 }
366
367 // Inst returns the underlying metric instrument.
368 func (m ClientConnectionCreateTime) Inst() metric.Float64Histogram {
369 return m.Float64Histogram
370 }
371
372 // Name returns the semantic convention name of the instrument.
373 func (ClientConnectionCreateTime) Name() string {
374 return "db.client.connection.create_time"
375 }
376
377 // Unit returns the semantic convention unit of the instrument
378 func (ClientConnectionCreateTime) Unit() string {
379 return "s"
380 }
381
382 // Description returns the semantic convention description of the instrument
383 func (ClientConnectionCreateTime) Description() string {
384 return "The time it took to create a new connection"
385 }
386
387 // Record records val to the current distribution.
388 //
389 // The clientConnectionPoolName is the the name of the connection pool; unique
390 // within the instrumented application. In case the connection pool
391 // implementation doesn't provide a name, instrumentation SHOULD use a
392 // combination of parameters that would make the name unique, for example,
393 // combining attributes `server.address`, `server.port`, and `db.namespace`,
394 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
395 // generate connection pool name following different patterns SHOULD document it.
396 func (m ClientConnectionCreateTime) Record(
397 ctx context.Context,
398 val float64,
399 clientConnectionPoolName string,
400 attrs ...attribute.KeyValue,
401 ) {
402 o := recOptPool.Get().(*[]metric.RecordOption)
403 defer func() {
404 *o = (*o)[:0]
405 recOptPool.Put(o)
406 }()
407
408 *o = append(
409 *o,
410 metric.WithAttributes(
411 append(
412 attrs,
413 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
414 )...,
415 ),
416 )
417
418 m.Float64Histogram.Record(ctx, val, *o...)
419 }
420
421 // ClientConnectionIdleMax is an instrument used to record metric values
422 // conforming to the "db.client.connection.idle.max" semantic conventions. It
423 // represents the maximum number of idle open connections allowed.
424 type ClientConnectionIdleMax struct {
425 metric.Int64UpDownCounter
426 }
427
428 // NewClientConnectionIdleMax returns a new ClientConnectionIdleMax instrument.
429 func NewClientConnectionIdleMax(
430 m metric.Meter,
431 opt ...metric.Int64UpDownCounterOption,
432 ) (ClientConnectionIdleMax, error) {
433 // Check if the meter is nil.
434 if m == nil {
435 return ClientConnectionIdleMax{noop.Int64UpDownCounter{}}, nil
436 }
437
438 i, err := m.Int64UpDownCounter(
439 "db.client.connection.idle.max",
440 append([]metric.Int64UpDownCounterOption{
441 metric.WithDescription("The maximum number of idle open connections allowed"),
442 metric.WithUnit("{connection}"),
443 }, opt...)...,
444 )
445 if err != nil {
446 return ClientConnectionIdleMax{noop.Int64UpDownCounter{}}, err
447 }
448 return ClientConnectionIdleMax{i}, nil
449 }
450
451 // Inst returns the underlying metric instrument.
452 func (m ClientConnectionIdleMax) Inst() metric.Int64UpDownCounter {
453 return m.Int64UpDownCounter
454 }
455
456 // Name returns the semantic convention name of the instrument.
457 func (ClientConnectionIdleMax) Name() string {
458 return "db.client.connection.idle.max"
459 }
460
461 // Unit returns the semantic convention unit of the instrument
462 func (ClientConnectionIdleMax) Unit() string {
463 return "{connection}"
464 }
465
466 // Description returns the semantic convention description of the instrument
467 func (ClientConnectionIdleMax) Description() string {
468 return "The maximum number of idle open connections allowed"
469 }
470
471 // Add adds incr to the existing count.
472 //
473 // The clientConnectionPoolName is the the name of the connection pool; unique
474 // within the instrumented application. In case the connection pool
475 // implementation doesn't provide a name, instrumentation SHOULD use a
476 // combination of parameters that would make the name unique, for example,
477 // combining attributes `server.address`, `server.port`, and `db.namespace`,
478 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
479 // generate connection pool name following different patterns SHOULD document it.
480 func (m ClientConnectionIdleMax) Add(
481 ctx context.Context,
482 incr int64,
483 clientConnectionPoolName string,
484 attrs ...attribute.KeyValue,
485 ) {
486 o := addOptPool.Get().(*[]metric.AddOption)
487 defer func() {
488 *o = (*o)[:0]
489 addOptPool.Put(o)
490 }()
491
492 *o = append(
493 *o,
494 metric.WithAttributes(
495 append(
496 attrs,
497 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
498 )...,
499 ),
500 )
501
502 m.Int64UpDownCounter.Add(ctx, incr, *o...)
503 }
504
505 // ClientConnectionIdleMin is an instrument used to record metric values
506 // conforming to the "db.client.connection.idle.min" semantic conventions. It
507 // represents the minimum number of idle open connections allowed.
508 type ClientConnectionIdleMin struct {
509 metric.Int64UpDownCounter
510 }
511
512 // NewClientConnectionIdleMin returns a new ClientConnectionIdleMin instrument.
513 func NewClientConnectionIdleMin(
514 m metric.Meter,
515 opt ...metric.Int64UpDownCounterOption,
516 ) (ClientConnectionIdleMin, error) {
517 // Check if the meter is nil.
518 if m == nil {
519 return ClientConnectionIdleMin{noop.Int64UpDownCounter{}}, nil
520 }
521
522 i, err := m.Int64UpDownCounter(
523 "db.client.connection.idle.min",
524 append([]metric.Int64UpDownCounterOption{
525 metric.WithDescription("The minimum number of idle open connections allowed"),
526 metric.WithUnit("{connection}"),
527 }, opt...)...,
528 )
529 if err != nil {
530 return ClientConnectionIdleMin{noop.Int64UpDownCounter{}}, err
531 }
532 return ClientConnectionIdleMin{i}, nil
533 }
534
535 // Inst returns the underlying metric instrument.
536 func (m ClientConnectionIdleMin) Inst() metric.Int64UpDownCounter {
537 return m.Int64UpDownCounter
538 }
539
540 // Name returns the semantic convention name of the instrument.
541 func (ClientConnectionIdleMin) Name() string {
542 return "db.client.connection.idle.min"
543 }
544
545 // Unit returns the semantic convention unit of the instrument
546 func (ClientConnectionIdleMin) Unit() string {
547 return "{connection}"
548 }
549
550 // Description returns the semantic convention description of the instrument
551 func (ClientConnectionIdleMin) Description() string {
552 return "The minimum number of idle open connections allowed"
553 }
554
555 // Add adds incr to the existing count.
556 //
557 // The clientConnectionPoolName is the the name of the connection pool; unique
558 // within the instrumented application. In case the connection pool
559 // implementation doesn't provide a name, instrumentation SHOULD use a
560 // combination of parameters that would make the name unique, for example,
561 // combining attributes `server.address`, `server.port`, and `db.namespace`,
562 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
563 // generate connection pool name following different patterns SHOULD document it.
564 func (m ClientConnectionIdleMin) Add(
565 ctx context.Context,
566 incr int64,
567 clientConnectionPoolName string,
568 attrs ...attribute.KeyValue,
569 ) {
570 o := addOptPool.Get().(*[]metric.AddOption)
571 defer func() {
572 *o = (*o)[:0]
573 addOptPool.Put(o)
574 }()
575
576 *o = append(
577 *o,
578 metric.WithAttributes(
579 append(
580 attrs,
581 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
582 )...,
583 ),
584 )
585
586 m.Int64UpDownCounter.Add(ctx, incr, *o...)
587 }
588
589 // ClientConnectionMax is an instrument used to record metric values conforming
590 // to the "db.client.connection.max" semantic conventions. It represents the
591 // maximum number of open connections allowed.
592 type ClientConnectionMax struct {
593 metric.Int64UpDownCounter
594 }
595
596 // NewClientConnectionMax returns a new ClientConnectionMax instrument.
597 func NewClientConnectionMax(
598 m metric.Meter,
599 opt ...metric.Int64UpDownCounterOption,
600 ) (ClientConnectionMax, error) {
601 // Check if the meter is nil.
602 if m == nil {
603 return ClientConnectionMax{noop.Int64UpDownCounter{}}, nil
604 }
605
606 i, err := m.Int64UpDownCounter(
607 "db.client.connection.max",
608 append([]metric.Int64UpDownCounterOption{
609 metric.WithDescription("The maximum number of open connections allowed"),
610 metric.WithUnit("{connection}"),
611 }, opt...)...,
612 )
613 if err != nil {
614 return ClientConnectionMax{noop.Int64UpDownCounter{}}, err
615 }
616 return ClientConnectionMax{i}, nil
617 }
618
619 // Inst returns the underlying metric instrument.
620 func (m ClientConnectionMax) Inst() metric.Int64UpDownCounter {
621 return m.Int64UpDownCounter
622 }
623
624 // Name returns the semantic convention name of the instrument.
625 func (ClientConnectionMax) Name() string {
626 return "db.client.connection.max"
627 }
628
629 // Unit returns the semantic convention unit of the instrument
630 func (ClientConnectionMax) Unit() string {
631 return "{connection}"
632 }
633
634 // Description returns the semantic convention description of the instrument
635 func (ClientConnectionMax) Description() string {
636 return "The maximum number of open connections allowed"
637 }
638
639 // Add adds incr to the existing count.
640 //
641 // The clientConnectionPoolName is the the name of the connection pool; unique
642 // within the instrumented application. In case the connection pool
643 // implementation doesn't provide a name, instrumentation SHOULD use a
644 // combination of parameters that would make the name unique, for example,
645 // combining attributes `server.address`, `server.port`, and `db.namespace`,
646 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
647 // generate connection pool name following different patterns SHOULD document it.
648 func (m ClientConnectionMax) Add(
649 ctx context.Context,
650 incr int64,
651 clientConnectionPoolName string,
652 attrs ...attribute.KeyValue,
653 ) {
654 o := addOptPool.Get().(*[]metric.AddOption)
655 defer func() {
656 *o = (*o)[:0]
657 addOptPool.Put(o)
658 }()
659
660 *o = append(
661 *o,
662 metric.WithAttributes(
663 append(
664 attrs,
665 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
666 )...,
667 ),
668 )
669
670 m.Int64UpDownCounter.Add(ctx, incr, *o...)
671 }
672
673 // ClientConnectionPendingRequests is an instrument used to record metric values
674 // conforming to the "db.client.connection.pending_requests" semantic
675 // conventions. It represents the number of current pending requests for an open
676 // connection.
677 type ClientConnectionPendingRequests struct {
678 metric.Int64UpDownCounter
679 }
680
681 // NewClientConnectionPendingRequests returns a new
682 // ClientConnectionPendingRequests instrument.
683 func NewClientConnectionPendingRequests(
684 m metric.Meter,
685 opt ...metric.Int64UpDownCounterOption,
686 ) (ClientConnectionPendingRequests, error) {
687 // Check if the meter is nil.
688 if m == nil {
689 return ClientConnectionPendingRequests{noop.Int64UpDownCounter{}}, nil
690 }
691
692 i, err := m.Int64UpDownCounter(
693 "db.client.connection.pending_requests",
694 append([]metric.Int64UpDownCounterOption{
695 metric.WithDescription("The number of current pending requests for an open connection"),
696 metric.WithUnit("{request}"),
697 }, opt...)...,
698 )
699 if err != nil {
700 return ClientConnectionPendingRequests{noop.Int64UpDownCounter{}}, err
701 }
702 return ClientConnectionPendingRequests{i}, nil
703 }
704
705 // Inst returns the underlying metric instrument.
706 func (m ClientConnectionPendingRequests) Inst() metric.Int64UpDownCounter {
707 return m.Int64UpDownCounter
708 }
709
710 // Name returns the semantic convention name of the instrument.
711 func (ClientConnectionPendingRequests) Name() string {
712 return "db.client.connection.pending_requests"
713 }
714
715 // Unit returns the semantic convention unit of the instrument
716 func (ClientConnectionPendingRequests) Unit() string {
717 return "{request}"
718 }
719
720 // Description returns the semantic convention description of the instrument
721 func (ClientConnectionPendingRequests) Description() string {
722 return "The number of current pending requests for an open connection"
723 }
724
725 // Add adds incr to the existing count.
726 //
727 // The clientConnectionPoolName is the the name of the connection pool; unique
728 // within the instrumented application. In case the connection pool
729 // implementation doesn't provide a name, instrumentation SHOULD use a
730 // combination of parameters that would make the name unique, for example,
731 // combining attributes `server.address`, `server.port`, and `db.namespace`,
732 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
733 // generate connection pool name following different patterns SHOULD document it.
734 func (m ClientConnectionPendingRequests) Add(
735 ctx context.Context,
736 incr int64,
737 clientConnectionPoolName string,
738 attrs ...attribute.KeyValue,
739 ) {
740 o := addOptPool.Get().(*[]metric.AddOption)
741 defer func() {
742 *o = (*o)[:0]
743 addOptPool.Put(o)
744 }()
745
746 *o = append(
747 *o,
748 metric.WithAttributes(
749 append(
750 attrs,
751 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
752 )...,
753 ),
754 )
755
756 m.Int64UpDownCounter.Add(ctx, incr, *o...)
757 }
758
759 // ClientConnectionTimeouts is an instrument used to record metric values
760 // conforming to the "db.client.connection.timeouts" semantic conventions. It
761 // represents the number of connection timeouts that have occurred trying to
762 // obtain a connection from the pool.
763 type ClientConnectionTimeouts struct {
764 metric.Int64Counter
765 }
766
767 // NewClientConnectionTimeouts returns a new ClientConnectionTimeouts instrument.
768 func NewClientConnectionTimeouts(
769 m metric.Meter,
770 opt ...metric.Int64CounterOption,
771 ) (ClientConnectionTimeouts, error) {
772 // Check if the meter is nil.
773 if m == nil {
774 return ClientConnectionTimeouts{noop.Int64Counter{}}, nil
775 }
776
777 i, err := m.Int64Counter(
778 "db.client.connection.timeouts",
779 append([]metric.Int64CounterOption{
780 metric.WithDescription("The number of connection timeouts that have occurred trying to obtain a connection from the pool"),
781 metric.WithUnit("{timeout}"),
782 }, opt...)...,
783 )
784 if err != nil {
785 return ClientConnectionTimeouts{noop.Int64Counter{}}, err
786 }
787 return ClientConnectionTimeouts{i}, nil
788 }
789
790 // Inst returns the underlying metric instrument.
791 func (m ClientConnectionTimeouts) Inst() metric.Int64Counter {
792 return m.Int64Counter
793 }
794
795 // Name returns the semantic convention name of the instrument.
796 func (ClientConnectionTimeouts) Name() string {
797 return "db.client.connection.timeouts"
798 }
799
800 // Unit returns the semantic convention unit of the instrument
801 func (ClientConnectionTimeouts) Unit() string {
802 return "{timeout}"
803 }
804
805 // Description returns the semantic convention description of the instrument
806 func (ClientConnectionTimeouts) Description() string {
807 return "The number of connection timeouts that have occurred trying to obtain a connection from the pool"
808 }
809
810 // Add adds incr to the existing count.
811 //
812 // The clientConnectionPoolName is the the name of the connection pool; unique
813 // within the instrumented application. In case the connection pool
814 // implementation doesn't provide a name, instrumentation SHOULD use a
815 // combination of parameters that would make the name unique, for example,
816 // combining attributes `server.address`, `server.port`, and `db.namespace`,
817 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
818 // generate connection pool name following different patterns SHOULD document it.
819 func (m ClientConnectionTimeouts) Add(
820 ctx context.Context,
821 incr int64,
822 clientConnectionPoolName string,
823 attrs ...attribute.KeyValue,
824 ) {
825 o := addOptPool.Get().(*[]metric.AddOption)
826 defer func() {
827 *o = (*o)[:0]
828 addOptPool.Put(o)
829 }()
830
831 *o = append(
832 *o,
833 metric.WithAttributes(
834 append(
835 attrs,
836 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
837 )...,
838 ),
839 )
840
841 m.Int64Counter.Add(ctx, incr, *o...)
842 }
843
844 // ClientConnectionUseTime is an instrument used to record metric values
845 // conforming to the "db.client.connection.use_time" semantic conventions. It
846 // represents the time between borrowing a connection and returning it to the
847 // pool.
848 type ClientConnectionUseTime struct {
849 metric.Float64Histogram
850 }
851
852 // NewClientConnectionUseTime returns a new ClientConnectionUseTime instrument.
853 func NewClientConnectionUseTime(
854 m metric.Meter,
855 opt ...metric.Float64HistogramOption,
856 ) (ClientConnectionUseTime, error) {
857 // Check if the meter is nil.
858 if m == nil {
859 return ClientConnectionUseTime{noop.Float64Histogram{}}, nil
860 }
861
862 i, err := m.Float64Histogram(
863 "db.client.connection.use_time",
864 append([]metric.Float64HistogramOption{
865 metric.WithDescription("The time between borrowing a connection and returning it to the pool"),
866 metric.WithUnit("s"),
867 }, opt...)...,
868 )
869 if err != nil {
870 return ClientConnectionUseTime{noop.Float64Histogram{}}, err
871 }
872 return ClientConnectionUseTime{i}, nil
873 }
874
875 // Inst returns the underlying metric instrument.
876 func (m ClientConnectionUseTime) Inst() metric.Float64Histogram {
877 return m.Float64Histogram
878 }
879
880 // Name returns the semantic convention name of the instrument.
881 func (ClientConnectionUseTime) Name() string {
882 return "db.client.connection.use_time"
883 }
884
885 // Unit returns the semantic convention unit of the instrument
886 func (ClientConnectionUseTime) Unit() string {
887 return "s"
888 }
889
890 // Description returns the semantic convention description of the instrument
891 func (ClientConnectionUseTime) Description() string {
892 return "The time between borrowing a connection and returning it to the pool"
893 }
894
895 // Record records val to the current distribution.
896 //
897 // The clientConnectionPoolName is the the name of the connection pool; unique
898 // within the instrumented application. In case the connection pool
899 // implementation doesn't provide a name, instrumentation SHOULD use a
900 // combination of parameters that would make the name unique, for example,
901 // combining attributes `server.address`, `server.port`, and `db.namespace`,
902 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
903 // generate connection pool name following different patterns SHOULD document it.
904 func (m ClientConnectionUseTime) Record(
905 ctx context.Context,
906 val float64,
907 clientConnectionPoolName string,
908 attrs ...attribute.KeyValue,
909 ) {
910 o := recOptPool.Get().(*[]metric.RecordOption)
911 defer func() {
912 *o = (*o)[:0]
913 recOptPool.Put(o)
914 }()
915
916 *o = append(
917 *o,
918 metric.WithAttributes(
919 append(
920 attrs,
921 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
922 )...,
923 ),
924 )
925
926 m.Float64Histogram.Record(ctx, val, *o...)
927 }
928
929 // ClientConnectionWaitTime is an instrument used to record metric values
930 // conforming to the "db.client.connection.wait_time" semantic conventions. It
931 // represents the time it took to obtain an open connection from the pool.
932 type ClientConnectionWaitTime struct {
933 metric.Float64Histogram
934 }
935
936 // NewClientConnectionWaitTime returns a new ClientConnectionWaitTime instrument.
937 func NewClientConnectionWaitTime(
938 m metric.Meter,
939 opt ...metric.Float64HistogramOption,
940 ) (ClientConnectionWaitTime, error) {
941 // Check if the meter is nil.
942 if m == nil {
943 return ClientConnectionWaitTime{noop.Float64Histogram{}}, nil
944 }
945
946 i, err := m.Float64Histogram(
947 "db.client.connection.wait_time",
948 append([]metric.Float64HistogramOption{
949 metric.WithDescription("The time it took to obtain an open connection from the pool"),
950 metric.WithUnit("s"),
951 }, opt...)...,
952 )
953 if err != nil {
954 return ClientConnectionWaitTime{noop.Float64Histogram{}}, err
955 }
956 return ClientConnectionWaitTime{i}, nil
957 }
958
959 // Inst returns the underlying metric instrument.
960 func (m ClientConnectionWaitTime) Inst() metric.Float64Histogram {
961 return m.Float64Histogram
962 }
963
964 // Name returns the semantic convention name of the instrument.
965 func (ClientConnectionWaitTime) Name() string {
966 return "db.client.connection.wait_time"
967 }
968
969 // Unit returns the semantic convention unit of the instrument
970 func (ClientConnectionWaitTime) Unit() string {
971 return "s"
972 }
973
974 // Description returns the semantic convention description of the instrument
975 func (ClientConnectionWaitTime) Description() string {
976 return "The time it took to obtain an open connection from the pool"
977 }
978
979 // Record records val to the current distribution.
980 //
981 // The clientConnectionPoolName is the the name of the connection pool; unique
982 // within the instrumented application. In case the connection pool
983 // implementation doesn't provide a name, instrumentation SHOULD use a
984 // combination of parameters that would make the name unique, for example,
985 // combining attributes `server.address`, `server.port`, and `db.namespace`,
986 // formatted as `server.address:server.port/db.namespace`. Instrumentations that
987 // generate connection pool name following different patterns SHOULD document it.
988 func (m ClientConnectionWaitTime) Record(
989 ctx context.Context,
990 val float64,
991 clientConnectionPoolName string,
992 attrs ...attribute.KeyValue,
993 ) {
994 o := recOptPool.Get().(*[]metric.RecordOption)
995 defer func() {
996 *o = (*o)[:0]
997 recOptPool.Put(o)
998 }()
999
1000 *o = append(
1001 *o,
1002 metric.WithAttributes(
1003 append(
1004 attrs,
1005 attribute.String("db.client.connection.pool.name", clientConnectionPoolName),
1006 )...,
1007 ),
1008 )
1009
1010 m.Float64Histogram.Record(ctx, val, *o...)
1011 }
1012
1013 // ClientOperationDuration is an instrument used to record metric values
1014 // conforming to the "db.client.operation.duration" semantic conventions. It
1015 // represents the duration of database client operations.
1016 type ClientOperationDuration struct {
1017 metric.Float64Histogram
1018 }
1019
1020 // NewClientOperationDuration returns a new ClientOperationDuration instrument.
1021 func NewClientOperationDuration(
1022 m metric.Meter,
1023 opt ...metric.Float64HistogramOption,
1024 ) (ClientOperationDuration, error) {
1025 // Check if the meter is nil.
1026 if m == nil {
1027 return ClientOperationDuration{noop.Float64Histogram{}}, nil
1028 }
1029
1030 i, err := m.Float64Histogram(
1031 "db.client.operation.duration",
1032 append([]metric.Float64HistogramOption{
1033 metric.WithDescription("Duration of database client operations."),
1034 metric.WithUnit("s"),
1035 }, opt...)...,
1036 )
1037 if err != nil {
1038 return ClientOperationDuration{noop.Float64Histogram{}}, err
1039 }
1040 return ClientOperationDuration{i}, nil
1041 }
1042
1043 // Inst returns the underlying metric instrument.
1044 func (m ClientOperationDuration) Inst() metric.Float64Histogram {
1045 return m.Float64Histogram
1046 }
1047
1048 // Name returns the semantic convention name of the instrument.
1049 func (ClientOperationDuration) Name() string {
1050 return "db.client.operation.duration"
1051 }
1052
1053 // Unit returns the semantic convention unit of the instrument
1054 func (ClientOperationDuration) Unit() string {
1055 return "s"
1056 }
1057
1058 // Description returns the semantic convention description of the instrument
1059 func (ClientOperationDuration) Description() string {
1060 return "Duration of database client operations."
1061 }
1062
1063 // Record records val to the current distribution.
1064 //
1065 // The systemName is the the database management system (DBMS) product as
1066 // identified by the client instrumentation.
1067 //
1068 // All additional attrs passed are included in the recorded value.
1069 //
1070 // Batch operations SHOULD be recorded as a single operation.
1071 func (m ClientOperationDuration) Record(
1072 ctx context.Context,
1073 val float64,
1074 systemName SystemNameAttr,
1075 attrs ...attribute.KeyValue,
1076 ) {
1077 o := recOptPool.Get().(*[]metric.RecordOption)
1078 defer func() {
1079 *o = (*o)[:0]
1080 recOptPool.Put(o)
1081 }()
1082
1083 *o = append(
1084 *o,
1085 metric.WithAttributes(
1086 append(
1087 attrs,
1088 attribute.String("db.system.name", string(systemName)),
1089 )...,
1090 ),
1091 )
1092
1093 m.Float64Histogram.Record(ctx, val, *o...)
1094 }
1095
1096 // AttrCollectionName returns an optional attribute for the "db.collection.name"
1097 // semantic convention. It represents the name of a collection (table, container)
1098 // within the database.
1099 func (ClientOperationDuration) AttrCollectionName(val string) attribute.KeyValue {
1100 return attribute.String("db.collection.name", val)
1101 }
1102
1103 // AttrNamespace returns an optional attribute for the "db.namespace" semantic
1104 // convention. It represents the name of the database, fully qualified within the
1105 // server address and port.
1106 func (ClientOperationDuration) AttrNamespace(val string) attribute.KeyValue {
1107 return attribute.String("db.namespace", val)
1108 }
1109
1110 // AttrOperationName returns an optional attribute for the "db.operation.name"
1111 // semantic convention. It represents the name of the operation or command being
1112 // executed.
1113 func (ClientOperationDuration) AttrOperationName(val string) attribute.KeyValue {
1114 return attribute.String("db.operation.name", val)
1115 }
1116
1117 // AttrResponseStatusCode returns an optional attribute for the
1118 // "db.response.status_code" semantic convention. It represents the database
1119 // response status code.
1120 func (ClientOperationDuration) AttrResponseStatusCode(val string) attribute.KeyValue {
1121 return attribute.String("db.response.status_code", val)
1122 }
1123
1124 // AttrErrorType returns an optional attribute for the "error.type" semantic
1125 // convention. It represents the describes a class of error the operation ended
1126 // with.
1127 func (ClientOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1128 return attribute.String("error.type", string(val))
1129 }
1130
1131 // AttrServerPort returns an optional attribute for the "server.port" semantic
1132 // convention. It represents the server port number.
1133 func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue {
1134 return attribute.Int("server.port", val)
1135 }
1136
1137 // AttrQuerySummary returns an optional attribute for the "db.query.summary"
1138 // semantic convention. It represents the low cardinality representation of a
1139 // database query text.
1140 func (ClientOperationDuration) AttrQuerySummary(val string) attribute.KeyValue {
1141 return attribute.String("db.query.summary", val)
1142 }
1143
1144 // AttrStoredProcedureName returns an optional attribute for the
1145 // "db.stored_procedure.name" semantic convention. It represents the name of a
1146 // stored procedure within the database.
1147 func (ClientOperationDuration) AttrStoredProcedureName(val string) attribute.KeyValue {
1148 return attribute.String("db.stored_procedure.name", val)
1149 }
1150
1151 // AttrNetworkPeerAddress returns an optional attribute for the
1152 // "network.peer.address" semantic convention. It represents the peer address of
1153 // the database node where the operation was performed.
1154 func (ClientOperationDuration) AttrNetworkPeerAddress(val string) attribute.KeyValue {
1155 return attribute.String("network.peer.address", val)
1156 }
1157
1158 // AttrNetworkPeerPort returns an optional attribute for the "network.peer.port"
1159 // semantic convention. It represents the peer port number of the network
1160 // connection.
1161 func (ClientOperationDuration) AttrNetworkPeerPort(val int) attribute.KeyValue {
1162 return attribute.Int("network.peer.port", val)
1163 }
1164
1165 // AttrServerAddress returns an optional attribute for the "server.address"
1166 // semantic convention. It represents the name of the database host.
1167 func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue {
1168 return attribute.String("server.address", val)
1169 }
1170
1171 // AttrQueryText returns an optional attribute for the "db.query.text" semantic
1172 // convention. It represents the database query being executed.
1173 func (ClientOperationDuration) AttrQueryText(val string) attribute.KeyValue {
1174 return attribute.String("db.query.text", val)
1175 }
1176
1177 // ClientResponseReturnedRows is an instrument used to record metric values
1178 // conforming to the "db.client.response.returned_rows" semantic conventions. It
1179 // represents the actual number of records returned by the database operation.
1180 type ClientResponseReturnedRows struct {
1181 metric.Int64Histogram
1182 }
1183
1184 // NewClientResponseReturnedRows returns a new ClientResponseReturnedRows
1185 // instrument.
1186 func NewClientResponseReturnedRows(
1187 m metric.Meter,
1188 opt ...metric.Int64HistogramOption,
1189 ) (ClientResponseReturnedRows, error) {
1190 // Check if the meter is nil.
1191 if m == nil {
1192 return ClientResponseReturnedRows{noop.Int64Histogram{}}, nil
1193 }
1194
1195 i, err := m.Int64Histogram(
1196 "db.client.response.returned_rows",
1197 append([]metric.Int64HistogramOption{
1198 metric.WithDescription("The actual number of records returned by the database operation."),
1199 metric.WithUnit("{row}"),
1200 }, opt...)...,
1201 )
1202 if err != nil {
1203 return ClientResponseReturnedRows{noop.Int64Histogram{}}, err
1204 }
1205 return ClientResponseReturnedRows{i}, nil
1206 }
1207
1208 // Inst returns the underlying metric instrument.
1209 func (m ClientResponseReturnedRows) Inst() metric.Int64Histogram {
1210 return m.Int64Histogram
1211 }
1212
1213 // Name returns the semantic convention name of the instrument.
1214 func (ClientResponseReturnedRows) Name() string {
1215 return "db.client.response.returned_rows"
1216 }
1217
1218 // Unit returns the semantic convention unit of the instrument
1219 func (ClientResponseReturnedRows) Unit() string {
1220 return "{row}"
1221 }
1222
1223 // Description returns the semantic convention description of the instrument
1224 func (ClientResponseReturnedRows) Description() string {
1225 return "The actual number of records returned by the database operation."
1226 }
1227
1228 // Record records val to the current distribution.
1229 //
1230 // The systemName is the the database management system (DBMS) product as
1231 // identified by the client instrumentation.
1232 //
1233 // All additional attrs passed are included in the recorded value.
1234 func (m ClientResponseReturnedRows) Record(
1235 ctx context.Context,
1236 val int64,
1237 systemName SystemNameAttr,
1238 attrs ...attribute.KeyValue,
1239 ) {
1240 o := recOptPool.Get().(*[]metric.RecordOption)
1241 defer func() {
1242 *o = (*o)[:0]
1243 recOptPool.Put(o)
1244 }()
1245
1246 *o = append(
1247 *o,
1248 metric.WithAttributes(
1249 append(
1250 attrs,
1251 attribute.String("db.system.name", string(systemName)),
1252 )...,
1253 ),
1254 )
1255
1256 m.Int64Histogram.Record(ctx, val, *o...)
1257 }
1258
1259 // AttrCollectionName returns an optional attribute for the "db.collection.name"
1260 // semantic convention. It represents the name of a collection (table, container)
1261 // within the database.
1262 func (ClientResponseReturnedRows) AttrCollectionName(val string) attribute.KeyValue {
1263 return attribute.String("db.collection.name", val)
1264 }
1265
1266 // AttrNamespace returns an optional attribute for the "db.namespace" semantic
1267 // convention. It represents the name of the database, fully qualified within the
1268 // server address and port.
1269 func (ClientResponseReturnedRows) AttrNamespace(val string) attribute.KeyValue {
1270 return attribute.String("db.namespace", val)
1271 }
1272
1273 // AttrOperationName returns an optional attribute for the "db.operation.name"
1274 // semantic convention. It represents the name of the operation or command being
1275 // executed.
1276 func (ClientResponseReturnedRows) AttrOperationName(val string) attribute.KeyValue {
1277 return attribute.String("db.operation.name", val)
1278 }
1279
1280 // AttrResponseStatusCode returns an optional attribute for the
1281 // "db.response.status_code" semantic convention. It represents the database
1282 // response status code.
1283 func (ClientResponseReturnedRows) AttrResponseStatusCode(val string) attribute.KeyValue {
1284 return attribute.String("db.response.status_code", val)
1285 }
1286
1287 // AttrErrorType returns an optional attribute for the "error.type" semantic
1288 // convention. It represents the describes a class of error the operation ended
1289 // with.
1290 func (ClientResponseReturnedRows) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1291 return attribute.String("error.type", string(val))
1292 }
1293
1294 // AttrServerPort returns an optional attribute for the "server.port" semantic
1295 // convention. It represents the server port number.
1296 func (ClientResponseReturnedRows) AttrServerPort(val int) attribute.KeyValue {
1297 return attribute.Int("server.port", val)
1298 }
1299
1300 // AttrQuerySummary returns an optional attribute for the "db.query.summary"
1301 // semantic convention. It represents the low cardinality representation of a
1302 // database query text.
1303 func (ClientResponseReturnedRows) AttrQuerySummary(val string) attribute.KeyValue {
1304 return attribute.String("db.query.summary", val)
1305 }
1306
1307 // AttrNetworkPeerAddress returns an optional attribute for the
1308 // "network.peer.address" semantic convention. It represents the peer address of
1309 // the database node where the operation was performed.
1310 func (ClientResponseReturnedRows) AttrNetworkPeerAddress(val string) attribute.KeyValue {
1311 return attribute.String("network.peer.address", val)
1312 }
1313
1314 // AttrNetworkPeerPort returns an optional attribute for the "network.peer.port"
1315 // semantic convention. It represents the peer port number of the network
1316 // connection.
1317 func (ClientResponseReturnedRows) AttrNetworkPeerPort(val int) attribute.KeyValue {
1318 return attribute.Int("network.peer.port", val)
1319 }
1320
1321 // AttrServerAddress returns an optional attribute for the "server.address"
1322 // semantic convention. It represents the name of the database host.
1323 func (ClientResponseReturnedRows) AttrServerAddress(val string) attribute.KeyValue {
1324 return attribute.String("server.address", val)
1325 }
1326
1327 // AttrQueryText returns an optional attribute for the "db.query.text" semantic
1328 // convention. It represents the database query being executed.
1329 func (ClientResponseReturnedRows) AttrQueryText(val string) attribute.KeyValue {
1330 return attribute.String("db.query.text", val)
1331 }