SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat: trace span for binary marshal and unmarshal operations (#9740)
Karan Balanibc1295b93a4c
diff --git a/pkg/cache/memorycache/provider.go b/pkg/cache/memorycache/provider.goindex b5338cf9a0..db340210b5 100644--- a/pkg/cache/memorycache/provider.go+++ b/pkg/cache/memorycache/provider.go@@ -93,7 +93,7 @@ func New(ctx context.Context, settings factory.ProviderSettings, config cache.Co}func (provider *provider) Set(ctx context.Context, orgID valuer.UUID, cacheKey string, data cachetypes.Cacheable, ttl time.Duration) error {- _, span := provider.settings.Tracer().Start(ctx, "memory.set", trace.WithAttributes(+ ctx, span := provider.settings.Tracer().Start(ctx, "memory.set", trace.WithAttributes(attribute.String(semconv.AttributeDBSystem, "memory"),attribute.String(semconv.AttributeDBStatement, "set "+strings.Join([]string{orgID.StringValue(), cacheKey}, "::")),attribute.String(semconv.AttributeDBOperation, "SET"),@@ -113,12 +113,12 @@ func (provider *provider) Set(ctx context.Context, orgID valuer.UUID, cacheKey sif ok := provider.cc.SetWithTTL(strings.Join([]string{orgID.StringValue(), cacheKey}, "::"), toCache, 1, ttl); !ok {return errors.New(errors.TypeInternal, errors.CodeInternal, "error writing to cache")}-+provider.cc.Wait()return nil}- toCache, err := data.MarshalBinary()+ toCache, err := provider.marshalBinary(ctx, data)cost := int64(len(toCache))if err != nil {return err@@ -136,7 +136,7 @@ func (provider *provider) Set(ctx context.Context, orgID valuer.UUID, cacheKey s}func (provider *provider) Get(ctx context.Context, orgID valuer.UUID, cacheKey string, dest cachetypes.Cacheable) error {- _, span := provider.settings.Tracer().Start(ctx, "memory.get", trace.WithAttributes(+ ctx, span := provider.settings.Tracer().Start(ctx, "memory.get", trace.WithAttributes(attribute.String(semconv.AttributeDBSystem, "memory"),attribute.String(semconv.AttributeDBStatement, "get "+strings.Join([]string{orgID.StringValue(), cacheKey}, "::")),attribute.String(semconv.AttributeDBOperation, "GET"),@@ -176,7 +176,7 @@ func (provider *provider) Get(ctx context.Context, orgID valuer.UUID, cacheKey sif fromCache, ok := cachedData.([]byte); ok {span.SetAttributes(attribute.Bool("memory.cloneable", false))- if err = dest.UnmarshalBinary(fromCache); err != nil {+ if err = provider.unmarshalBinary(ctx, dest, fromCache); err != nil {return err}@@ -202,3 +202,19 @@ func (provider *provider) DeleteMany(_ context.Context, orgID valuer.UUID, cacheprovider.cc.Del(strings.Join([]string{orgID.StringValue(), cacheKey}, "::"))}}++func (provider *provider) marshalBinary(ctx context.Context, toMarshal cachetypes.Cacheable) ([]byte, error) {+ _, span := provider.settings.Tracer().Start(ctx, "binary.Marshal", trace.WithAttributes(+ attribute.String(semconv.AttributeDBSystem, "memory"),+ ))+ defer span.End()+ return toMarshal.MarshalBinary()+}++func (provider *provider) unmarshalBinary(ctx context.Context, dest cachetypes.Cacheable, fromCache []byte) error {+ _, span := provider.settings.Tracer().Start(ctx, "binary.Unmarshal", trace.WithAttributes(+ attribute.String(semconv.AttributeDBSystem, "memory"),+ ))+ defer span.End()+ return dest.UnmarshalBinary(fromCache)+}