File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ func (instance *Traceloop) populatePromptRegistry() {
3131 return
3232 }
3333
34+ instance .registryMutex .Lock ()
3435 for _ , prompt := range response .Prompts {
3536 instance .promptRegistry [prompt .Key ] = & prompt
3637 }
38+ instance .registryMutex .Unlock ()
3739}
3840
3941func (instance * Traceloop ) pollPrompts () {
@@ -55,6 +57,8 @@ func (instance *Traceloop) pollPrompts() {
5557}
5658
5759func (instance * Traceloop ) getPromptVersion (key string ) (* model.PromptVersion , error ) {
60+ instance .registryMutex .RLock ()
61+ defer instance .registryMutex .RUnlock ()
5862 if instance .promptRegistry [key ] == nil {
5963 return nil , fmt .Errorf ("prompt with key %s not found" , key )
6064 }
Original file line number Diff line number Diff line change 66 "log"
77 "net/http"
88 "os"
9+ "sync"
910 "time"
1011
1112 "go.opentelemetry.io/otel/attribute"
@@ -21,6 +22,7 @@ const PromptsPath = "/v1/traceloop/prompts"
2122type Traceloop struct {
2223 config Config
2324 promptRegistry model.PromptRegistry
25+ registryMutex sync.RWMutex
2426 tracerProvider * trace.TracerProvider
2527 http.Client
2628}
You can’t perform that action at this time.
0 commit comments