diff --git a/backend/redis/similarity.go b/backend/redis/similarity.go index ad6169e..99cd583 100644 --- a/backend/redis/similarity.go +++ b/backend/redis/similarity.go @@ -141,7 +141,11 @@ func (s *SimilarityService) FindSimilarPosts(ctx context.Context, filter *analog err = s.idKeysCache.get(ctx, idKey, &idKeyHashesString) // split string to list - idKeyHashes := strings.Split(idKeyHashesString, delimiter) + var idKeyHashes []string + + if idKeyHashesString != "" { + idKeyHashes = strings.Split(idKeyHashesString, delimiter) + } // if key already exists in slice, no more to do for _, h := range idKeyHashes { @@ -192,7 +196,11 @@ func (s *SimilarityService) DeletePost(ctx context.Context, id int) error { } // split string to list - idKeyHashes := strings.Split(idKeyHashesString, delimiter) + var idKeyHashes []string + + if idKeyHashesString != "" { + idKeyHashes = strings.Split(idKeyHashesString, delimiter) + } // for all hashes, remove from posts cache for _, hash := range idKeyHashes { diff --git a/backend/weaviate/weaviate.go b/backend/weaviate/weaviate.go index 3ea72f0..a6cb0ad 100644 --- a/backend/weaviate/weaviate.go +++ b/backend/weaviate/weaviate.go @@ -101,10 +101,12 @@ func (db *DB) startTrace(ctx context.Context, spanName string, opts ...trace.Spa dbSystem := attribute.String("db.system", "weaviate") dbName := attribute.String("db.name", "pictures") serverAddress := attribute.String("server.address", db.host) + + attributes := trace.WithAttributes(dbSystem, dbName, serverAddress) spanKind := trace.WithSpanKind(trace.SpanKindClient) - opts = append(opts, dbSystem, dbName, serverAddress, spanKind) + opts = append(opts, attributes, spanKind) - return db.tracer.Tracer.Start(ctx, spanName, opts) + return db.tracer.Tracer.Start(ctx, spanName, opts...) }