Skip to content

Commit

Permalink
fix weaviate traces
Browse files Browse the repository at this point in the history
  • Loading branch information
evanofslack committed Jul 31, 2023
1 parent 7ca63f3 commit 314f262
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions backend/redis/similarity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions backend/weaviate/weaviate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)

}

0 comments on commit 314f262

Please sign in to comment.