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
1,392 changes: 578 additions & 814 deletions .golangci.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ integration-test: $(SELECTED_PACKAGE) build-mock-management-plane-grpc
TEST_ENV="Container" CONTAINER_OS_TYPE=$(CONTAINER_OS_TYPE) BUILD_TARGET="install-agent-local" CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} \
PACKAGES_REPO=$(OSS_PACKAGES_REPO) PACKAGE_NAME=$(PACKAGE_NAME) BASE_IMAGE=$(BASE_IMAGE) DOCKERFILE_PATH=$(DOCKERFILE_PATH) IMAGE_PATH=$(IMAGE_PATH) TAG=${IMAGE_TAG} \
OS_VERSION=$(OS_VERSION) OS_RELEASE=$(OS_RELEASE) \
go test -v ./test/integration/installuninstall ./test/integration/managementplane ./test/integration/nginxless
go test -v ./test/integration/installuninstall ./test/integration/managementplane ./test/integration/auxiliarycommandserver ./test/integration/nginxless

official-image-integration-test: $(SELECTED_PACKAGE) build-mock-management-plane-grpc
TEST_ENV="Container" CONTAINER_OS_TYPE=$(CONTAINER_OS_TYPE) CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} BUILD_TARGET="install" \
PACKAGES_REPO=$(OSS_PACKAGES_REPO) TAG=${TAG} PACKAGE_NAME=$(PACKAGE_NAME) BASE_IMAGE=$(BASE_IMAGE) DOCKERFILE_PATH=$(OFFICIAL_IMAGE_DOCKERFILE_PATH) \
OS_VERSION=$(OS_VERSION) OS_RELEASE=$(OS_RELEASE) IMAGE_PATH=$(IMAGE_PATH) \
go test -v ./test/integration/managementplane
go test -v ./test/integration/managementplane ./test/integration/auxiliarycommandserver

performance-test:
@mkdir -p $(TEST_BUILD_DIR)
Expand Down
101 changes: 11 additions & 90 deletions Makefile.packaging
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ AZURE_PACKAGES_DIR := ./build/azure/packages
BINARY_PATH := $(BUILD_DIR)/$(BINARY_NAME)
GPG_PUBLIC_KEY := .key
PACKAGE_BUILD ?= 1
PACKAGE_VERSION := $(shell echo ${VERSION} | tr -d 'v')
PACKAGE_VERSION := $(shell git describe --match "v[0-9]*" --abbrev=0 --tags)
TARBALL_NAME := $(PACKAGE_PREFIX).tar.gz

DEB_DISTROS ?= ubuntu-noble-24.04 ubuntu-jammy-22.04 ubuntu-focal-20.04 debian-bookworm-12 debian-bullseye-11
DEB_DISTROS ?= ubuntu-plucky-25.04 ubuntu-noble-24.04 ubuntu-jammy-22.04 ubuntu-focal-20.04 debian-bookworm-12 debian-bullseye-11
DEB_ARCHS ?= arm64 amd64
RPM_DISTROS ?= oraclelinux-8-x86_64 oraclelinux-9-x86_64 suse-15-x86_64
RPM_DISTROS ?= suse-15-x86_64
RPM_ARCH := x86_64
REDHAT_VERSIONS ?= redhatenterprise-8 redhatenterprise-9
REDHAT_VERSIONS ?= redhatenterprise-8 redhatenterprise-9 redhatenterprise-10
REDHAT_ARCHS ?= aarch64 x86_64
ROCKY_VERSIONS ?= rocky-8 rocky-9
ROCKY_ARCHS ?= aarch64 x86_64
FREEBSD_DISTROS ?= "FreeBSD:13:amd64" "FreeBSD:14:amd64"
APK_VERSIONS ?= 3.18 3.19 3.20 3.21 3.22
APK_ARCHS ?= aarch64 x86_64
APK_REVISION ?= 1
ALMA_VERSIONS ?= almalinux-8 almalinux-9
ALMA_ARCHS ?= aarch64 x86_64
AMAZON_VERSIONS ?= amazon-2 amazon-2023
AMAZON_ARCHS ?= aarch64 x86_64

