Private
Public Access
1
0
Files
data-api/ntpdb/otel.go
Ask Bjørn Hansen e824274998
All checks were successful
continuous-integration/drone/push Build is passing
Add png graph handler
2023-12-09 13:54:13 -08:00

215 lines
6.0 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)
}
// GetServerByID implements QuerierTx
func (_d QuerierTxWithTracing) GetServerByID(ctx context.Context, id uint32) (s1 Server, err error) {
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerByID")
defer func() {
if _d._spanDecorator != nil {
_d._spanDecorator(_span, map[string]interface{}{
"ctx": ctx,
"id": id}, map[string]interface{}{
"s1": s1,
"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.GetServerByID(ctx, id)
}
// GetServerByIP implements QuerierTx
func (_d QuerierTxWithTracing) GetServerByIP(ctx context.Context, ip string) (s1 Server, err error) {
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerByIP")
defer func() {
if _d._spanDecorator != nil {
_d._spanDecorator(_span, map[string]interface{}{
"ctx": ctx,
"ip": ip}, map[string]interface{}{
"s1": s1,
"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.GetServerByIP(ctx, ip)
}
// 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)
}