Skip to content

Commit

Permalink
[Heartbeat] add screenshots config to synthetics (#26455)
Browse files Browse the repository at this point in the history
* [Heartbeat] add screenshots config to synthetics

* docs: update screenshot docs

(cherry picked from commit 7ca5909)
  • Loading branch information
vigneshshanmugam authored and mergify-bot committed Jun 28, 2021
1 parent eb6df62 commit b869b51
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
31 changes: 30 additions & 1 deletion heartbeat/docs/monitors/monitor-browser.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,33 @@ Set this option to `true` to enable the normally disabled chromium sandbox. Defa
[[monitor-browser-synthetics-args]]
==== `synthetics_args`

Extra arguments to pass to the synthetics agent package. Takes a list of strings.
Extra arguments to pass to the synthetics agent package. Takes a list of
strings.

[float]
[[monitor-browser-screenshots]]
==== `screenshots`

Set this option to manage the screenshots captured by the synthetics agent.

Under `screenshots`, specify one of these options:

*`on`*:: capture screenshots for all steps in a journey (default)
*`off`*:: do not capture any screenshots
*`only-on-failure`*:: capture screenshots for all steps when a journey fails
(any failing step marks the whole journey as failed)

Example configuration:

[source,yaml]
-------------------------------------------------------------------------------
- type: browser
id: local-journeys
name: Local journeys
schedule: '@every 1m'
screenshots: "on"
source:
local:
path: "/path/to/synthetics/journeys"
-------------------------------------------------------------------------------

4 changes: 3 additions & 1 deletion x-pack/heartbeat/monitors/browser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (

func DefaultConfig() *Config {
return &Config{
Sandbox: false,
Sandbox: false,
Screenshots: "on",
}
}

Expand All @@ -27,6 +28,7 @@ type Config struct {
// Id is optional for lightweight checks but required for browsers
Id string `config:"id"`
Sandbox bool `config:"sandbox"`
Screenshots string `config:"screenshots"`
SyntheticsArgs []string `config:"synthetics_args"`
}

Expand Down
3 changes: 3 additions & 0 deletions x-pack/heartbeat/monitors/browser/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (s *Suite) extraArgs() []string {
if s.suiteCfg.Sandbox {
extraArgs = append(extraArgs, "--sandbox")
}
if s.suiteCfg.Screenshots != "" {
extraArgs = append(extraArgs, "--screenshots", s.suiteCfg.Screenshots)
}

return extraArgs
}
Expand Down
10 changes: 10 additions & 0 deletions x-pack/heartbeat/monitors/browser/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,21 @@ func TestExtraArgs(t *testing.T) {
&Config{},
nil,
},
{
"default",
DefaultConfig(),
[]string{"--screenshots", "on"},
},
{
"sandbox",
&Config{Sandbox: true},
[]string{"--sandbox"},
},
{
"screenshots",
&Config{Screenshots: "off"},
[]string{"--screenshots", "off"},
},
{
"capabilities",
&Config{SyntheticsArgs: []string{"--capability", "trace", "ssblocks"}},
Expand Down

0 comments on commit b869b51

Please sign in to comment.