Expand All @@ -35,55 +30,38 @@ AMAZON_ARCHS ?= aarch64 x86_64
.PHONY: clean-packages
clean-packages:
rm -rf $(PACKAGES_DIR)
rm -rf $(GITHUB_PACKAGES_DIR)
rm -rf $(AZURE_PACKAGES_DIR)

$(PACKAGES_DIR):
@mkdir -p $(PACKAGES_DIR)/deb && mkdir -p $(PACKAGES_DIR)/rpm && mkdir -p $(PACKAGES_DIR)/apk && mkdir -p $(PACKAGES_DIR)/txz

$(GITHUB_PACKAGES_DIR):
@mkdir -p $(GITHUB_PACKAGES_DIR)

$(AZURE_PACKAGES_DIR):
@mkdir -p $(AZURE_PACKAGES_DIR)
@mkdir -p $(PACKAGES_DIR)/deb && mkdir -p $(PACKAGES_DIR)/rpm && mkdir -p $(PACKAGES_DIR)/apk

.PHONY: package
package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) #### Create final packages for all supported distros
package: $(PACKAGES_DIR) #### Create final packages for all supported distros
# Create deb packages

@for arch in $(DEB_ARCHS); do \
GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE); \
for distro in $(DEB_DISTROS); do \
deb_codename=`echo $$distro | cut -d- -f 2`; \
VERSION=$(PACKAGE_VERSION)~$${deb_codename} ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager deb --target ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(PACKAGE_VERSION)~$${deb_codename}_$${arch}.deb; \
cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(PACKAGE_VERSION)~$${deb_codename}_$${arch}.deb ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION)~$${deb_codename}_$${arch}.deb; \
cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(PACKAGE_VERSION)~$${deb_codename}_$${arch}.deb ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION)~$${deb_codename}_$${arch}.deb; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create rpm packages

@GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE)
@for distro in $(RPM_DISTROS); do \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename='na'; \
if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \
elif [ "$$rpm_distro" = "oraclelinux" ]; then rpm_codename="oraclelinux$$rpm_major"; \
elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \
if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \
fi; \
if [ "$$rpm_codename" != "na" ]; then \
VERSION=$(PACKAGE_VERSION) ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.${RPM_ARCH}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$(RPM_ARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.${RPM_ARCH}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$(RPM_ARCH).rpm ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.${RPM_ARCH}.rpm; \
fi; \
done; \
rm -rf $(BINARY_PATH)


# Create redhat rpm packages

@for arch in $(REDHAT_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
Expand All @@ -93,49 +71,12 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) ##
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename="el$$rpm_major"; \
VERSION=$(PACKAGE_VERSION) ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create almalinux rpm packages

@for arch in $(ALMA_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
GOWORK=off CGO_ENABLED=0 GOARCH=$${goarch} GOOS=linux go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE); \
for distro in $(ALMA_VERSIONS); do \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename="almalinux$$rpm_major"; \
VERSION=$(PACKAGE_VERSION) ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create rocky rpm packages

@for arch in $(ROCKY_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
GOWORK=off CGO_ENABLED=0 GOARCH=$${goarch} GOOS=linux go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE); \
for distro in $(ROCKY_VERSIONS); do \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename='na'; \
if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \
if [ "$$rpm_codename" != "na" ]; then \
VERSION=$(PACKAGE_VERSION) ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
fi; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create amazon rpm packages
@for arch in $(AMAZON_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
Expand All @@ -144,34 +85,22 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) ##
rpm_major=`echo $$version | cut -d- -f 2`; \
rpm_codename="amzn$$rpm_major";\
VERSION=$(PACKAGE_VERSION) ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).$${rpm_codename}.ngx.$${arch}.rpm; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create apk packages

@for arch in $(APK_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
GOWORK=off CGO_ENABLED=0 GOARCH=$${goarch} GOOS=linux go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE); \
for version in $(APK_VERSIONS); do \
if [ ! -d "$(PACKAGES_DIR)/apk/v$${version}/$${arch}" ]; then mkdir -p $(PACKAGES_DIR)/apk/v$${version}/$${arch}; fi; \
VERSION=$(PACKAGE_VERSION) ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager apk --target $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).apk; \
cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).apk ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-v$(PACKAGE_VERSION)-r$(APK_REVISION).apk; \
cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(PACKAGE_VERSION).apk ${AZURE_PACKAGES_DIR}/${PACKAGE_PREFIX}-v$(PACKAGE_VERSION)-r$(APK_REVISION).apk; \
done; \
rm -rf $(BINARY_PATH); \
done; \

