mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 23:12:25 -05:00 
			
		
		
		
	[chore] Update a bunch of database dependencies (#1772)
* [chore] Update a bunch of database dependencies * fix lil thing
This commit is contained in:
		
					parent
					
						
							
								66df974143
							
						
					
				
			
			
				commit
				
					
						ec325fee14
					
				
			
		
					 402 changed files with 35068 additions and 35401 deletions
				
			
		
							
								
								
									
										21
									
								
								vendor/github.com/uptrace/bun/CHANGELOG.md
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/uptrace/bun/CHANGELOG.md
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -1,3 +1,24 @@ | |||
| ## [1.1.13](https://github.com/uptrace/bun/compare/v1.1.12...v1.1.13) (2023-05-06) | ||||
| 
 | ||||
| 
 | ||||
| ### Bug Fixes | ||||
| 
 | ||||
| * bunbig.Int.Scan typo ([7ddabb8](https://github.com/uptrace/bun/commit/7ddabb8c667f50032bc0bb2523a287efbe0851e7)) | ||||
| * compare full MySQL version ([096fabe](https://github.com/uptrace/bun/commit/096fabefa114202d3601ad8e456f5e491a4e3787)) | ||||
| * enable delete table alias for MySQL >= 8.0.16 ([77a600b](https://github.com/uptrace/bun/commit/77a600bc060154fb91aa68e68ba6a8875e5b10fb)) | ||||
| * incorrect table relationship panic message [#791](https://github.com/uptrace/bun/issues/791) ([ad41888](https://github.com/uptrace/bun/commit/ad4188862eeaab30fc7c48d3224b5a786557aec5)) | ||||
| * should rollback if migrate using transaction and got an err (thanks [@bayshark](https://github.com/bayshark)) ([e7a119b](https://github.com/uptrace/bun/commit/e7a119b1b8911d8bf059bb271c90ad4a5f5f02be)) | ||||
| 
 | ||||
| 
 | ||||
| ### Features | ||||
| 
 | ||||
| * add option to customize Go migration template ([f31bf73](https://github.com/uptrace/bun/commit/f31bf739b9c7a0383411b9e67cba96c858795c68)) | ||||
| * expose Exec(…) method for RawQuery ([11192c8](https://github.com/uptrace/bun/commit/11192c83f932eb7421ef09e06859a7f171de7803)) | ||||
| * prefix migration files with 1 upto 14 digits ([b74b671](https://github.com/uptrace/bun/commit/b74b6714bb6a83e470e21801c97cc40e20acfb50)) | ||||
| * rename option ([9353a3f](https://github.com/uptrace/bun/commit/9353a3f921c038fdf4a90665f1b0a9d0d03dc182)) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ## [1.1.12](https://github.com/uptrace/bun/compare/v1.1.11...v1.1.12) (2023-02-20) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										3
									
								
								vendor/github.com/uptrace/bun/dialect/pgdialect/append.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/uptrace/bun/dialect/pgdialect/append.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -122,7 +122,8 @@ func (d *Dialect) arrayAppender(typ reflect.Type) schema.AppenderFunc { | |||
| 		b = append(b, '\'') | ||||
| 
 | ||||
| 		b = append(b, '{') | ||||
| 		for i := 0; i < v.Len(); i++ { | ||||
| 		ln := v.Len() | ||||
| 		for i := 0; i < ln; i++ { | ||||
| 			elem := v.Index(i) | ||||
| 			b = appendElem(fmter, b, elem) | ||||
| 			b = append(b, ',') | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/dialect/pgdialect/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/dialect/pgdialect/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -2,5 +2,5 @@ package pgdialect | |||
| 
 | ||||
| // Version is the current release version. | ||||
| func Version() string { | ||||
| 	return "1.1.12" | ||||
| 	return "1.1.13" | ||||
| } | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -2,5 +2,5 @@ package sqlitedialect | |||
| 
 | ||||
| // Version is the current release version. | ||||
| func Version() string { | ||||
| 	return "1.1.12" | ||||
| 	return "1.1.13" | ||||
| } | ||||
|  |  | |||
							
								
								
									
										4
									
								
								vendor/github.com/uptrace/bun/extra/bunotel/otel.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/uptrace/bun/extra/bunotel/otel.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -10,6 +10,7 @@ import ( | |||
| 	"go.opentelemetry.io/otel" | ||||
| 	"go.opentelemetry.io/otel/attribute" | ||||
| 	"go.opentelemetry.io/otel/codes" | ||||
| 	"go.opentelemetry.io/otel/metric" | ||||
| 	"go.opentelemetry.io/otel/metric/global" | ||||
| 	"go.opentelemetry.io/otel/metric/instrument" | ||||
| 	semconv "go.opentelemetry.io/otel/semconv/v1.12.0" | ||||
|  | @ -75,7 +76,8 @@ func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	queryHistogram.Record(ctx, time.Since(event.StartTime).Milliseconds(), labels...) | ||||
| 	dur := time.Since(event.StartTime) | ||||
| 	queryHistogram.Record(ctx, dur.Milliseconds(), metric.WithAttributes(labels...)) | ||||
| 
 | ||||
| 	span := trace.SpanFromContext(ctx) | ||||
| 	if !span.IsRecording() { | ||||
|  |  | |||
							
								
								
									
										12
									
								
								vendor/github.com/uptrace/bun/migrate/migration.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/uptrace/bun/migrate/migration.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -97,10 +97,15 @@ func Exec(ctx context.Context, db *bun.DB, f io.Reader, isTx bool) error { | |||
| 	} | ||||
| 
 | ||||
| 	var retErr error | ||||
| 	var execErr error | ||||
| 
 | ||||
| 	defer func() { | ||||
| 		if tx, ok := idb.(bun.Tx); ok { | ||||
| 			retErr = tx.Commit() | ||||
| 			if execErr != nil { | ||||
| 				retErr = tx.Rollback() | ||||
| 			} else { | ||||
| 				retErr = tx.Commit() | ||||
| 			} | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
|  | @ -113,8 +118,9 @@ func Exec(ctx context.Context, db *bun.DB, f io.Reader, isTx bool) error { | |||
| 	}() | ||||
| 
 | ||||
| 	for _, q := range queries { | ||||
| 		if _, err := idb.ExecContext(ctx, q); err != nil { | ||||
| 			return err | ||||
| 		_, execErr = idb.ExecContext(ctx, q) | ||||
| 		if execErr != nil { | ||||
| 			return execErr | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/migrate/migrations.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/migrate/migrations.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -157,7 +157,7 @@ func migrationFile() string { | |||
| 	return "" | ||||
| } | ||||
| 
 | ||||
| var fnameRE = regexp.MustCompile(`^(\d{14})_([0-9a-z_\-]+)\.`) | ||||
| var fnameRE = regexp.MustCompile(`^(\d{1,14})_([0-9a-z_\-]+)\.`) | ||||
| 
 | ||||
| func extractMigrationName(fpath string) (string, string, error) { | ||||
| 	fname := filepath.Base(fpath) | ||||
|  |  | |||
							
								
								
									
										10
									
								
								vendor/github.com/uptrace/bun/migrate/migrator.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/uptrace/bun/migrate/migrator.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -217,6 +217,7 @@ func (m *Migrator) Rollback(ctx context.Context, opts ...MigrationOption) (*Migr | |||
| 
 | ||||
| type goMigrationConfig struct { | ||||
| 	packageName string | ||||
| 	goTemplate  string | ||||
| } | ||||
| 
 | ||||
| type GoMigrationOption func(cfg *goMigrationConfig) | ||||
|  | @ -227,12 +228,19 @@ func WithPackageName(name string) GoMigrationOption { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| func WithGoTemplate(template string) GoMigrationOption { | ||||
| 	return func(cfg *goMigrationConfig) { | ||||
| 		cfg.goTemplate = template | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // CreateGoMigration creates a Go migration file. | ||||
| func (m *Migrator) CreateGoMigration( | ||||
| 	ctx context.Context, name string, opts ...GoMigrationOption, | ||||
| ) (*MigrationFile, error) { | ||||
| 	cfg := &goMigrationConfig{ | ||||
| 		packageName: "migrations", | ||||
| 		goTemplate:  goTemplate, | ||||
| 	} | ||||
| 	for _, opt := range opts { | ||||
| 		opt(cfg) | ||||
|  | @ -245,7 +253,7 @@ func (m *Migrator) CreateGoMigration( | |||
| 
 | ||||
| 	fname := name + ".go" | ||||
| 	fpath := filepath.Join(m.migrations.getDirectory(), fname) | ||||
| 	content := fmt.Sprintf(goTemplate, cfg.packageName) | ||||
| 	content := fmt.Sprintf(cfg.goTemplate, cfg.packageName) | ||||
| 
 | ||||
| 	if err := ioutil.WriteFile(fpath, []byte(content), 0o644); err != nil { | ||||
| 		return nil, err | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/model.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/model.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -101,7 +101,7 @@ func _newModel(db *DB, dest interface{}, scan bool) (Model, error) { | |||
| 		if typ.Kind() == reflect.Struct { | ||||
| 			return newStructTableModel(db, dest, db.Table(typ)), nil | ||||
| 		} | ||||
| 		return nil, fmt.Errorf("bun: Model(nil %T)", dest) | ||||
| 		return nil, fmt.Errorf("bun: Model(nil %s %T)", typ.Kind(), dest) | ||||
| 	} | ||||
| 
 | ||||
| 	v = v.Elem() | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/package.json
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/package.json
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -1,6 +1,6 @@ | |||
| { | ||||
|   "name": "gobun", | ||||
|   "version": "1.1.12", | ||||
|   "version": "1.1.13", | ||||
|   "main": "index.js", | ||||
|   "repository": "git@github.com:uptrace/bun.git", | ||||
|   "author": "Vladimir Mihailenco <vladimir.webdev@gmail.com>", | ||||
|  |  | |||
							
								
								
									
										19
									
								
								vendor/github.com/uptrace/bun/query_base.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/uptrace/bun/query_base.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -180,13 +180,13 @@ func (q *baseQuery) setErr(err error) { | |||
| } | ||||
| 
 | ||||
| func (q *baseQuery) getModel(dest []interface{}) (Model, error) { | ||||
| 	if len(dest) == 0 { | ||||
| 		if q.model != nil { | ||||
| 			return q.model, nil | ||||
| 		} | ||||
| 		return nil, errNilModel | ||||
| 	if len(dest) > 0 { | ||||
| 		return newModel(q.db, dest) | ||||
| 	} | ||||
| 	return newModel(q.db, dest) | ||||
| 	if q.model != nil { | ||||
| 		return q.model, nil | ||||
| 	} | ||||
| 	return nil, errNilModel | ||||
| } | ||||
| 
 | ||||
| func (q *baseQuery) beforeAppendModel(ctx context.Context, query Query) error { | ||||
|  | @ -1054,7 +1054,12 @@ type customValueQuery struct { | |||
| func (q *customValueQuery) addValue( | ||||
| 	table *schema.Table, column string, value string, args []interface{}, | ||||
| ) { | ||||
| 	if _, ok := table.FieldMap[column]; ok { | ||||
| 	ok := false | ||||
| 	if table != nil { | ||||
| 		_, ok = table.FieldMap[column] | ||||
| 	} | ||||
| 
 | ||||
| 	if ok { | ||||
| 		if q.modelValues == nil { | ||||
| 			q.modelValues = make(map[string]schema.QueryWithArgs) | ||||
| 		} | ||||
|  |  | |||
							
								
								
									
										40
									
								
								vendor/github.com/uptrace/bun/query_raw.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								vendor/github.com/uptrace/bun/query_raw.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -2,6 +2,7 @@ package bun | |||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"database/sql" | ||||
| 
 | ||||
| 	"github.com/uptrace/bun/schema" | ||||
| ) | ||||
|  | @ -46,19 +47,46 @@ func (q *RawQuery) Err(err error) *RawQuery { | |||
| 	return q | ||||
| } | ||||
| 
 | ||||
| func (q *RawQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) { | ||||
| 	return q.scanOrExec(ctx, dest, len(dest) > 0) | ||||
| } | ||||
| 
 | ||||
| func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error { | ||||
| 	_, err := q.scanOrExec(ctx, dest, true) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (q *RawQuery) scanOrExec( | ||||
| 	ctx context.Context, dest []interface{}, hasDest bool, | ||||
| ) (sql.Result, error) { | ||||
| 	if q.err != nil { | ||||
| 		return q.err | ||||
| 		return nil, q.err | ||||
| 	} | ||||
| 
 | ||||
| 	model, err := q.getModel(dest) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	var model Model | ||||
| 	var err error | ||||
| 
 | ||||
| 	if hasDest { | ||||
| 		model, err = q.getModel(dest) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	query := q.db.format(q.query, q.args) | ||||
| 	_, err = q.scan(ctx, q, query, model, true) | ||||
| 	return err | ||||
| 	var res sql.Result | ||||
| 
 | ||||
| 	if hasDest { | ||||
| 		res, err = q.scan(ctx, q, query, model, hasDest) | ||||
| 	} else { | ||||
| 		res, err = q.exec(ctx, q, query) | ||||
| 	} | ||||
| 
 | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return res, nil | ||||
| } | ||||
| 
 | ||||
| func (q *RawQuery) AppendQuery(fmter schema.Formatter, b []byte) ([]byte, error) { | ||||
|  |  | |||
							
								
								
									
										5
									
								
								vendor/github.com/uptrace/bun/schema/append.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/uptrace/bun/schema/append.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -79,6 +79,11 @@ func (in *inValues) AppendQuery(fmter Formatter, b []byte) (_ []byte, err error) | |||
| 
 | ||||
| func appendIn(fmter Formatter, b []byte, slice reflect.Value) []byte { | ||||
| 	sliceLen := slice.Len() | ||||
| 
 | ||||
| 	if sliceLen == 0 { | ||||
| 		return append(b, "NULL"...) | ||||
| 	} | ||||
| 
 | ||||
| 	for i := 0; i < sliceLen; i++ { | ||||
| 		if i > 0 { | ||||
| 			b = append(b, ", "...) | ||||
|  |  | |||
							
								
								
									
										8
									
								
								vendor/github.com/uptrace/bun/schema/table.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/uptrace/bun/schema/table.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -534,7 +534,7 @@ func (t *Table) belongsToRelation(field *Field) *Relation { | |||
| 			} else { | ||||
| 				panic(fmt.Errorf( | ||||
| 					"bun: %s belongs-to %s: %s must have column %s", | ||||
| 					t.TypeName, field.GoName, t.TypeName, baseColumn, | ||||
| 					t.TypeName, field.GoName, joinTable.TypeName, joinColumn, | ||||
| 				)) | ||||
| 			} | ||||
| 		} | ||||
|  | @ -588,7 +588,7 @@ func (t *Table) hasOneRelation(field *Field) *Relation { | |||
| 			} else { | ||||
| 				panic(fmt.Errorf( | ||||
| 					"bun: %s has-one %s: %s must have column %s", | ||||
| 					field.GoName, t.TypeName, joinTable.TypeName, baseColumn, | ||||
| 					field.GoName, t.TypeName, t.TypeName, baseColumn, | ||||
| 				)) | ||||
| 			} | ||||
| 
 | ||||
|  | @ -598,7 +598,7 @@ func (t *Table) hasOneRelation(field *Field) *Relation { | |||
| 			} else { | ||||
| 				panic(fmt.Errorf( | ||||
| 					"bun: %s has-one %s: %s must have column %s", | ||||
| 					field.GoName, t.TypeName, joinTable.TypeName, baseColumn, | ||||
| 					field.GoName, t.TypeName, joinTable.TypeName, joinColumn, | ||||
| 				)) | ||||
| 			} | ||||
| 		} | ||||
|  | @ -677,7 +677,7 @@ func (t *Table) hasManyRelation(field *Field) *Relation { | |||
| 			} else { | ||||
| 				panic(fmt.Errorf( | ||||
| 					"bun: %s has-many %s: %s must have column %s", | ||||
| 					t.TypeName, field.GoName, t.TypeName, baseColumn, | ||||
| 					t.TypeName, field.GoName, joinTable.TypeName, joinColumn, | ||||
| 				)) | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/bun/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/bun/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -2,5 +2,5 @@ package bun | |||
| 
 | ||||
| // Version is the current release version. | ||||
| func Version() string { | ||||
| 	return "1.1.12" | ||||
| 	return "1.1.13" | ||||
| } | ||||
|  |  | |||
							
								
								
									
										47
									
								
								vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										47
									
								
								vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -12,7 +12,6 @@ import ( | |||
| 	"go.opentelemetry.io/otel/codes" | ||||
| 	"go.opentelemetry.io/otel/metric" | ||||
| 	"go.opentelemetry.io/otel/metric/global" | ||||
| 	"go.opentelemetry.io/otel/metric/instrument" | ||||
| 	semconv "go.opentelemetry.io/otel/semconv/v1.10.0" | ||||
| 	"go.opentelemetry.io/otel/trace" | ||||
| ) | ||||
|  | @ -54,7 +53,7 @@ func (c *config) formatQuery(query string) string { | |||
| type dbInstrum struct { | ||||
| 	*config | ||||
| 
 | ||||
| 	queryHistogram instrument.Int64Histogram | ||||
| 	queryHistogram metric.Int64Histogram | ||||
| } | ||||
| 
 | ||||
| func newDBInstrum(opts []Option) *dbInstrum { | ||||
|  | @ -72,8 +71,8 @@ func newDBInstrum(opts []Option) *dbInstrum { | |||
| 	var err error | ||||
| 	t.queryHistogram, err = t.meter.Int64Histogram( | ||||
| 		"go.sql.query_timing", | ||||
| 		instrument.WithDescription("Timing of processed queries"), | ||||
| 		instrument.WithUnit("milliseconds"), | ||||
| 		metric.WithDescription("Timing of processed queries"), | ||||
| 		metric.WithUnit("milliseconds"), | ||||
| 	) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
|  | @ -106,7 +105,7 @@ func (t *dbInstrum) withSpan( | |||
| 	span.End() | ||||
| 
 | ||||
| 	if query != "" { | ||||
| 		t.queryHistogram.Record(ctx, time.Since(startTime).Milliseconds(), t.attrs...) | ||||
| 		t.queryHistogram.Record(ctx, time.Since(startTime).Milliseconds(), metric.WithAttributes(t.attrs...)) | ||||
| 	} | ||||
| 
 | ||||
| 	if !span.IsRecording() { | ||||
|  | @ -185,57 +184,57 @@ func ReportDBStatsMetrics(db *sql.DB, opts ...Option) { | |||
| 
 | ||||
| 	maxOpenConns, _ := meter.Int64ObservableGauge( | ||||
| 		"go.sql.connections_max_open", | ||||
| 		instrument.WithDescription("Maximum number of open connections to the database"), | ||||
| 		metric.WithDescription("Maximum number of open connections to the database"), | ||||
| 	) | ||||
| 	openConns, _ := meter.Int64ObservableGauge( | ||||
| 		"go.sql.connections_open", | ||||
| 		instrument.WithDescription("The number of established connections both in use and idle"), | ||||
| 		metric.WithDescription("The number of established connections both in use and idle"), | ||||
| 	) | ||||
| 	inUseConns, _ := meter.Int64ObservableGauge( | ||||
| 		"go.sql.connections_in_use", | ||||
| 		instrument.WithDescription("The number of connections currently in use"), | ||||
| 		metric.WithDescription("The number of connections currently in use"), | ||||
| 	) | ||||
| 	idleConns, _ := meter.Int64ObservableGauge( | ||||
| 		"go.sql.connections_idle", | ||||
| 		instrument.WithDescription("The number of idle connections"), | ||||
| 		metric.WithDescription("The number of idle connections"), | ||||
| 	) | ||||
| 	connsWaitCount, _ := meter.Int64ObservableCounter( | ||||
| 		"go.sql.connections_wait_count", | ||||
| 		instrument.WithDescription("The total number of connections waited for"), | ||||
| 		metric.WithDescription("The total number of connections waited for"), | ||||
| 	) | ||||
| 	connsWaitDuration, _ := meter.Int64ObservableCounter( | ||||
| 		"go.sql.connections_wait_duration", | ||||
| 		instrument.WithDescription("The total time blocked waiting for a new connection"), | ||||
| 		instrument.WithUnit("nanoseconds"), | ||||
| 		metric.WithDescription("The total time blocked waiting for a new connection"), | ||||
| 		metric.WithUnit("nanoseconds"), | ||||
| 	) | ||||
| 	connsClosedMaxIdle, _ := meter.Int64ObservableCounter( | ||||
| 		"go.sql.connections_closed_max_idle", | ||||
| 		instrument.WithDescription("The total number of connections closed due to SetMaxIdleConns"), | ||||
| 		metric.WithDescription("The total number of connections closed due to SetMaxIdleConns"), | ||||
| 	) | ||||
| 	connsClosedMaxIdleTime, _ := meter.Int64ObservableCounter( | ||||
| 		"go.sql.connections_closed_max_idle_time", | ||||
| 		instrument.WithDescription("The total number of connections closed due to SetConnMaxIdleTime"), | ||||
| 		metric.WithDescription("The total number of connections closed due to SetConnMaxIdleTime"), | ||||
| 	) | ||||
| 	connsClosedMaxLifetime, _ := meter.Int64ObservableCounter( | ||||
| 		"go.sql.connections_closed_max_lifetime", | ||||
| 		instrument.WithDescription("The total number of connections closed due to SetConnMaxLifetime"), | ||||
| 		metric.WithDescription("The total number of connections closed due to SetConnMaxLifetime"), | ||||
| 	) | ||||
| 
 | ||||
| 	if _, err := meter.RegisterCallback( | ||||
| 		func(ctx context.Context, o metric.Observer) error { | ||||
| 			stats := db.Stats() | ||||
| 
 | ||||
| 			o.ObserveInt64(maxOpenConns, int64(stats.MaxOpenConnections), labels...) | ||||
| 			o.ObserveInt64(maxOpenConns, int64(stats.MaxOpenConnections), metric.WithAttributes(labels...)) | ||||
| 
 | ||||
| 			o.ObserveInt64(openConns, int64(stats.OpenConnections), labels...) | ||||
| 			o.ObserveInt64(inUseConns, int64(stats.InUse), labels...) | ||||
| 			o.ObserveInt64(idleConns, int64(stats.Idle), labels...) | ||||
| 			o.ObserveInt64(openConns, int64(stats.OpenConnections), metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(inUseConns, int64(stats.InUse), metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(idleConns, int64(stats.Idle), metric.WithAttributes(labels...)) | ||||
| 
 | ||||
| 			o.ObserveInt64(connsWaitCount, stats.WaitCount, labels...) | ||||
| 			o.ObserveInt64(connsWaitDuration, int64(stats.WaitDuration), labels...) | ||||
| 			o.ObserveInt64(connsClosedMaxIdle, stats.MaxIdleClosed, labels...) | ||||
| 			o.ObserveInt64(connsClosedMaxIdleTime, stats.MaxIdleTimeClosed, labels...) | ||||
| 			o.ObserveInt64(connsClosedMaxLifetime, stats.MaxLifetimeClosed, labels...) | ||||
| 			o.ObserveInt64(connsWaitCount, stats.WaitCount, metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(connsWaitDuration, int64(stats.WaitDuration), metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(connsClosedMaxIdle, stats.MaxIdleClosed, metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(connsClosedMaxIdleTime, stats.MaxIdleTimeClosed, metric.WithAttributes(labels...)) | ||||
| 			o.ObserveInt64(connsClosedMaxLifetime, stats.MaxLifetimeClosed, metric.WithAttributes(labels...)) | ||||
| 
 | ||||
| 			return nil | ||||
| 		}, | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -2,5 +2,5 @@ package otelsql | |||
| 
 | ||||
| // Version is the current release version. | ||||
| func Version() string { | ||||
| 	return "0.1.21" | ||||
| 	return "0.2.0" | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue