Skip to content

Commit

Permalink
Feat support k6 artillery triggers (#3745)
Browse files Browse the repository at this point in the history
* feat(agent): adding support for k6 and artillery triggers

* feat(agent): adding support for k6 and artillery triggers
  • Loading branch information
xoscar committed Mar 22, 2024
1 parent 01f28f3 commit c105866
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion agent/workers/trigger/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/kubeshop/tracetest/server/pkg/kafka"
"github.com/kubeshop/tracetest/agent/workers/trigger/kafka"
"go.opentelemetry.io/otel/propagation"
)

Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion agent/workers/trigger/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ func (t *traceidTriggerer) Type() TriggerType {
const TriggerTypeTraceID TriggerType = "traceid"
const TriggerTypeCypress TriggerType = "cypress"
const TriggerTypePlaywright TriggerType = "playwright"
const TriggerTypeArtillery TriggerType = "artillery"
const TriggerTypeK6 TriggerType = "k6"

var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright}
var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright, TriggerTypeArtillery, TriggerTypeK6}
var traceIDBasedIntegrationsTriggers = []TriggerType{TriggerTypeCypress, TriggerTypePlaywright, TriggerTypeArtillery, TriggerTypeK6}

type TraceIDRequest struct {
ID string `json:"id,omitempty" expr_enabled:"true"`
Expand Down
4 changes: 2 additions & 2 deletions agent/workers/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (t TriggerType) IsTraceIDBased() bool {
return slices.Contains(traceIDBasedTriggers, t)
}

func (t TriggerType) IsFrontendE2EBased() bool {
return t == TriggerTypeCypress || t == TriggerTypePlaywright
func (t TriggerType) IsIntegration() bool {
return slices.Contains(traceIDBasedIntegrationsTriggers, t)
}

type (
Expand Down
2 changes: 1 addition & 1 deletion agent/workers/trigger/trigger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (v3 triggerJSONV3) valid() bool {
(v3.HTTP != nil ||
v3.GRPC != nil ||
v3.TraceID != nil ||
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright)
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright || v3.Type == TriggerTypeArtillery || v3.Type == TriggerTypeK6)
}

type triggerJSONV2 struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ spec:
id: artillery-plugin-import-pokemon
name: "Artillery Plugin: Import a Pokemon"
trigger:
type: traceid
traceid:
id: ${var:TRACE_ID}
type: artillery
specs:
- selector: span[tracetest.span.type="general" name = "validate request"] span[tracetest.span.type="http"]
name: "All HTTP Spans: Status code is 200"
Expand Down
2 changes: 1 addition & 1 deletion examples/quick-start-artillery/plugin-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ config:
tool: "Artillery"
tracetest:
token: <YOUR_TRACETES_ENV_TOKEN>
definition: import-pokemon-trace-id.yaml
definition: import-pokemon-plugin.yaml
runInfo:
variables:
- key: POKEMON_ID
Expand Down
2 changes: 1 addition & 1 deletion server/executor/trigger/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/server/pkg/kafka"
"github.com/kubeshop/tracetest/agent/workers/trigger/kafka"
"github.com/kubeshop/tracetest/server/test"

"go.opentelemetry.io/otel/propagation"
Expand Down
2 changes: 1 addition & 1 deletion server/executor/trigger/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (t *traceidTriggerer) Type() trigger.TriggerType {
}

func (t *traceidTriggerer) Resolve(ctx context.Context, test test.Test, opts *ResolveOptions) (test.Test, error) {
if test.Trigger.Type.IsFrontendE2EBased() {
if test.Trigger.Type.IsIntegration() {
test.Trigger.TraceID = &trigger.TraceIDRequest{ID: TRACEID_EXPRESSION}
}

Expand Down

0 comments on commit c105866

Please sign in to comment.