Files
tasks/common/persistence/telemetry/shared_store_gen.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

154 lines
4.7 KiB
Go

// Code generated by gowrap. DO NOT EDIT.
// template: gowrap_template
// gowrap: http://github.com/hexdigest/gowrap
package telemetry
//go:generate gowrap gen -p github.com/hanzoai/tasks/common/persistence -i ShardStore -t gowrap_template -o shared_store_gen.go -l ""
import (
"context"
"encoding/json"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/log/tag"
_sourcePersistence "github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/common/telemetry"
)
// telemetryShardStore implements ShardStore interface instrumented with OpenTelemetry.
type telemetryShardStore struct {
_sourcePersistence.ShardStore
tracer trace.Tracer
logger log.Logger
debugMode bool
}
// newTelemetryShardStore returns telemetryShardStore.
func newTelemetryShardStore(
base _sourcePersistence.ShardStore,
logger log.Logger,
tracer trace.Tracer,
) telemetryShardStore {
return telemetryShardStore{
ShardStore: base,
tracer: tracer,
debugMode: telemetry.DebugMode(),
}
}
// AssertShardOwnership wraps ShardStore.AssertShardOwnership.
func (d telemetryShardStore) AssertShardOwnership(ctx context.Context, request *_sourcePersistence.AssertShardOwnershipRequest) (err error) {
ctx, span := d.tracer.Start(
ctx,
"persistence.ShardStore/AssertShardOwnership",
trace.WithAttributes(
attribute.Key("persistence.store").String("ShardStore"),
attribute.Key("persistence.method").String("AssertShardOwnership"),
))
defer span.End()
if deadline, ok := ctx.Deadline(); ok {
span.SetAttributes(attribute.String("deadline", deadline.Format(time.RFC3339Nano)))
span.SetAttributes(attribute.String("timeout", time.Until(deadline).String()))
}
err = d.ShardStore.AssertShardOwnership(ctx, request)
if err != nil {
span.RecordError(err)
}
if d.debugMode {
requestPayload, err := json.MarshalIndent(request, "", " ")
if err != nil {
d.logger.Error("failed to serialize *_sourcePersistence.AssertShardOwnershipRequest for OTEL span", tag.Error(err))
} else {
span.SetAttributes(attribute.Key("persistence.request.payload").String(string(requestPayload)))
}
}
return
}
// GetOrCreateShard wraps ShardStore.GetOrCreateShard.
func (d telemetryShardStore) GetOrCreateShard(ctx context.Context, request *_sourcePersistence.InternalGetOrCreateShardRequest) (ip1 *_sourcePersistence.InternalGetOrCreateShardResponse, err error) {
ctx, span := d.tracer.Start(
ctx,
"persistence.ShardStore/GetOrCreateShard",
trace.WithAttributes(
attribute.Key("persistence.store").String("ShardStore"),
attribute.Key("persistence.method").String("GetOrCreateShard"),
))
defer span.End()
if deadline, ok := ctx.Deadline(); ok {
span.SetAttributes(attribute.String("deadline", deadline.Format(time.RFC3339Nano)))
span.SetAttributes(attribute.String("timeout", time.Until(deadline).String()))
}
ip1, err = d.ShardStore.GetOrCreateShard(ctx, request)
if err != nil {
span.RecordError(err)
}
if d.debugMode {
requestPayload, err := json.MarshalIndent(request, "", " ")
if err != nil {
d.logger.Error("failed to serialize *_sourcePersistence.InternalGetOrCreateShardRequest for OTEL span", tag.Error(err))
} else {
span.SetAttributes(attribute.Key("persistence.request.payload").String(string(requestPayload)))
}
responsePayload, err := json.MarshalIndent(ip1, "", " ")
if err != nil {
d.logger.Error("failed to serialize *_sourcePersistence.InternalGetOrCreateShardResponse for OTEL span", tag.Error(err))
} else {
span.SetAttributes(attribute.Key("persistence.response.payload").String(string(responsePayload)))
}
}
return
}
// UpdateShard wraps ShardStore.UpdateShard.
func (d telemetryShardStore) UpdateShard(ctx context.Context, request *_sourcePersistence.InternalUpdateShardRequest) (err error) {
ctx, span := d.tracer.Start(
ctx,
"persistence.ShardStore/UpdateShard",
trace.WithAttributes(
attribute.Key("persistence.store").String("ShardStore"),
attribute.Key("persistence.method").String("UpdateShard"),
))
defer span.End()
if deadline, ok := ctx.Deadline(); ok {
span.SetAttributes(attribute.String("deadline", deadline.Format(time.RFC3339Nano)))
span.SetAttributes(attribute.String("timeout", time.Until(deadline).String()))
}
err = d.ShardStore.UpdateShard(ctx, request)
if err != nil {
span.RecordError(err)
}
if d.debugMode {
requestPayload, err := json.MarshalIndent(request, "", " ")
if err != nil {
d.logger.Error("failed to serialize *_sourcePersistence.InternalUpdateShardRequest for OTEL span", tag.Error(err))
} else {
span.SetAttributes(attribute.Key("persistence.request.payload").String(string(requestPayload)))
}
}
return
}