Skip to content

Commit

Permalink
fix: adding concurrency check on Tracetest constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Sep 6, 2023
1 parent b682154 commit 54eb0b6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/tracetest/tracetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Tracetest struct {
logger logrus.FieldLogger
client *openapi.APIClient
apiOptions models.ApiOptions
mutex sync.Mutex
}

func New() *Tracetest {
Expand All @@ -33,6 +34,7 @@ func New() *Tracetest {
processedBuffer: sync.Map{},
logger: logger.WithField("component", "xk6-tracetest-tracing"),
client: NewAPIClient(models.ApiOptions{}),
mutex: sync.Mutex{},
}

duration := 1 * time.Second
Expand All @@ -52,6 +54,9 @@ func (t *Tracetest) UpdateFromConfig(config models.OutputConfig) {
}

func (t *Tracetest) Constructor(call goja.ConstructorCall) *goja.Object {
t.mutex.Lock()
defer t.mutex.Unlock()

rt := t.Vu.Runtime()
apiOptions, err := models.NewApiOptions(t.Vu, call.Argument(0))
if err != nil {
Expand Down

0 comments on commit 54eb0b6

Please sign in to comment.