[FEATURE] memory usage #82

Closed
opened 2024-09-16 15:32:23 +03:00 by vtolstov · 1 comment
Owner
Total: 33.80GB
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).BeginTx in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
   68.01MB   452.09MB (flat, cum)  1.31% of Total
         .          .    101:func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
         .    27.01MB    102:	name := getQueryName(ctx)
       8MB   232.05MB    103:	nctx, span := w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
       4MB        9MB    104:	span.AddLabels("db.method", "BeginTx")
    7.50MB       15MB    105:	span.AddLabels("db.statement", name)
         .          .    106:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
       6MB    21.50MB    107:		span.AddLabels("x-request-id", id)
         .          .    108:	}
       7MB        7MB    109:	labels := []string{labelMethod, "BeginTx", labelQuery, name}
         .          .    110:
         .          .    111:	connBeginTx, ok := w.conn.(driver.ConnBeginTx)
         .          .    112:	if !ok {
         .          .    113:		return w.Begin()
         .          .    114:	}
         .          .    115:
         .          .    116:	ts := time.Now()
         .    12.01MB    117:	tx, err := connBeginTx.BeginTx(nctx, opts)
         .          .    118:	td := time.Since(ts)
         .          .    119:	te := td.Seconds()
         .          .    120:	if err != nil {
         .          .    121:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    122:		w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .          .    123:		w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    124:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    125:		if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    126:			w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
         .          .    127:		}
         .          .    128:		return nil, err
         .          .    129:	}
      13MB   106.02MB    130:	w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    131:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    132:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
         .          .    133:	}
   22.50MB    22.50MB    134:	return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx, span: span}, nil
         .          .    135:}
         .          .    136:
         .          .    137:// Prepare implements driver.Conn Prepare
         .          .    138:func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) {
         .          .    139:	var ctx context.Context
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).Close in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
         0   512.12kB (flat, cum) 0.0014% of Total
         .          .     39:func (w *wrapperConn) Close() error {
         .          .     40:	var ctx context.Context
         .          .     41:	if w.ctx != nil {
         .          .     42:		ctx = w.ctx
         .          .     43:	} else {
         .          .     44:		ctx = context.Background()
         .          .     45:	}
         .          .     46:
         .          .     47:	labels := []string{labelMethod, "Close"}
         .          .     48:	ts := time.Now()
         .          .     49:	err := w.conn.Close()
         .          .     50:	td := time.Since(ts)
         .          .     51:	te := td.Seconds()
         .          .     52:	if err != nil {
         .          .     53:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .     54:	} else {
         .          .     55:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .     56:	}
         .   512.12kB     57:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .          .     58:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .     59:
         .          .     60:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     61:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...)
         .          .     62:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).ExecContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
   66.01MB     3.66GB (flat, cum) 10.82% of Total
         .          .    251:func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
         .          .    252:	var nctx context.Context
         .          .    253:	var span tracer.Span
         .          .    254:
         .          .    255:	name := getQueryName(ctx)
         .          .    256:	if w.ctx != nil {
         .          .    257:		nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    258:	} else {
    5.50MB   205.03MB    259:		nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    260:	}
    4.50MB     7.50MB    261:	span.AddLabels("db.method", "ExecContext")
       6MB       17MB    262:	span.AddLabels("db.statement", name)
         .          .    263:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
    6.50MB       21MB    264:		span.AddLabels("x-request-id", id)
         .          .    265:	}
         .          .    266:	defer span.Finish()
         .          .    267:	if len(args) > 0 {
       5MB   540.90MB    268:		span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args)))
         .          .    269:	}
       7MB        7MB    270:	labels := []string{labelMethod, "ExecContext", labelQuery, name}
         .          .    271:
         .          .    272:	conn, ok := w.conn.(driver.ExecerContext)
         .          .    273:	if !ok {
         .          .    274:		// nolint:staticcheck
         .          .    275:		return nil, driver.ErrSkip
         .          .    276:	}
         .          .    277:
         .          .    278:	ts := time.Now()
         .     2.48GB    279:	res, err := conn.ExecContext(nctx, query, args)
         .          .    280:	td := time.Since(ts)
         .          .    281:	te := td.Seconds()
         .          .    282:	if err != nil {
         .          .    283:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    284:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    285:	} else {
      15MB    87.51MB    286:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    287:	}
   16.50MB    98.02MB    288:	w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .    70.51MB    289:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .    79.01MB    290:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    291:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    292:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", getCallerName(), td, err)...)
         .          .    293:	}
         .          .    294:
         .    69.51MB    295:	return res, err
         .          .    296:}
         .          .    297:
         .          .    298:// Ping implements driver.Pinger Ping
         .          .    299:func (w *wrapperConn) Ping(ctx context.Context) error {
         .          .    300:	conn, ok := w.conn.(driver.Pinger)
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).QueryContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
  298.52MB    18.36GB (flat, cum) 54.32% of Total
         .          .    374:func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
         .          .    375:	var nctx context.Context
         .          .    376:	var span tracer.Span
         .          .    377:
         .          .    378:	name := getQueryName(ctx)
         .          .    379:	if w.ctx != nil {
         .          .    380:		nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    381:	} else {
   45.50MB     1.22GB    382:		nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    383:	}
      20MB    36.50MB    384:	span.AddLabels("db.method", "QueryContext")
   32.50MB    72.50MB    385:	span.AddLabels("db.statement", name)
         .          .    386:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
      39MB   136.01MB    387:		span.AddLabels("x-request-id", id)
         .          .    388:	}
         .          .    389:	defer span.Finish()
         .          .    390:	if len(args) > 0 {
   44.50MB   226.51MB    391:		span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args)))
         .          .    392:	}
      40MB       40MB    393:	labels := []string{labelMethod, "QueryContext", labelQuery, name}
         .          .    394:	conn, ok := w.conn.(driver.QueryerContext)
         .          .    395:	if !ok {
         .          .    396:		return nil, driver.ErrSkip
         .          .    397:	}
         .          .    398:
         .          .    399:	ts := time.Now()
         .    14.96GB    400:	rows, err := conn.QueryContext(nctx, query, args)
         .          .    401:	td := time.Since(ts)
         .          .    402:	te := td.Seconds()
         .          .    403:	if err != nil {
         .          .    404:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    405:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    406:	} else {
   77.01MB   503.58MB    407:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    408:	}
         .   411.57MB    409:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .   409.07MB    410:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    411:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    412:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", getCallerName(), td, err)...)
         .          .    413:	}
         .          .    414:
         .   393.07MB    415:	return rows, err
         .          .    416:}
         .          .    417:
         .          .    418:// CheckNamedValue implements driver.NamedValueChecker
         .          .    419:func (w *wrapperConn) CheckNamedValue(v *driver.NamedValue) error {
         .          .    420:	s, ok := w.conn.(driver.NamedValueChecker)
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperDriver).Open in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/driver.go
         0     5.52MB (flat, cum) 0.016% of Total
         .          .     66:func (w *wrapperDriver) Open(name string) (driver.Conn, error) {
         .          .     67:	// ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Ensure eventual timeout
         .          .     68:	// defer cancel()
         .          .     69:
         .          .     70:	/*
         .          .     71:		connector, err := w.OpenConnector(name)
         .          .     72:		if err != nil {
         .          .     73:			return nil, err
         .          .     74:		}
         .          .     75:		return connector.Connect(ctx)
         .          .     76:	*/
         .          .     77:
         .          .     78:	ts := time.Now()
         .     5.52MB     79:	c, err := w.driver.Open(name)
         .          .     80:	td := time.Since(ts)
         .          .     81:
         .          .     82:	if w.opts.LoggerEnabled {
         .          .     83:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Open", getCallerName(), td, err)...)
         .          .     84:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Commit in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go
         0    57.04MB (flat, cum)  0.16% of Total
         .          .     22:func (w *wrapperTx) Commit() error {
         .          .     23:	ts := time.Now()
         .     4.54MB     24:	err := w.tx.Commit()
         .          .     25:	td := time.Since(ts)
         .          .     26:
         .          .     27:	if w.span != nil {
         .          .     28:		if err != nil {
         .          .     29:			w.span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .     30:		}
         .    52.51MB     31:		w.span.Finish()
         .          .     32:	}
         .          .     33:
         .          .     34:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     35:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Commit", getCallerName(), td, err)...)
         .          .     36:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Rollback in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go
         0    13.51MB (flat, cum) 0.039% of Total
         .          .     44:func (w *wrapperTx) Rollback() error {
         .          .     45:	ts := time.Now()
         .     1.51MB     46:	err := w.tx.Rollback()
         .          .     47:	td := time.Since(ts)
         .          .     48:
         .          .     49:	if w.span != nil {
         .          .     50:		if err != nil {
         .          .     51:			w.span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .     52:		}
         .       12MB     53:		w.span.Finish()
         .          .     54:	}
         .          .     55:
         .          .     56:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     57:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Rollback", getCallerName(), td, err)...)
         .          .     58:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.NewStatsMeter.func1 in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/stats.go
         0        2MB (flat, cum) 0.0058% of Total
         .          .     16:	go func() {
         .          .     17:		ticker := time.NewTicker(options.MeterStatsInterval)
         .          .     18:		defer ticker.Stop()
         .          .     19:
         .          .     20:		for {
         .          .     21:			select {
         .          .     22:			case <-ctx.Done():
         .          .     23:				return
         .          .     24:			case <-ticker.C:
         .          .     25:				if db == nil {
         .          .     26:					return
         .          .     27:				}
         .          .     28:				stats := db.Stats()
         .          .     29:				options.Meter.Counter(MaxOpenConnections).Set(uint64(stats.MaxOpenConnections))
         .          .     30:				options.Meter.Counter(OpenConnections).Set(uint64(stats.OpenConnections))
         .   512.01kB     31:				options.Meter.Counter(InuseConnections).Set(uint64(stats.InUse))
         .          .     32:				options.Meter.Counter(IdleConnections).Set(uint64(stats.Idle))
         .          .     33:				options.Meter.Counter(WaitConnections).Set(uint64(stats.WaitCount))
         .          .     34:				options.Meter.FloatCounter(BlockedSeconds).Set(stats.WaitDuration.Seconds())
         .          .     35:				options.Meter.Counter(MaxIdleClosed).Set(uint64(stats.MaxIdleClosed))
         .     1.50MB     36:				options.Meter.Counter(MaxIdletimeClosed).Set(uint64(stats.MaxIdleTimeClosed))
         .          .     37:				options.Meter.Counter(MaxLifetimeClosed).Set(uint64(stats.MaxLifetimeClosed))
         .          .     38:			}
         .          .     39:		}
         .          .     40:	}()
         .          .     41:}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.QueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go
      13MB       47MB (flat, cum)  0.14% of Total
         .          .    172:func QueryName(ctx context.Context, name string) context.Context {
         .          .    173:	if ctx == nil {
         .          .    174:		ctx = context.Background()
         .          .    175:	}
      13MB       47MB    176:	return context.WithValue(ctx, queryNameKey{}, name)
         .          .    177:}
         .          .    178:
         .          .    179:func getQueryName(ctx context.Context) string {
         .          .    180:	if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown {
         .          .    181:		return v
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getCallerName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go
   27.01MB    27.01MB (flat, cum) 0.078% of Total
         .          .     41:func getCallerName() string {
   27.01MB    27.01MB     42:	pc, _, _, ok := runtime.Caller(3)
         .          .     43:	details := runtime.FuncForPC(pc)
         .          .     44:	var callerName string
         .          .     45:	if ok && details != nil {
         .          .     46:		callerName = details.Name()
         .          .     47:	} else {
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getQueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go
         0    27.01MB (flat, cum) 0.078% of Total
         .          .    179:func getQueryName(ctx context.Context) string {
         .          .    180:	if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown {
         .          .    181:		return v
         .          .    182:	}
         .    27.01MB    183:	return getCallerName()
         .          .    184:}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.namedValueToLabels in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go
  216.05MB   463.44MB (flat, cum)  1.34% of Total
         .          .     26:func namedValueToLabels(named []driver.NamedValue) []interface{} {
  108.05MB   108.05MB     27:	largs := make([]interface{}, 0, len(named)*2)
         .          .     28:	var name string
         .          .     29:	for _, param := range named {
         .          .     30:		if param.Name != "" {
         .          .     31:			name = param.Name
         .          .     32:		} else {
         .    13.50MB     33:			name = fmt.Sprintf("$%d", param.Ordinal)
         .          .     34:		}
     108MB   341.89MB     35:		largs = append(largs, fmt.Sprintf("%s=%v", name, param.Value))
         .          .     36:	}
         .          .     37:	return largs
         .          .     38:}
         .          .     39:
         .          .     40:// getCallerName get the name of the function A where A() -> B() -> GetFunctionCallerName()
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) 
(pprof) list go.unistack.org/micro-wrapper-sql/v3                            
Total: 33.80GB
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).BeginTx in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
   68.01MB   452.09MB (flat, cum)  1.31% of Total
         .          .    101:func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
         .    27.01MB    102:	name := getQueryName(ctx)
       8MB   232.05MB    103:	nctx, span := w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
       4MB        9MB    104:	span.AddLabels("db.method", "BeginTx")
    7.50MB       15MB    105:	span.AddLabels("db.statement", name)
         .          .    106:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
       6MB    21.50MB    107:		span.AddLabels("x-request-id", id)
         .          .    108:	}
       7MB        7MB    109:	labels := []string{labelMethod, "BeginTx", labelQuery, name}
         .          .    110:
         .          .    111:	connBeginTx, ok := w.conn.(driver.ConnBeginTx)
         .          .    112:	if !ok {
         .          .    113:		return w.Begin()
         .          .    114:	}
         .          .    115:
         .          .    116:	ts := time.Now()
         .    12.01MB    117:	tx, err := connBeginTx.BeginTx(nctx, opts)
         .          .    118:	td := time.Since(ts)
         .          .    119:	te := td.Seconds()
         .          .    120:	if err != nil {
         .          .    121:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    122:		w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .          .    123:		w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    124:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    125:		if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    126:			w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
         .          .    127:		}
         .          .    128:		return nil, err
         .          .    129:	}
      13MB   106.02MB    130:	w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    131:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    132:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
         .          .    133:	}
   22.50MB    22.50MB    134:	return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx, span: span}, nil
         .          .    135:}
         .          .    136:
         .          .    137:// Prepare implements driver.Conn Prepare
         .          .    138:func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) {
         .          .    139:	var ctx context.Context
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).Close in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
         0   512.12kB (flat, cum) 0.0014% of Total
         .          .     39:func (w *wrapperConn) Close() error {
         .          .     40:	var ctx context.Context
         .          .     41:	if w.ctx != nil {
         .          .     42:		ctx = w.ctx
         .          .     43:	} else {
         .          .     44:		ctx = context.Background()
         .          .     45:	}
         .          .     46:
         .          .     47:	labels := []string{labelMethod, "Close"}
         .          .     48:	ts := time.Now()
         .          .     49:	err := w.conn.Close()
         .          .     50:	td := time.Since(ts)
         .          .     51:	te := td.Seconds()
         .          .     52:	if err != nil {
         .          .     53:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .     54:	} else {
         .          .     55:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .     56:	}
         .   512.12kB     57:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .          .     58:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .     59:
         .          .     60:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     61:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...)
         .          .     62:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).ExecContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
   66.01MB     3.66GB (flat, cum) 10.82% of Total
         .          .    251:func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
         .          .    252:	var nctx context.Context
         .          .    253:	var span tracer.Span
         .          .    254:
         .          .    255:	name := getQueryName(ctx)
         .          .    256:	if w.ctx != nil {
         .          .    257:		nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    258:	} else {
    5.50MB   205.03MB    259:			nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    260:	}
    4.50MB     7.50MB    261:	span.AddLabels("db.method", "ExecContext")
       6MB       17MB    262:	span.AddLabels("db.statement", name)
         .          .    263:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
    6.50MB       21MB    264:		span.AddLabels("x-request-id", id)
         .          .    265:	}
         .          .    266:	defer span.Finish()
         .          .    267:	if len(args) > 0 {
       5MB   540.90MB    268:		span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args)))
         .          .    269:	}
       7MB        7MB    270:	labels := []string{labelMethod, "ExecContext", labelQuery, name}
         .          .    271:
         .          .    272:	conn, ok := w.conn.(driver.ExecerContext)
         .          .    273:	if !ok {
         .          .    274:		// nolint:staticcheck
         .          .    275:		return nil, driver.ErrSkip
         .          .    276:	}
         .          .    277:
         .          .    278:	ts := time.Now()
         .     2.48GB    279:	res, err := conn.ExecContext(nctx, query, args)
         .          .    280:	td := time.Since(ts)
         .          .    281:	te := td.Seconds()
         .          .    282:	if err != nil {
         .          .    283:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    284:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    285:	} else {
      15MB    87.51MB    286:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    287:	}
   16.50MB    98.02MB    288:	w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .    70.51MB    289:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .    79.01MB    290:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    291:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    292:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", getCallerName(), td, err)...)
         .          .    293:	}
         .          .    294:
         .    69.51MB    295:	return res, err
         .          .    296:}
         .          .    297:
         .          .    298:// Ping implements driver.Pinger Ping
         .          .    299:func (w *wrapperConn) Ping(ctx context.Context) error {
         .          .    300:	conn, ok := w.conn.(driver.Pinger)
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).QueryContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go
  298.52MB    18.36GB (flat, cum) 54.32% of Total
         .          .    374:func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
         .          .    375:	var nctx context.Context
         .          .    376:	var span tracer.Span
         .          .    377:
         .          .    378:	name := getQueryName(ctx)
         .          .    379:	if w.ctx != nil {
         .          .    380:		nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    381:	} else {
   45.50MB     1.22GB    382:		nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
         .          .    383:	}
      20MB    36.50MB    384:	span.AddLabels("db.method", "QueryContext")
   32.50MB    72.50MB    385:	span.AddLabels("db.statement", name)
         .          .    386:	if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
      39MB   136.01MB    387:		span.AddLabels("x-request-id", id)
         .          .    388:	}
         .          .    389:	defer span.Finish()
         .          .    390:	if len(args) > 0 {
   44.50MB   226.51MB    391:		span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args)))
         .          .    392:	}
      40MB       40MB    393:	labels := []string{labelMethod, "QueryContext", labelQuery, name}
         .          .    394:	conn, ok := w.conn.(driver.QueryerContext)
         .          .    395:	if !ok {
         .          .    396:		return nil, driver.ErrSkip
         .          .    397:	}
         .          .    398:
         .          .    399:	ts := time.Now()
         .    14.96GB    400:	rows, err := conn.QueryContext(nctx, query, args)
         .          .    401:	td := time.Since(ts)
         .          .    402:	te := td.Seconds()
         .          .    403:	if err != nil {
         .          .    404:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
         .          .    405:		span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .    406:	} else {
   77.01MB   503.58MB    407:		w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
         .          .    408:	}
         .   411.57MB    409:	w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
         .   409.07MB    410:	w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
         .          .    411:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .    412:		w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", getCallerName(), td, err)...)
         .          .    413:	}
         .          .    414:
         .   393.07MB    415:	return rows, err
         .          .    416:}
         .          .    417:
         .          .    418:// CheckNamedValue implements driver.NamedValueChecker
         .          .    419:func (w *wrapperConn) CheckNamedValue(v *driver.NamedValue) error {
         .          .    420:	s, ok := w.conn.(driver.NamedValueChecker)
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperDriver).Open in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/driver.go
         0     5.52MB (flat, cum) 0.016% of Total
         .          .     66:func (w *wrapperDriver) Open(name string) (driver.Conn, error) {
         .          .     67:	// ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Ensure eventual timeout
         .          .     68:	// defer cancel()
         .          .     69:
         .          .     70:	/*
         .          .     71:		connector, err := w.OpenConnector(name)
         .          .     72:		if err != nil {
         .          .     73:			return nil, err
         .          .     74:		}
         .          .     75:		return connector.Connect(ctx)
         .          .     76:	*/
         .          .     77:
         .          .     78:	ts := time.Now()
         .     5.52MB     79:	c, err := w.driver.Open(name)
         .          .     80:	td := time.Since(ts)
         .          .     81:
         .          .     82:	if w.opts.LoggerEnabled {
         .          .     83:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Open", getCallerName(), td, err)...)
         .          .     84:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Commit in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go
         0    57.04MB (flat, cum)  0.16% of Total
         .          .     22:func (w *wrapperTx) Commit() error {
         .          .     23:	ts := time.Now()
         .     4.54MB     24:	err := w.tx.Commit()
         .          .     25:	td := time.Since(ts)
         .          .     26:
         .          .     27:	if w.span != nil {
         .          .     28:		if err != nil {
         .          .     29:			w.span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .     30:		}
         .    52.51MB     31:		w.span.Finish()
         .          .     32:	}
         .          .     33:
         .          .     34:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     35:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Commit", getCallerName(), td, err)...)
         .          .     36:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Rollback in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go
         0    13.51MB (flat, cum) 0.039% of Total
         .          .     44:func (w *wrapperTx) Rollback() error {
         .          .     45:	ts := time.Now()
         .     1.51MB     46:	err := w.tx.Rollback()
         .          .     47:	td := time.Since(ts)
         .          .     48:
         .          .     49:	if w.span != nil {
         .          .     50:		if err != nil {
         .          .     51:			w.span.SetStatus(tracer.SpanStatusError, err.Error())
         .          .     52:		}
         .       12MB     53:		w.span.Finish()
         .          .     54:	}
         .          .     55:
         .          .     56:	if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
         .          .     57:		w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Rollback", getCallerName(), td, err)...)
         .          .     58:	}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.NewStatsMeter.func1 in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/stats.go
         0        2MB (flat, cum) 0.0058% of Total
         .          .     16:	go func() {
         .          .     17:		ticker := time.NewTicker(options.MeterStatsInterval)
         .          .     18:		defer ticker.Stop()
         .          .     19:
         .          .     20:		for {
         .          .     21:			select {
         .          .     22:			case <-ctx.Done():
         .          .     23:				return
         .          .     24:			case <-ticker.C:
         .          .     25:				if db == nil {
         .          .     26:					return
         .          .     27:				}
         .          .     28:				stats := db.Stats()
         .          .     29:				options.Meter.Counter(MaxOpenConnections).Set(uint64(stats.MaxOpenConnections))
         .          .     30:				options.Meter.Counter(OpenConnections).Set(uint64(stats.OpenConnections))
         .   512.01kB     31:				options.Meter.Counter(InuseConnections).Set(uint64(stats.InUse))
         .          .     32:				options.Meter.Counter(IdleConnections).Set(uint64(stats.Idle))
         .          .     33:				options.Meter.Counter(WaitConnections).Set(uint64(stats.WaitCount))
         .          .     34:				options.Meter.FloatCounter(BlockedSeconds).Set(stats.WaitDuration.Seconds())
         .          .     35:				options.Meter.Counter(MaxIdleClosed).Set(uint64(stats.MaxIdleClosed))
         .     1.50MB     36:				options.Meter.Counter(MaxIdletimeClosed).Set(uint64(stats.MaxIdleTimeClosed))
         .          .     37:				options.Meter.Counter(MaxLifetimeClosed).Set(uint64(stats.MaxLifetimeClosed))
         .          .     38:			}
         .          .     39:		}
         .          .     40:	}()
         .          .     41:}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.QueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go
      13MB       47MB (flat, cum)  0.14% of Total
         .          .    172:func QueryName(ctx context.Context, name string) context.Context {
         .          .    173:	if ctx == nil {
         .          .    174:		ctx = context.Background()
         .          .    175:	}
      13MB       47MB    176:	return context.WithValue(ctx, queryNameKey{}, name)
         .          .    177:}
         .          .    178:
         .          .    179:func getQueryName(ctx context.Context) string {
         .          .    180:	if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown {
         .          .    181:		return v
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getCallerName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go
   27.01MB    27.01MB (flat, cum) 0.078% of Total
         .          .     41:func getCallerName() string {
   27.01MB    27.01MB     42:	pc, _, _, ok := runtime.Caller(3)
         .          .     43:	details := runtime.FuncForPC(pc)
         .          .     44:	var callerName string
         .          .     45:	if ok && details != nil {
         .          .     46:		callerName = details.Name()
         .          .     47:	} else {
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getQueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go
         0    27.01MB (flat, cum) 0.078% of Total
         .          .    179:func getQueryName(ctx context.Context) string {
         .          .    180:	if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown {
         .          .    181:		return v
         .          .    182:	}
         .    27.01MB    183:	return getCallerName()
         .          .    184:}
ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.namedValueToLabels in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go
  216.05MB   463.44MB (flat, cum)  1.34% of Total
         .          .     26:func namedValueToLabels(named []driver.NamedValue) []interface{} {
  108.05MB   108.05MB     27:	largs := make([]interface{}, 0, len(named)*2)
         .          .     28:	var name string
         .          .     29:	for _, param := range named {
         .          .     30:		if param.Name != "" {
         .          .     31:			name = param.Name
         .          .     32:		} else {
         .    13.50MB     33:			name = fmt.Sprintf("$%d", param.Ordinal)
         .          .     34:		}
     108MB   341.89MB     35:		largs = append(largs, fmt.Sprintf("%s=%v", name, param.Value))
         .          .     36:	}
         .          .     37:	return largs
         .          .     38:}
         .          .     39:
         .          .     40:// getCallerName get the name of the function A where A() -> B() -> GetFunctionCallerName()
``` Total: 33.80GB ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).BeginTx in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 68.01MB 452.09MB (flat, cum) 1.31% of Total . . 101:func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { . 27.01MB 102: name := getQueryName(ctx) 8MB 232.05MB 103: nctx, span := w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) 4MB 9MB 104: span.AddLabels("db.method", "BeginTx") 7.50MB 15MB 105: span.AddLabels("db.statement", name) . . 106: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 6MB 21.50MB 107: span.AddLabels("x-request-id", id) . . 108: } 7MB 7MB 109: labels := []string{labelMethod, "BeginTx", labelQuery, name} . . 110: . . 111: connBeginTx, ok := w.conn.(driver.ConnBeginTx) . . 112: if !ok { . . 113: return w.Begin() . . 114: } . . 115: . . 116: ts := time.Now() . 12.01MB 117: tx, err := connBeginTx.BeginTx(nctx, opts) . . 118: td := time.Since(ts) . . 119: te := td.Seconds() . . 120: if err != nil { . . 121: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 122: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . . 123: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 124: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 125: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 126: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...) . . 127: } . . 128: return nil, err . . 129: } 13MB 106.02MB 130: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 131: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 132: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...) . . 133: } 22.50MB 22.50MB 134: return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx, span: span}, nil . . 135:} . . 136: . . 137:// Prepare implements driver.Conn Prepare . . 138:func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) { . . 139: var ctx context.Context ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).Close in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 0 512.12kB (flat, cum) 0.0014% of Total . . 39:func (w *wrapperConn) Close() error { . . 40: var ctx context.Context . . 41: if w.ctx != nil { . . 42: ctx = w.ctx . . 43: } else { . . 44: ctx = context.Background() . . 45: } . . 46: . . 47: labels := []string{labelMethod, "Close"} . . 48: ts := time.Now() . . 49: err := w.conn.Close() . . 50: td := time.Since(ts) . . 51: te := td.Seconds() . . 52: if err != nil { . . 53: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 54: } else { . . 55: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 56: } . 512.12kB 57: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . . 58: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 59: . . 60: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 61: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...) . . 62: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).ExecContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 66.01MB 3.66GB (flat, cum) 10.82% of Total . . 251:func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { . . 252: var nctx context.Context . . 253: var span tracer.Span . . 254: . . 255: name := getQueryName(ctx) . . 256: if w.ctx != nil { . . 257: nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 258: } else { 5.50MB 205.03MB 259: nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 260: } 4.50MB 7.50MB 261: span.AddLabels("db.method", "ExecContext") 6MB 17MB 262: span.AddLabels("db.statement", name) . . 263: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 6.50MB 21MB 264: span.AddLabels("x-request-id", id) . . 265: } . . 266: defer span.Finish() . . 267: if len(args) > 0 { 5MB 540.90MB 268: span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args))) . . 269: } 7MB 7MB 270: labels := []string{labelMethod, "ExecContext", labelQuery, name} . . 271: . . 272: conn, ok := w.conn.(driver.ExecerContext) . . 273: if !ok { . . 274: // nolint:staticcheck . . 275: return nil, driver.ErrSkip . . 276: } . . 277: . . 278: ts := time.Now() . 2.48GB 279: res, err := conn.ExecContext(nctx, query, args) . . 280: td := time.Since(ts) . . 281: te := td.Seconds() . . 282: if err != nil { . . 283: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 284: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 285: } else { 15MB 87.51MB 286: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 287: } 16.50MB 98.02MB 288: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . 70.51MB 289: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . 79.01MB 290: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 291: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 292: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", getCallerName(), td, err)...) . . 293: } . . 294: . 69.51MB 295: return res, err . . 296:} . . 297: . . 298:// Ping implements driver.Pinger Ping . . 299:func (w *wrapperConn) Ping(ctx context.Context) error { . . 300: conn, ok := w.conn.(driver.Pinger) ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).QueryContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 298.52MB 18.36GB (flat, cum) 54.32% of Total . . 374:func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { . . 375: var nctx context.Context . . 376: var span tracer.Span . . 377: . . 378: name := getQueryName(ctx) . . 379: if w.ctx != nil { . . 380: nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 381: } else { 45.50MB 1.22GB 382: nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 383: } 20MB 36.50MB 384: span.AddLabels("db.method", "QueryContext") 32.50MB 72.50MB 385: span.AddLabels("db.statement", name) . . 386: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 39MB 136.01MB 387: span.AddLabels("x-request-id", id) . . 388: } . . 389: defer span.Finish() . . 390: if len(args) > 0 { 44.50MB 226.51MB 391: span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args))) . . 392: } 40MB 40MB 393: labels := []string{labelMethod, "QueryContext", labelQuery, name} . . 394: conn, ok := w.conn.(driver.QueryerContext) . . 395: if !ok { . . 396: return nil, driver.ErrSkip . . 397: } . . 398: . . 399: ts := time.Now() . 14.96GB 400: rows, err := conn.QueryContext(nctx, query, args) . . 401: td := time.Since(ts) . . 402: te := td.Seconds() . . 403: if err != nil { . . 404: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 405: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 406: } else { 77.01MB 503.58MB 407: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 408: } . 411.57MB 409: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . 409.07MB 410: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 411: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 412: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", getCallerName(), td, err)...) . . 413: } . . 414: . 393.07MB 415: return rows, err . . 416:} . . 417: . . 418:// CheckNamedValue implements driver.NamedValueChecker . . 419:func (w *wrapperConn) CheckNamedValue(v *driver.NamedValue) error { . . 420: s, ok := w.conn.(driver.NamedValueChecker) ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperDriver).Open in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/driver.go 0 5.52MB (flat, cum) 0.016% of Total . . 66:func (w *wrapperDriver) Open(name string) (driver.Conn, error) { . . 67: // ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Ensure eventual timeout . . 68: // defer cancel() . . 69: . . 70: /* . . 71: connector, err := w.OpenConnector(name) . . 72: if err != nil { . . 73: return nil, err . . 74: } . . 75: return connector.Connect(ctx) . . 76: */ . . 77: . . 78: ts := time.Now() . 5.52MB 79: c, err := w.driver.Open(name) . . 80: td := time.Since(ts) . . 81: . . 82: if w.opts.LoggerEnabled { . . 83: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Open", getCallerName(), td, err)...) . . 84: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Commit in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go 0 57.04MB (flat, cum) 0.16% of Total . . 22:func (w *wrapperTx) Commit() error { . . 23: ts := time.Now() . 4.54MB 24: err := w.tx.Commit() . . 25: td := time.Since(ts) . . 26: . . 27: if w.span != nil { . . 28: if err != nil { . . 29: w.span.SetStatus(tracer.SpanStatusError, err.Error()) . . 30: } . 52.51MB 31: w.span.Finish() . . 32: } . . 33: . . 34: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 35: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Commit", getCallerName(), td, err)...) . . 36: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Rollback in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go 0 13.51MB (flat, cum) 0.039% of Total . . 44:func (w *wrapperTx) Rollback() error { . . 45: ts := time.Now() . 1.51MB 46: err := w.tx.Rollback() . . 47: td := time.Since(ts) . . 48: . . 49: if w.span != nil { . . 50: if err != nil { . . 51: w.span.SetStatus(tracer.SpanStatusError, err.Error()) . . 52: } . 12MB 53: w.span.Finish() . . 54: } . . 55: . . 56: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 57: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Rollback", getCallerName(), td, err)...) . . 58: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.NewStatsMeter.func1 in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/stats.go 0 2MB (flat, cum) 0.0058% of Total . . 16: go func() { . . 17: ticker := time.NewTicker(options.MeterStatsInterval) . . 18: defer ticker.Stop() . . 19: . . 20: for { . . 21: select { . . 22: case <-ctx.Done(): . . 23: return . . 24: case <-ticker.C: . . 25: if db == nil { . . 26: return . . 27: } . . 28: stats := db.Stats() . . 29: options.Meter.Counter(MaxOpenConnections).Set(uint64(stats.MaxOpenConnections)) . . 30: options.Meter.Counter(OpenConnections).Set(uint64(stats.OpenConnections)) . 512.01kB 31: options.Meter.Counter(InuseConnections).Set(uint64(stats.InUse)) . . 32: options.Meter.Counter(IdleConnections).Set(uint64(stats.Idle)) . . 33: options.Meter.Counter(WaitConnections).Set(uint64(stats.WaitCount)) . . 34: options.Meter.FloatCounter(BlockedSeconds).Set(stats.WaitDuration.Seconds()) . . 35: options.Meter.Counter(MaxIdleClosed).Set(uint64(stats.MaxIdleClosed)) . 1.50MB 36: options.Meter.Counter(MaxIdletimeClosed).Set(uint64(stats.MaxIdleTimeClosed)) . . 37: options.Meter.Counter(MaxLifetimeClosed).Set(uint64(stats.MaxLifetimeClosed)) . . 38: } . . 39: } . . 40: }() . . 41:} ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.QueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go 13MB 47MB (flat, cum) 0.14% of Total . . 172:func QueryName(ctx context.Context, name string) context.Context { . . 173: if ctx == nil { . . 174: ctx = context.Background() . . 175: } 13MB 47MB 176: return context.WithValue(ctx, queryNameKey{}, name) . . 177:} . . 178: . . 179:func getQueryName(ctx context.Context) string { . . 180: if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown { . . 181: return v ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getCallerName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go 27.01MB 27.01MB (flat, cum) 0.078% of Total . . 41:func getCallerName() string { 27.01MB 27.01MB 42: pc, _, _, ok := runtime.Caller(3) . . 43: details := runtime.FuncForPC(pc) . . 44: var callerName string . . 45: if ok && details != nil { . . 46: callerName = details.Name() . . 47: } else { ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getQueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go 0 27.01MB (flat, cum) 0.078% of Total . . 179:func getQueryName(ctx context.Context) string { . . 180: if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown { . . 181: return v . . 182: } . 27.01MB 183: return getCallerName() . . 184:} ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.namedValueToLabels in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go 216.05MB 463.44MB (flat, cum) 1.34% of Total . . 26:func namedValueToLabels(named []driver.NamedValue) []interface{} { 108.05MB 108.05MB 27: largs := make([]interface{}, 0, len(named)*2) . . 28: var name string . . 29: for _, param := range named { . . 30: if param.Name != "" { . . 31: name = param.Name . . 32: } else { . 13.50MB 33: name = fmt.Sprintf("$%d", param.Ordinal) . . 34: } 108MB 341.89MB 35: largs = append(largs, fmt.Sprintf("%s=%v", name, param.Value)) . . 36: } . . 37: return largs . . 38:} . . 39: . . 40:// getCallerName get the name of the function A where A() -> B() -> GetFunctionCallerName() (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) (pprof) list go.unistack.org/micro-wrapper-sql/v3 Total: 33.80GB ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).BeginTx in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 68.01MB 452.09MB (flat, cum) 1.31% of Total . . 101:func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { . 27.01MB 102: name := getQueryName(ctx) 8MB 232.05MB 103: nctx, span := w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) 4MB 9MB 104: span.AddLabels("db.method", "BeginTx") 7.50MB 15MB 105: span.AddLabels("db.statement", name) . . 106: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 6MB 21.50MB 107: span.AddLabels("x-request-id", id) . . 108: } 7MB 7MB 109: labels := []string{labelMethod, "BeginTx", labelQuery, name} . . 110: . . 111: connBeginTx, ok := w.conn.(driver.ConnBeginTx) . . 112: if !ok { . . 113: return w.Begin() . . 114: } . . 115: . . 116: ts := time.Now() . 12.01MB 117: tx, err := connBeginTx.BeginTx(nctx, opts) . . 118: td := time.Since(ts) . . 119: te := td.Seconds() . . 120: if err != nil { . . 121: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 122: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . . 123: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 124: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 125: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 126: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...) . . 127: } . . 128: return nil, err . . 129: } 13MB 106.02MB 130: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 131: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 132: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...) . . 133: } 22.50MB 22.50MB 134: return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx, span: span}, nil . . 135:} . . 136: . . 137:// Prepare implements driver.Conn Prepare . . 138:func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) { . . 139: var ctx context.Context ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).Close in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 0 512.12kB (flat, cum) 0.0014% of Total . . 39:func (w *wrapperConn) Close() error { . . 40: var ctx context.Context . . 41: if w.ctx != nil { . . 42: ctx = w.ctx . . 43: } else { . . 44: ctx = context.Background() . . 45: } . . 46: . . 47: labels := []string{labelMethod, "Close"} . . 48: ts := time.Now() . . 49: err := w.conn.Close() . . 50: td := time.Since(ts) . . 51: te := td.Seconds() . . 52: if err != nil { . . 53: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 54: } else { . . 55: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 56: } . 512.12kB 57: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . . 58: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 59: . . 60: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 61: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...) . . 62: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).ExecContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 66.01MB 3.66GB (flat, cum) 10.82% of Total . . 251:func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { . . 252: var nctx context.Context . . 253: var span tracer.Span . . 254: . . 255: name := getQueryName(ctx) . . 256: if w.ctx != nil { . . 257: nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 258: } else { 5.50MB 205.03MB 259: nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 260: } 4.50MB 7.50MB 261: span.AddLabels("db.method", "ExecContext") 6MB 17MB 262: span.AddLabels("db.statement", name) . . 263: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 6.50MB 21MB 264: span.AddLabels("x-request-id", id) . . 265: } . . 266: defer span.Finish() . . 267: if len(args) > 0 { 5MB 540.90MB 268: span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args))) . . 269: } 7MB 7MB 270: labels := []string{labelMethod, "ExecContext", labelQuery, name} . . 271: . . 272: conn, ok := w.conn.(driver.ExecerContext) . . 273: if !ok { . . 274: // nolint:staticcheck . . 275: return nil, driver.ErrSkip . . 276: } . . 277: . . 278: ts := time.Now() . 2.48GB 279: res, err := conn.ExecContext(nctx, query, args) . . 280: td := time.Since(ts) . . 281: te := td.Seconds() . . 282: if err != nil { . . 283: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 284: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 285: } else { 15MB 87.51MB 286: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 287: } 16.50MB 98.02MB 288: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . 70.51MB 289: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . 79.01MB 290: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 291: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 292: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", getCallerName(), td, err)...) . . 293: } . . 294: . 69.51MB 295: return res, err . . 296:} . . 297: . . 298:// Ping implements driver.Pinger Ping . . 299:func (w *wrapperConn) Ping(ctx context.Context) error { . . 300: conn, ok := w.conn.(driver.Pinger) ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperConn).QueryContext in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/conn.go 298.52MB 18.36GB (flat, cum) 54.32% of Total . . 374:func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { . . 375: var nctx context.Context . . 376: var span tracer.Span . . 377: . . 378: name := getQueryName(ctx) . . 379: if w.ctx != nil { . . 380: nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 381: } else { 45.50MB 1.22GB 382: nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient)) . . 383: } 20MB 36.50MB 384: span.AddLabels("db.method", "QueryContext") 32.50MB 72.50MB 385: span.AddLabels("db.statement", name) . . 386: if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok { 39MB 136.01MB 387: span.AddLabels("x-request-id", id) . . 388: } . . 389: defer span.Finish() . . 390: if len(args) > 0 { 44.50MB 226.51MB 391: span.AddLabels("db.args", fmt.Sprintf("%v", namedValueToLabels(args))) . . 392: } 40MB 40MB 393: labels := []string{labelMethod, "QueryContext", labelQuery, name} . . 394: conn, ok := w.conn.(driver.QueryerContext) . . 395: if !ok { . . 396: return nil, driver.ErrSkip . . 397: } . . 398: . . 399: ts := time.Now() . 14.96GB 400: rows, err := conn.QueryContext(nctx, query, args) . . 401: td := time.Since(ts) . . 402: te := td.Seconds() . . 403: if err != nil { . . 404: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc() . . 405: span.SetStatus(tracer.SpanStatusError, err.Error()) . . 406: } else { 77.01MB 503.58MB 407: w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc() . . 408: } . 411.57MB 409: w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te) . 409.07MB 410: w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te) . . 411: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 412: w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", getCallerName(), td, err)...) . . 413: } . . 414: . 393.07MB 415: return rows, err . . 416:} . . 417: . . 418:// CheckNamedValue implements driver.NamedValueChecker . . 419:func (w *wrapperConn) CheckNamedValue(v *driver.NamedValue) error { . . 420: s, ok := w.conn.(driver.NamedValueChecker) ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperDriver).Open in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/driver.go 0 5.52MB (flat, cum) 0.016% of Total . . 66:func (w *wrapperDriver) Open(name string) (driver.Conn, error) { . . 67: // ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Ensure eventual timeout . . 68: // defer cancel() . . 69: . . 70: /* . . 71: connector, err := w.OpenConnector(name) . . 72: if err != nil { . . 73: return nil, err . . 74: } . . 75: return connector.Connect(ctx) . . 76: */ . . 77: . . 78: ts := time.Now() . 5.52MB 79: c, err := w.driver.Open(name) . . 80: td := time.Since(ts) . . 81: . . 82: if w.opts.LoggerEnabled { . . 83: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Open", getCallerName(), td, err)...) . . 84: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Commit in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go 0 57.04MB (flat, cum) 0.16% of Total . . 22:func (w *wrapperTx) Commit() error { . . 23: ts := time.Now() . 4.54MB 24: err := w.tx.Commit() . . 25: td := time.Since(ts) . . 26: . . 27: if w.span != nil { . . 28: if err != nil { . . 29: w.span.SetStatus(tracer.SpanStatusError, err.Error()) . . 30: } . 52.51MB 31: w.span.Finish() . . 32: } . . 33: . . 34: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 35: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Commit", getCallerName(), td, err)...) . . 36: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.(*wrapperTx).Rollback in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/tx.go 0 13.51MB (flat, cum) 0.039% of Total . . 44:func (w *wrapperTx) Rollback() error { . . 45: ts := time.Now() . 1.51MB 46: err := w.tx.Rollback() . . 47: td := time.Since(ts) . . 48: . . 49: if w.span != nil { . . 50: if err != nil { . . 51: w.span.SetStatus(tracer.SpanStatusError, err.Error()) . . 52: } . 12MB 53: w.span.Finish() . . 54: } . . 55: . . 56: if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) { . . 57: w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Rollback", getCallerName(), td, err)...) . . 58: } ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.NewStatsMeter.func1 in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/stats.go 0 2MB (flat, cum) 0.0058% of Total . . 16: go func() { . . 17: ticker := time.NewTicker(options.MeterStatsInterval) . . 18: defer ticker.Stop() . . 19: . . 20: for { . . 21: select { . . 22: case <-ctx.Done(): . . 23: return . . 24: case <-ticker.C: . . 25: if db == nil { . . 26: return . . 27: } . . 28: stats := db.Stats() . . 29: options.Meter.Counter(MaxOpenConnections).Set(uint64(stats.MaxOpenConnections)) . . 30: options.Meter.Counter(OpenConnections).Set(uint64(stats.OpenConnections)) . 512.01kB 31: options.Meter.Counter(InuseConnections).Set(uint64(stats.InUse)) . . 32: options.Meter.Counter(IdleConnections).Set(uint64(stats.Idle)) . . 33: options.Meter.Counter(WaitConnections).Set(uint64(stats.WaitCount)) . . 34: options.Meter.FloatCounter(BlockedSeconds).Set(stats.WaitDuration.Seconds()) . . 35: options.Meter.Counter(MaxIdleClosed).Set(uint64(stats.MaxIdleClosed)) . 1.50MB 36: options.Meter.Counter(MaxIdletimeClosed).Set(uint64(stats.MaxIdleTimeClosed)) . . 37: options.Meter.Counter(MaxLifetimeClosed).Set(uint64(stats.MaxLifetimeClosed)) . . 38: } . . 39: } . . 40: }() . . 41:} ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.QueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go 13MB 47MB (flat, cum) 0.14% of Total . . 172:func QueryName(ctx context.Context, name string) context.Context { . . 173: if ctx == nil { . . 174: ctx = context.Background() . . 175: } 13MB 47MB 176: return context.WithValue(ctx, queryNameKey{}, name) . . 177:} . . 178: . . 179:func getQueryName(ctx context.Context) string { . . 180: if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown { . . 181: return v ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getCallerName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go 27.01MB 27.01MB (flat, cum) 0.078% of Total . . 41:func getCallerName() string { 27.01MB 27.01MB 42: pc, _, _, ok := runtime.Caller(3) . . 43: details := runtime.FuncForPC(pc) . . 44: var callerName string . . 45: if ok && details != nil { . . 46: callerName = details.Name() . . 47: } else { ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.getQueryName in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/options.go 0 27.01MB (flat, cum) 0.078% of Total . . 179:func getQueryName(ctx context.Context) string { . . 180: if v, ok := ctx.Value(queryNameKey{}).(string); ok && v != labelUnknown { . . 181: return v . . 182: } . 27.01MB 183: return getCallerName() . . 184:} ROUTINE ======================== go.unistack.org/micro-wrapper-sql/v3.namedValueToLabels in go.unistack.org/micro-wrapper-sql/v3@v3.10.12/common.go 216.05MB 463.44MB (flat, cum) 1.34% of Total . . 26:func namedValueToLabels(named []driver.NamedValue) []interface{} { 108.05MB 108.05MB 27: largs := make([]interface{}, 0, len(named)*2) . . 28: var name string . . 29: for _, param := range named { . . 30: if param.Name != "" { . . 31: name = param.Name . . 32: } else { . 13.50MB 33: name = fmt.Sprintf("$%d", param.Ordinal) . . 34: } 108MB 341.89MB 35: largs = append(largs, fmt.Sprintf("%s=%v", name, param.Value)) . . 36: } . . 37: return largs . . 38:} . . 39: . . 40:// getCallerName get the name of the function A where A() -> B() -> GetFunctionCallerName() ```
Author
Owner

partially fixed in latest v3 release

partially fixed in latest v3 release
Sign in to join this conversation.
No description provided.