-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Heartbeat] Dedupe screenshots / Extra Args #25808
Changes from all commits
91fcabf
709a7f9
7e831a6
81c6b1c
05a01f2
38084d8
e29d661
343adb1
247ae18
442078d
b1666ce
759139b
c1ff28a
609bc66
9cdcb08
0998ddd
076f77f
31f7934
a825a7c
d3e5b33
b8153f6
452c53a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,23 @@ | |
type: text | ||
- name: stack | ||
type: text | ||
- name: screenshot_ref | ||
type: group | ||
dynamic: false | ||
fields: | ||
- name: width | ||
type: integer | ||
description: Width of the full screenshot in pixels. | ||
- name: height | ||
type: integer | ||
description: Height of the full screenshot in pixels | ||
- name: blocks | ||
type: group | ||
description: Attributes representing individual screenshot blocks. Only hash is indexed since it's the only one we'd query on. | ||
fields: | ||
- name: hash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the |
||
type: keyword | ||
description: Hash that uniquely identifies this image by content. Corresponds to block document id. | ||
- name: browser | ||
type: group | ||
fields: | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package browser | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file isn't new, it's just moved. Enough of it changed due to renaming the |
||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/elastic/beats/v7/heartbeat/monitors/jobs" | ||
"github.com/elastic/beats/v7/heartbeat/monitors/plugin" | ||
"github.com/elastic/beats/v7/libbeat/beat" | ||
"github.com/elastic/beats/v7/libbeat/common" | ||
"github.com/elastic/beats/v7/x-pack/heartbeat/monitors/browser/synthexec" | ||
) | ||
|
||
type JourneyLister func(ctx context.Context, suitePath string, params common.MapStr) (journeyNames []string, err error) | ||
|
||
type Suite struct { | ||
rawCfg *common.Config | ||
suiteCfg *Config | ||
} | ||
|
||
func NewSuite(rawCfg *common.Config) (*Suite, error) { | ||
s := &Suite{ | ||
rawCfg: rawCfg, | ||
suiteCfg: DefaultConfig(), | ||
} | ||
err := rawCfg.Unpack(s.suiteCfg) | ||
if err != nil { | ||
return nil, ErrBadConfig(err) | ||
} | ||
|
||
return s, nil | ||
} | ||
|
||
func ErrBadConfig(err error) error { | ||
return fmt.Errorf("could not parse suite config: %w", err) | ||
} | ||
|
||
func (s *Suite) String() string { | ||
panic("implement me") | ||
} | ||
|
||
func (s *Suite) Fetch() error { | ||
return s.suiteCfg.Source.Active().Fetch() | ||
} | ||
|
||
func (s *Suite) Workdir() string { | ||
return s.suiteCfg.Source.Active().Workdir() | ||
} | ||
|
||
func (s *Suite) InlineSource() (string, bool) { | ||
if s.suiteCfg.Source.Inline != nil { | ||
return s.suiteCfg.Source.Inline.Script, true | ||
} | ||
return "", false | ||
} | ||
|
||
func (s *Suite) Params() map[string]interface{} { | ||
return s.suiteCfg.Params | ||
} | ||
|
||
func (s *Suite) Close() error { | ||
if s.suiteCfg.Source.ActiveMemo != nil { | ||
s.suiteCfg.Source.ActiveMemo.Close() | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (s *Suite) extraArgs() []string { | ||
extraArgs := s.suiteCfg.SyntheticsArgs | ||
if s.suiteCfg.Sandbox { | ||
extraArgs = append(extraArgs, "--sandbox") | ||
} | ||
|
||
return extraArgs | ||
} | ||
|
||
func (s *Suite) jobs() []jobs.Job { | ||
var j jobs.Job | ||
if src, ok := s.InlineSource(); ok { | ||
j = synthexec.InlineJourneyJob(context.TODO(), src, s.Params(), s.extraArgs()...) | ||
} else { | ||
j = func(event *beat.Event) ([]jobs.Job, error) { | ||
err := s.Fetch() | ||
if err != nil { | ||
return nil, fmt.Errorf("could not fetch for suite job: %w", err) | ||
} | ||
sj, err := synthexec.SuiteJob(context.TODO(), s.Workdir(), s.Params(), s.extraArgs()...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return sj(event) | ||
} | ||
} | ||
return []jobs.Job{j} | ||
} | ||
|
||
func (s *Suite) plugin() plugin.Plugin { | ||
return plugin.Plugin{ | ||
Jobs: s.jobs(), | ||
Close: s.Close, | ||
Endpoints: 1, | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove the use of full here? Full seems like full page screenshot but we are capture only the viewport width and height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I intended it to mean not of an individual block. I'll clarify that.