@@ -6,12 +6,16 @@ import (
66 "github.com/bcc-media/wayfarer/internal/cache"
77 "github.com/bcc-media/wayfarer/internal/database"
88 "github.com/bcc-media/wayfarer/internal/graph/api/model"
9+ "github.com/bcc-media/wayfarer/internal/otel"
910 "github.com/graph-gophers/dataloader/v7"
1011)
1112
1213// quizAnswersByQuestionBatchFunc batches loading predefined answers by question IDs
1314func quizAnswersByQuestionBatchFunc (db * database.DB , c * cache.CacheWithRegistry ) func (context.Context , []string ) []* dataloader.Result [[]* model.QuizPredefinedAnswer ] {
1415 return func (ctx context.Context , questionIDs []string ) []* dataloader.Result [[]* model.QuizPredefinedAnswer ] {
16+ ctx , span := otel .StartDataloaderSpan (ctx , "QuizAnswersByQuestion" , len (questionIDs ))
17+ defer span .End ()
18+
1519 // Check cache first for each question ID
1620 answersMap := make (map [string ][]* model.QuizPredefinedAnswer )
1721 missingIDs := []string {}
@@ -27,6 +31,9 @@ func quizAnswersByQuestionBatchFunc(db *database.DB, c *cache.CacheWithRegistry)
2731 missingIDs = append (missingIDs , questionID )
2832 }
2933
34+ // Record cache statistics
35+ otel .RecordCacheHitMiss (span , len (questionIDs )- len (missingIDs ), len (missingIDs ))
36+
3037 // Query database only for cache misses
3138 if len (missingIDs ) > 0 {
3239 rows , err := db .Queries .GetPredefinedAnswersByQuestionIDs (ctx , missingIDs )
0 commit comments