Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ func BuildSystemTestBinary() error {
return BuildSystemTestGoBinary(DefaultTestBinaryArgs())
}

// BuildSystemTestOTelBinary builds beat binary that includes otel.
func BuildSystemTestOTelBinary() error {
args := DefaultTestBinaryArgs()
args.ExtraFlags = []string{"-tags", "otelbeat"}
return BuildSystemTestGoBinary(args)
}

// BuildSystemTestGoBinary build a binary for testing that is instrumented for
// testing and measuring code coverage. The binary is only instrumented for
// coverage when TEST_COVERAGE=true (default is false).
Expand Down
44 changes: 0 additions & 44 deletions x-pack/filebeat/cmd/otel_test.go

This file was deleted.

15 changes: 15 additions & 0 deletions x-pack/filebeat/cmd/otelcmd_disabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

//go:build !otelbeat

package cmd

import (
cmd "github.com/elastic/beats/v7/libbeat/cmd"
)

func addOTelCommand(command *cmd.BeatsRootCmd) {
// No-op
}
17 changes: 17 additions & 0 deletions x-pack/filebeat/cmd/otelcmd_enabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.

//go:build otelbeat

package cmd

import (
fbcmd "github.com/elastic/beats/v7/filebeat/cmd"
cmd "github.com/elastic/beats/v7/libbeat/cmd"
"github.com/elastic/beats/v7/x-pack/libbeat/common/otelbeat"
)

func addOTelCommand(command *cmd.BeatsRootCmd) {
command.AddCommand(otelbeat.OTelCmd(fbcmd.Name))
}
3 changes: 1 addition & 2 deletions x-pack/filebeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/elastic/beats/v7/libbeat/publisher/processing"
"github.com/elastic/beats/v7/x-pack/filebeat/include"
inputs "github.com/elastic/beats/v7/x-pack/filebeat/input/default-inputs"
"github.com/elastic/beats/v7/x-pack/libbeat/common/otelbeat"
"github.com/elastic/beats/v7/x-pack/libbeat/management"

// Register the includes.
Expand All @@ -41,7 +40,7 @@ func Filebeat() *cmd.BeatsRootCmd {
command.PersistentPreRun = func(cmd *cobra.Command, args []string) {
management.ConfigTransform.SetTransform(filebeatCfg)
}
command.AddCommand(otelbeat.OTelCmd(fbcmd.Name))
addOTelCommand(command)
return command
}

Expand Down
13 changes: 11 additions & 2 deletions x-pack/filebeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ func Build() error {
return devtools.Build(devtools.DefaultBuildArgs())
}

// BuildOTel builds the Beat binary with OTel sub command
func BuildOTel() error {
args := devtools.DefaultBuildArgs()
args.ExtraFlags = append(args.ExtraFlags, "-tags", "otelbeat")
return devtools.Build(args)
}

// BuildSystemTestBinary builds a binary instrumented for use with Python system tests.
func BuildSystemTestBinary() error {
return devtools.BuildSystemTestBinary()
Expand Down Expand Up @@ -168,13 +175,15 @@ func IntegTest() {

// GoIntegTest starts the docker containers and executes the Go integration tests.
func GoIntegTest(ctx context.Context) error {
mg.Deps(BuildSystemTestBinary)
// build integration test binary with otel sub command
devtools.BuildSystemTestOTelBinary()
return devtools.GoIntegTestFromHost(ctx, devtools.DefaultGoTestIntegrationFromHostArgs())
}

// GoFIPSOnlyIntegTest starts the docker containers and executes the Go integration tests with GODEBUG=fips140=only set.
func GoFIPSOnlyIntegTest(ctx context.Context) error {
mg.Deps(BuildSystemTestBinary)
// build integration test binary with otel sub command
devtools.BuildSystemTestOTelBinary()
return devtools.GoIntegTestFromHost(ctx, devtools.FIPSOnlyGoTestIntegrationFromHostArgs())
}

Expand Down