# Create txz packages

rm -rf $(BINARY_PATH)
@GOWORK=off CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -pgo=auto -ldflags=${LDFLAGS} -o $(BINARY_PATH) $(PROJECT_DIR)/$(PROJECT_FILE)

docker run -v ${PWD}:/nginx-agent/ -e VERSION=$(PACKAGE_VERSION) build-signed-packager:1.0.0


# Package build complete

echo "DEB packages:"; \
Expand All @@ -180,17 +109,9 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) ##
find $(PACKAGES_DIR)/rpm ;\
echo "APK packages:"; \
find $(PACKAGES_DIR)/apk ;\
echo "TXZ packages:"; \
find $(PACKAGES_DIR)/txz ;\
echo "Github packages:"; \
find $(GITHUB_PACKAGES_DIR) ;\
cd $(PACKAGES_DIR) && tar -czvf "./$(TARBALL_NAME)" * && cd ../.. && cp "${PACKAGES_DIR}/$(TARBALL_NAME)" "${AZURE_PACKAGES_DIR}/$(TARBALL_NAME)"; \
echo "Azure packages:"; \
find $(AZURE_PACKAGES_DIR) ;

.PHONY: build-signed-packager
build-signed-packager:
docker build -f scripts/packages/packager/Dockerfile --build-arg package_type=signed-package -t build-signed-packager:1.0.0 .
# Create tarball containing all packages
cd $(PACKAGES_DIR) && tar -czvf "./$(TARBALL_NAME)" * && cd ../.. && cp "${PACKAGES_DIR}/$(TARBALL_NAME)"; \

.PHONY: gpg-key
gpg-key: ## Generate GPG public key
Expand Down
2 changes: 1 addition & 1 deletion Makefile.tools
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OAPICODEGEN = github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0
LEFTHOOK = github.com/evilmartians/lefthook@v1.6.9
GOLANGCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
GOLANGCILINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1
PROTOCGENGO = google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0
GOFUMPT = mvdan.cc/gofumpt@v0.6.0
COUNTERFEITER = github.com/maxbrunsfeld/counterfeiter/v6@v6.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/nginx/agent/v3

go 1.23.7
go 1.24.0

toolchain go1.23.10
toolchain go1.24.4

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-20250130201111-63bb56e20495.1
Expand Down
20 changes: 10 additions & 10 deletions internal/bus/message_pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ func (p *MessagePipe) IsPluginRegistered(pluginName string) bool {
return isPluginRegistered
}

func (p *MessagePipe) Index(pluginName string, plugins []Plugin) int {
for index, plugin := range plugins {
if pluginName == plugin.Info().Name {
return index
}
}

return -1
}

