Skip to content

Commit

Permalink
update elastic-agent-shipper-client deps (#34596) (#34681)
Browse files Browse the repository at this point in the history
* update elastic-agent-shipper-client deps

* remove tests depending on failure

* remove debug lines

* update tests

* try to make linter happy

(cherry picked from commit b5c00fd)

Co-authored-by: Alex K <[email protected]>
  • Loading branch information
mergify[bot] and fearful-symmetry authored Apr 6, 2023
1 parent 1cf2db5 commit 92a39e2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 170 deletions.
12 changes: 6 additions & 6 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10311,11 +10311,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-l

--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-shipper-client
Version: v0.4.0
Version: v0.5.0
Licence type (autodetected): Elastic
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-shipper-client@v0.4.0/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-shipper-client@v0.5.0/LICENSE.txt:

Elastic License 2.0

Expand Down Expand Up @@ -21964,11 +21964,11 @@ THE SOFTWARE.

--------------------------------------------------------------------------------
Dependency : go.uber.org/multierr
Version: v1.8.0
Version: v1.9.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/go.uber.org/multierr@v1.8.0/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/go.uber.org/multierr@v1.9.0/LICENSE.txt:

Copyright (c) 2017-2021 Uber Technologies, Inc.

Expand All @@ -21993,11 +21993,11 @@ THE SOFTWARE.

--------------------------------------------------------------------------------
Dependency : go.uber.org/zap
Version: v1.23.0
Version: v1.24.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/go.uber.org/zap@v1.23.0/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/go.uber.org/zap@v1.24.0/LICENSE.txt:

Copyright (c) 2016-2017 Uber Technologies, Inc.

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ require (
go.elastic.co/go-licence-detector v0.5.0
go.etcd.io/bbolt v1.3.6
go.uber.org/atomic v1.10.0
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.23.0
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
Expand Down Expand Up @@ -194,7 +194,7 @@ require (
github.com/elastic/bayeux v1.0.5
github.com/elastic/elastic-agent-autodiscover v0.5.0
github.com/elastic/elastic-agent-libs v0.3.3
github.com/elastic/elastic-agent-shipper-client v0.4.0
github.com/elastic/elastic-agent-shipper-client v0.5.0
github.com/elastic/elastic-agent-system-metrics v0.4.6-0.20230308003052-ba171438211e
github.com/elastic/go-elasticsearch/v8 v8.2.0
github.com/elastic/mito v0.0.0-20230302005114-1dda06e81678
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ github.com/elastic/elastic-agent-client/v7 v7.0.3-0.20230315204017-166fd1fd746f/
github.com/elastic/elastic-agent-libs v0.2.11/go.mod h1:chO3rtcLyGlKi9S0iGVZhYCzDfdDsAQYBc+ui588AFE=
github.com/elastic/elastic-agent-libs v0.3.3 h1:iE8XhqQ0zRBLba+eu6ScZED0DYcVP/r2JvjcVoOkxic=
github.com/elastic/elastic-agent-libs v0.3.3/go.mod h1:nRkcK96PSJfK232cJRx17n9+/MVAIOzs5ghZdzXJAMo=
github.com/elastic/elastic-agent-shipper-client v0.4.0 h1:nsTJF9oo4RHLl+zxFUZqNHaE86C6Ba5aImfegcEf6Sk=
github.com/elastic/elastic-agent-shipper-client v0.4.0/go.mod h1:OyI2W+Mv3JxlkEF3OeT7K0dbuxvwew8ke2Cf4HpLa9Q=
github.com/elastic/elastic-agent-shipper-client v0.5.0 h1:rkdq7K8+ESNMXtMPzlwiiENTZz2Y6m4lN8SIMFrHuJA=
github.com/elastic/elastic-agent-shipper-client v0.5.0/go.mod h1:rWarFM7qYxJKsi9WcV6ONcFjH/NA3niDNpTxO+8/GVI=
github.com/elastic/elastic-agent-system-metrics v0.4.6-0.20230308003052-ba171438211e h1:OIfumgZhI6lI7Qy1KD1VzuqvX9DWSBpXJsvj97s7MRM=
github.com/elastic/elastic-agent-system-metrics v0.4.6-0.20230308003052-ba171438211e/go.mod h1:v/t/qgYueW3ZOm7SZhYY3ng9GWDddDLu7pmG4Ra3PBs=
github.com/elastic/elastic-transport-go/v8 v8.1.0 h1:NeqEz1ty4RQz+TVbUrpSU7pZ48XkzGWQj02k5koahIE=
Expand Down Expand Up @@ -1877,8 +1877,8 @@ go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
Expand All @@ -1887,8 +1887,8 @@ go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180505025534-4ec37c66abab/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
43 changes: 7 additions & 36 deletions libbeat/outputs/shipper/shipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"

"google.golang.org/grpc"
Expand Down Expand Up @@ -72,6 +71,9 @@ func init() {
outputs.RegisterType("shipper", makeShipper)
}

// shipperProcessor serves as a wrapper for testing Publish() calls with alternate marshalling callbacks
var shipperProcessor = toShipperEvent

func makeShipper(
_ outputs.IndexManager,
beat beat.Info,
Expand Down Expand Up @@ -191,7 +193,7 @@ func (s *shipper) Publish(ctx context.Context, batch publisher.Batch) error {
droppedCount := 0

for i, e := range events {
converted, err := toShipperEvent(e)
converted, err := shipperProcessor(e)
if err != nil {
// conversion errors are not recoverable, so we have to drop the event completely
s.log.Errorf("%d/%d: %q, dropped", i+1, len(events), err)
Expand Down Expand Up @@ -234,7 +236,7 @@ func (s *shipper) Publish(ctx context.Context, batch publisher.Batch) error {
}
toSend = toSend[publishReply.AcceptedCount:]
lastAcceptedIndex = publishReply.AcceptedIndex
s.log.Debugf("%d events have been accepted during a publish request", len(toSend))
s.log.Debugf("%d events have been accepted during a publish request", publishReply.AcceptedCount)
}

s.log.Debugf("total of %d events have been accepted from batch, %d dropped", convertedCount, droppedCount)
Expand Down Expand Up @@ -322,44 +324,13 @@ func (s *shipper) ackLoop(ctx context.Context, ackClient sc.Producer_PersistedIn
}
}

func convertMapStr(m mapstr.M) (*messages.Value, error) {
if m == nil {
return helpers.NewNullValue(), nil
}

fields := make(map[string]*messages.Value, len(m))

for key, value := range m {
var (
protoValue *messages.Value
err error
)
switch v := value.(type) {
case mapstr.M:
protoValue, err = convertMapStr(v)
default:
protoValue, err = helpers.NewValue(v)
}
if err != nil {
return nil, err
}
fields[key] = protoValue
}

s := &messages.Struct{
Data: fields,
}

return helpers.NewStructValue(s), nil
}

func toShipperEvent(e publisher.Event) (*messages.Event, error) {
meta, err := convertMapStr(e.Content.Meta)
meta, err := helpers.NewValue(e.Content.Meta)
if err != nil {
return nil, fmt.Errorf("failed to convert event metadata to protobuf: %w", err)
}

fields, err := convertMapStr(e.Content.Fields)
fields, err := helpers.NewValue(e.Content.Fields)
if err != nil {
return nil, fmt.Errorf("failed to convert event fields to protobuf: %w", err)
}
Expand Down
Loading

0 comments on commit 92a39e2

Please sign in to comment.