Skip to content

Commit

Permalink
Register a k6/experimental/tracing
Browse files Browse the repository at this point in the history
Although we do not expose any of user-facing logic at this point, we
register the "k6/experimental/tracing" module in k6 to prepare for
further implementation of public APIs
  • Loading branch information
oleiade committed Jan 16, 2023
1 parent 8489464 commit 9df375a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/jsmodules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"go.k6.io/k6/js/modules/k6/data"
"go.k6.io/k6/js/modules/k6/encoding"
"go.k6.io/k6/js/modules/k6/execution"
"go.k6.io/k6/js/modules/k6/experimental/tracing"
"go.k6.io/k6/js/modules/k6/grpc"
"go.k6.io/k6/js/modules/k6/html"
"go.k6.io/k6/js/modules/k6/http"
Expand All @@ -30,6 +31,7 @@ func getInternalJSModules() map[string]interface{} {
"k6/experimental/redis": redis.New(),
"k6/experimental/websockets": &expws.RootModule{},
"k6/experimental/timers": timers.New(),
"k6/experimental/tracing": tracing.New(),
"k6/net/grpc": grpc.New(),
"k6/html": html.New(),
"k6/http": http.New(),
Expand Down
42 changes: 42 additions & 0 deletions js/modules/k6/experimental/tracing/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
package tracing

import (
"go.k6.io/k6/js/modules"
)

type (
// RootModule is the global module instance that will create Client
// instances for each VU.
RootModule struct{}

// ModuleInstance represents an instance of the JS module.
ModuleInstance struct {
vu modules.VU
}
)

// Ensure the interfaces are implemented correctly
var (
_ modules.Instance = &ModuleInstance{}
_ modules.Module = &RootModule{}
)

// New returns a pointer to a new RootModule instance
func New() *RootModule {
return &RootModule{}
}

// NewModuleInstance implements the modules.Module interface and returns
// a new instance for each VU.
func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
return &ModuleInstance{
vu: vu,
}
}

// Exports implements the modules.Instance interface and returns
// the exports of the JS module.
func (mi *ModuleInstance) Exports() modules.Exports {
return modules.Exports{}
}

0 comments on commit 9df375a

Please sign in to comment.