169 lines
4.8 KiB
Go
169 lines
4.8 KiB
Go
// Code generated by gowrap. DO NOT EDIT.
|
|
// template: https://raw.githubusercontent.com/hexdigest/gowrap/6c8f05695fec23df85903a8da0af66ac414e2a63/templates/opentelemetry
|
|
// gowrap: http://github.com/hexdigest/gowrap
|
|
|
|
package ntpdb
|
|
|
|
//go:generate gowrap gen -p go.ntppool.org/data-api/ntpdb -i QuerierTx -t https://raw.githubusercontent.com/hexdigest/gowrap/6c8f05695fec23df85903a8da0af66ac414e2a63/templates/opentelemetry -o otel.go -l ""
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.opentelemetry.io/otel"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
// QuerierTxWithTracing implements QuerierTx interface instrumented with opentracing spans
|
|
type QuerierTxWithTracing struct {
|
|
QuerierTx
|
|
_instance string
|
|
_spanDecorator func(span trace.Span, params, results map[string]interface{})
|
|
}
|
|
|
|
// NewQuerierTxWithTracing returns QuerierTxWithTracing
|
|
func NewQuerierTxWithTracing(base QuerierTx, instance string, spanDecorator ...func(span trace.Span, params, results map[string]interface{})) QuerierTxWithTracing {
|
|
d := QuerierTxWithTracing{
|
|
QuerierTx: base,
|
|
_instance: instance,
|
|
}
|
|
|
|
if len(spanDecorator) > 0 && spanDecorator[0] != nil {
|
|
d._spanDecorator = spanDecorator[0]
|
|
}
|
|
|
|
return d
|
|
}
|
|
|
|
// Begin implements QuerierTx
|
|
func (_d QuerierTxWithTracing) Begin(ctx context.Context) (q1 QuerierTx, err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.Begin")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx}, map[string]interface{}{
|
|
"q1": q1,
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.Begin(ctx)
|
|
}
|
|
|
|
// Commit implements QuerierTx
|
|
func (_d QuerierTxWithTracing) Commit(ctx context.Context) (err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.Commit")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx}, map[string]interface{}{
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.Commit(ctx)
|
|
}
|
|
|
|
// GetServerNetspeed implements QuerierTx
|
|
func (_d QuerierTxWithTracing) GetServerNetspeed(ctx context.Context, ip string) (u1 uint32, err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerNetspeed")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx,
|
|
"ip": ip}, map[string]interface{}{
|
|
"u1": u1,
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.GetServerNetspeed(ctx, ip)
|
|
}
|
|
|
|
// GetZoneStatsData implements QuerierTx
|
|
func (_d QuerierTxWithTracing) GetZoneStatsData(ctx context.Context) (ga1 []GetZoneStatsDataRow, err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsData")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx}, map[string]interface{}{
|
|
"ga1": ga1,
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.GetZoneStatsData(ctx)
|
|
}
|
|
|
|
// GetZoneStatsV2 implements QuerierTx
|
|
func (_d QuerierTxWithTracing) GetZoneStatsV2(ctx context.Context, ip string) (ga1 []GetZoneStatsV2Row, err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsV2")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx,
|
|
"ip": ip}, map[string]interface{}{
|
|
"ga1": ga1,
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.GetZoneStatsV2(ctx, ip)
|
|
}
|
|
|
|
// Rollback implements QuerierTx
|
|
func (_d QuerierTxWithTracing) Rollback(ctx context.Context) (err error) {
|
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.Rollback")
|
|
defer func() {
|
|
if _d._spanDecorator != nil {
|
|
_d._spanDecorator(_span, map[string]interface{}{
|
|
"ctx": ctx}, map[string]interface{}{
|
|
"err": err})
|
|
} else if err != nil {
|
|
_span.RecordError(err)
|
|
_span.SetAttributes(
|
|
attribute.String("event", "error"),
|
|
attribute.String("message", err.Error()),
|
|
)
|
|
}
|
|
|
|
_span.End()
|
|
}()
|
|
return _d.QuerierTx.Rollback(ctx)
|
|
}
|