Skip to content

Commit

Permalink
Merge pull request #6 from kubeshop/fix/concurrency-issues-on-startup
Browse files Browse the repository at this point in the history
fix: adding concurrency check on Tracetest constructor
  • Loading branch information
danielbdias authored Sep 6, 2023
2 parents b682154 + a6f4d2e commit 2c72e7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21

- name: Install xk6
run: go install go.k6.io/xk6/cmd/xk6@latest
Expand Down
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 2c72e7e

Please sign in to comment.