func (p *MessagePipe) unsubscribePlugin(ctx context.Context, index int, plugin Plugin) error {
if index != -1 {
p.plugins = append(p.plugins[:index], p.plugins[index+1:]...)
Expand Down Expand Up @@ -181,16 +191,6 @@ func (p *MessagePipe) findPlugins(pluginNames []string) []Plugin {
return plugins
}

func (p *MessagePipe) Index(pluginName string, plugins []Plugin) int {
for index, plugin := range plugins {
if pluginName == plugin.Info().Name {
return index
}
}

return -1
}

func (p *MessagePipe) initPlugins(ctx context.Context) {
for index, plugin := range p.plugins {
err := plugin.Init(ctx, p)
Expand Down
32 changes: 16 additions & 16 deletions internal/collector/logsgzipprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ func (p *logsGzipProcessor) ConsumeLogs(ctx context.Context, ld plog.Logs) error
return p.nextConsumer.ConsumeLogs(ctx, ld)
}

func (p *logsGzipProcessor) Capabilities() consumer.Capabilities {
return consumer.Capabilities{
MutatesData: true,
}
}

func (p *logsGzipProcessor) Start(ctx context.Context, _ component.Host) error {
p.settings.Logger.Info("Starting logs gzip processor")
return nil
}

func (p *logsGzipProcessor) Shutdown(ctx context.Context) error {
p.settings.Logger.Info("Shutting down logs gzip processor")
return nil
}

func (p *logsGzipProcessor) processLogRecords(logRecords plog.LogRecordSlice) error {
var errs error
// Filter out unsupported data types in the log before processing
Expand Down Expand Up @@ -164,19 +180,3 @@ func (p *logsGzipProcessor) gzipCompress(data []byte) ([]byte, error) {

return buf.Bytes(), nil
}

func (p *logsGzipProcessor) Capabilities() consumer.Capabilities {
return consumer.Capabilities{
MutatesData: true,
}
}

func (p *logsGzipProcessor) Start(ctx context.Context, _ component.Host) error {
p.settings.Logger.Info("Starting logs gzip processor")
return nil
}

func (p *logsGzipProcessor) Shutdown(ctx context.Context) error {
p.settings.Logger.Info("Shutting down logs gzip processor")
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func generateLogs(numRecords, recordSize int) plog.Logs {
logs := plog.NewLogs()
rl := logs.ResourceLogs().AppendEmpty()
sl := rl.ScopeLogs().AppendEmpty()
for i := 0; i < numRecords; i++ {
for range numRecords {
lr := sl.LogRecords().AppendEmpty()
content, _ := randomString(recordSize)
lr.Body().SetStr(content)
Expand Down Expand Up @@ -64,7 +64,7 @@ func BenchmarkGzipProcessor(b *testing.B) {
logs := generateLogs(bm.numRecords, bm.recordSize)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
_ = p.ConsumeLogs(context.Background(), logs)
}
})
Expand Down
2 changes: 1 addition & 1 deletion internal/collector/nginxossreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
func TestType(t *testing.T) {
factory := NewFactory()
ft := factory.Type()
require.EqualValues(t, metadata.Type, ft)
require.Equal(t, metadata.Type, ft)
}

func TestValidConfig(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ func (nls *NginxLogScraper) Shutdown(_ context.Context) error {
return err
}

func (nls *NginxLogScraper) ConsumerCallback(_ context.Context, entries []*entry.Entry) {
nls.mut.Lock()
nls.entries = append(nls.entries, entries...)
nls.mut.Unlock()
}

func (nls *NginxLogScraper) initStanzaPipeline(
operators []operator.Config,
logger *zap.Logger,
Expand All @@ -248,12 +254,6 @@ func (nls *NginxLogScraper) initStanzaPipeline(
return pipe, err
}

func (nls *NginxLogScraper) ConsumerCallback(_ context.Context, entries []*entry.Entry) {
nls.mut.Lock()
nls.entries = append(nls.entries, entries...)
nls.mut.Unlock()
}

func (nls *NginxLogScraper) runConsumer(ctx context.Context) {
nls.logger.Info("Starting NGINX access log receiver's consumer")
defer nls.wg.Done()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import (

const operatorType = "access_log_file_input"

// Config is the configuration of a file input operator
type Config struct {
helper.InputConfig `mapstructure:",squash"`
AccessLogFormat string `mapstructure:"access_log_format"`
fileconsumer.Config `mapstructure:",squash"`
}

func init() {
operator.Register(operatorType, func() operator.Builder { return NewConfig() })
}
Expand All @@ -38,13 +45,6 @@ func NewConfigWithID(operatorID string) *Config {
}
}

// Config is the configuration of a file input operator
type Config struct {
helper.InputConfig `mapstructure:",squash"`
AccessLogFormat string `mapstructure:"access_log_format"`
fileconsumer.Config `mapstructure:",squash"`
}

// Build will build a file input operator from the supplied configuration
// nolint: ireturn
func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestNewConfig(t *testing.T) {
config := NewConfig()

assert.NotNil(t, config)
assert.Equal(t, "access_log_file_input", config.InputConfig.OperatorID)
assert.Equal(t, "access_log_file_input", config.OperatorID)
}

func TestConfig_Build(t *testing.T) {
Expand Down
Loading