This is an automated email from the ASF dual-hosted git repository.
qiuxiafan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 119c4243 build(fodc): refactor the file structure for fodc agent (#916)
119c4243 is described below
commit 119c4243aa34c92e92ef60914c9a83b165019d40
Author: Fine0830 <[email protected]>
AuthorDate: Wed Dec 24 20:05:05 2025 +0800
build(fodc): refactor the file structure for fodc agent (#916)
---
Makefile | 6 +++---
fodc/{ => agent}/.gitignore | 0
fodc/{ => agent}/Dockerfile | 6 +++---
fodc/{ => agent}/Makefile | 25 ++++++++++++----------
fodc/{ => agent}/cmd/cli/main.go | 2 +-
fodc/{ => agent}/internal/cmd/root.go | 8 +++----
fodc/{ => agent}/internal/exporter/exporter.go | 4 ++--
.../{ => agent}/internal/exporter/exporter_test.go | 4 ++--
.../internal/exporter/prometheus_format_test.go | 4 ++--
.../internal/flightrecorder/datasource.go | 2 +-
.../internal/flightrecorder/datasource_test.go | 2 +-
.../internal/flightrecorder/flightrecorder.go | 2 +-
.../internal/flightrecorder/flightrecorder_test.go | 2 +-
.../internal/flightrecorder/ringbuffer.go | 0
.../internal/flightrecorder/ringbuffer_test.go | 0
.../integration/basic_metrics_buffering_test.go | 8 +++----
.../internal/integration/buffer_overflow_test.go | 8 +++----
.../internal/integration/capacity_heap_test.go | 6 +++---
.../internal/integration/integration_suite_test.go | 0
.../internal/integration/metrics_export_test.go | 10 ++++-----
fodc/{ => agent}/internal/metrics/parse.go | 0
fodc/{ => agent}/internal/metrics/parse_test.go | 0
fodc/{ => agent}/internal/server/server.go | 2 +-
fodc/{ => agent}/internal/server/server_test.go | 4 ++--
fodc/{ => agent}/internal/watchdog/watchdog.go | 2 +-
.../{ => agent}/internal/watchdog/watchdog_test.go | 4 ++--
26 files changed, 57 insertions(+), 54 deletions(-)
diff --git a/Makefile b/Makefile
index 9aabf231..4d22536d 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ endif
include scripts/build/version.mk
-PROJECTS := ui banyand bydbctl mcp fodc
+PROJECTS := ui banyand bydbctl mcp fodc/agent
TEST_CI_OPTS ?=
@@ -175,11 +175,11 @@ license-dep: default ## Fix license header issues
##@ Docker targets
docker.build: TARGET=docker
-docker.build: PROJECTS:= banyand bydbctl mcp fodc
+docker.build: PROJECTS:= banyand bydbctl mcp fodc/agent
docker.build: default ## Build docker images
docker.push: TARGET=docker.push
-docker.push: PROJECTS:= banyand bydbctl mcp fodc
+docker.push: PROJECTS:= banyand bydbctl mcp fodc/agent
docker.push: default ## Push docker images
default:
diff --git a/fodc/.gitignore b/fodc/agent/.gitignore
similarity index 100%
rename from fodc/.gitignore
rename to fodc/agent/.gitignore
diff --git a/fodc/Dockerfile b/fodc/agent/Dockerfile
similarity index 86%
rename from fodc/Dockerfile
rename to fodc/agent/Dockerfile
index ba6fb276..cfaba22d 100644
--- a/fodc/Dockerfile
+++ b/fodc/agent/Dockerfile
@@ -22,15 +22,15 @@ FROM busybox:stable-glibc AS build-linux
ARG TARGETARCH
-COPY build/bin/linux/${TARGETARCH}/fodc-cli-static /fodc
+COPY build/bin/linux/${TARGETARCH}/fodc-agent-cli-static /fodc-agent
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS build-windows
ARG TARGETARCH
-COPY build/bin/windows/${TARGETARCH}/fodc-cli-static "/fodc"
+COPY build/bin/windows/${TARGETARCH}/fodc-agent-cli-static "/fodc-agent"
FROM build-${TARGETOS} AS final
-ENTRYPOINT ["/fodc"]
+ENTRYPOINT ["/fodc-agent"]
diff --git a/fodc/Makefile b/fodc/agent/Makefile
similarity index 63%
rename from fodc/Makefile
rename to fodc/agent/Makefile
index 535c2ce6..ee3f8e6b 100644
--- a/fodc/Makefile
+++ b/fodc/agent/Makefile
@@ -16,19 +16,22 @@
# under the License.
#
-NAME := fodc
+NAME := fodc-agent
BINARIES := $(NAME)-cli
-IMG_NAME := skywalking-fodc
+IMG_NAME := skywalking-fodc-agent
-include ../scripts/build/version.mk
-include ../scripts/build/base.mk
-include ../scripts/build/generate_go.mk
-include ../scripts/build/build.mk
-include ../scripts/build/docker.mk
-include ../scripts/build/test.mk
-include ../scripts/build/lint.mk
-include ../scripts/build/vendor.mk
-include ../scripts/build/help.mk
+# Override SOURCE_DIR to match the actual Go module path structure
+SOURCE_DIR := fodc/agent
+
+include ../../scripts/build/version.mk
+include ../../scripts/build/base.mk
+include ../../scripts/build/generate_go.mk
+include ../../scripts/build/build.mk
+include ../../scripts/build/docker.mk
+include ../../scripts/build/test.mk
+include ../../scripts/build/lint.mk
+include ../../scripts/build/vendor.mk
+include ../../scripts/build/help.mk
prepare-build: generate
diff --git a/fodc/cmd/cli/main.go b/fodc/agent/cmd/cli/main.go
similarity index 94%
rename from fodc/cmd/cli/main.go
rename to fodc/agent/cmd/cli/main.go
index b21f7dd9..3b7ff99c 100644
--- a/fodc/cmd/cli/main.go
+++ b/fodc/agent/cmd/cli/main.go
@@ -22,7 +22,7 @@ import (
"fmt"
"os"
- "github.com/apache/skywalking-banyandb/fodc/internal/cmd"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/cmd"
)
func main() {
diff --git a/fodc/internal/cmd/root.go b/fodc/agent/internal/cmd/root.go
similarity index 95%
rename from fodc/internal/cmd/root.go
rename to fodc/agent/internal/cmd/root.go
index e32e2013..fa78ae68 100644
--- a/fodc/internal/cmd/root.go
+++ b/fodc/agent/internal/cmd/root.go
@@ -31,10 +31,10 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/server"
- "github.com/apache/skywalking-banyandb/fodc/internal/watchdog"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/server"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/watchdog"
"github.com/apache/skywalking-banyandb/pkg/cgroups"
"github.com/apache/skywalking-banyandb/pkg/logger"
"github.com/apache/skywalking-banyandb/pkg/version"
diff --git a/fodc/internal/exporter/exporter.go
b/fodc/agent/internal/exporter/exporter.go
similarity index 98%
rename from fodc/internal/exporter/exporter.go
rename to fodc/agent/internal/exporter/exporter.go
index 2b2af9bd..20569a19 100644
--- a/fodc/internal/exporter/exporter.go
+++ b/fodc/agent/internal/exporter/exporter.go
@@ -28,8 +28,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
var (
diff --git a/fodc/internal/exporter/exporter_test.go
b/fodc/agent/internal/exporter/exporter_test.go
similarity index 98%
rename from fodc/internal/exporter/exporter_test.go
rename to fodc/agent/internal/exporter/exporter_test.go
index 5b8f1a59..8d1aea78 100644
--- a/fodc/internal/exporter/exporter_test.go
+++ b/fodc/agent/internal/exporter/exporter_test.go
@@ -25,8 +25,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
func TestNewDatasourceCollector(t *testing.T) {
diff --git a/fodc/internal/exporter/prometheus_format_test.go
b/fodc/agent/internal/exporter/prometheus_format_test.go
similarity index 99%
rename from fodc/internal/exporter/prometheus_format_test.go
rename to fodc/agent/internal/exporter/prometheus_format_test.go
index d6e79bac..ea854a57 100644
--- a/fodc/internal/exporter/prometheus_format_test.go
+++ b/fodc/agent/internal/exporter/prometheus_format_test.go
@@ -28,8 +28,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
// TestPrometheusFormatConversion verifies that metrics from datasource are
correctly converted to Prometheus format.
diff --git a/fodc/internal/flightrecorder/datasource.go
b/fodc/agent/internal/flightrecorder/datasource.go
similarity index 99%
rename from fodc/internal/flightrecorder/datasource.go
rename to fodc/agent/internal/flightrecorder/datasource.go
index 8a39fd27..e8afff56 100644
--- a/fodc/internal/flightrecorder/datasource.go
+++ b/fodc/agent/internal/flightrecorder/datasource.go
@@ -22,7 +22,7 @@ import (
"fmt"
"sync"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
const (
diff --git a/fodc/internal/flightrecorder/datasource_test.go
b/fodc/agent/internal/flightrecorder/datasource_test.go
similarity index 99%
rename from fodc/internal/flightrecorder/datasource_test.go
rename to fodc/agent/internal/flightrecorder/datasource_test.go
index 9f3c93a3..b4daf441 100644
--- a/fodc/internal/flightrecorder/datasource_test.go
+++ b/fodc/agent/internal/flightrecorder/datasource_test.go
@@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
// TestDatasource_Update_TimestampBufferCapacity tests timestamp buffer
capacity adjustment.
diff --git a/fodc/internal/flightrecorder/flightrecorder.go
b/fodc/agent/internal/flightrecorder/flightrecorder.go
similarity index 97%
rename from fodc/internal/flightrecorder/flightrecorder.go
rename to fodc/agent/internal/flightrecorder/flightrecorder.go
index 3f1a8806..9709d063 100644
--- a/fodc/internal/flightrecorder/flightrecorder.go
+++ b/fodc/agent/internal/flightrecorder/flightrecorder.go
@@ -23,7 +23,7 @@ import (
"sync"
"time"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
// FlightRecorder buffers metrics data using fixed-size circular buffers with
in-memory storage.
diff --git a/fodc/internal/flightrecorder/flightrecorder_test.go
b/fodc/agent/internal/flightrecorder/flightrecorder_test.go
similarity index 99%
rename from fodc/internal/flightrecorder/flightrecorder_test.go
rename to fodc/agent/internal/flightrecorder/flightrecorder_test.go
index a0c4e65c..f8e301d3 100644
--- a/fodc/internal/flightrecorder/flightrecorder_test.go
+++ b/fodc/agent/internal/flightrecorder/flightrecorder_test.go
@@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
// TestNewFlightRecorder tests the creation of a new FlightRecorder instance.
diff --git a/fodc/internal/flightrecorder/ringbuffer.go
b/fodc/agent/internal/flightrecorder/ringbuffer.go
similarity index 100%
rename from fodc/internal/flightrecorder/ringbuffer.go
rename to fodc/agent/internal/flightrecorder/ringbuffer.go
diff --git a/fodc/internal/flightrecorder/ringbuffer_test.go
b/fodc/agent/internal/flightrecorder/ringbuffer_test.go
similarity index 100%
rename from fodc/internal/flightrecorder/ringbuffer_test.go
rename to fodc/agent/internal/flightrecorder/ringbuffer_test.go
diff --git a/fodc/internal/integration/basic_metrics_buffering_test.go
b/fodc/agent/internal/integration/basic_metrics_buffering_test.go
similarity index 97%
rename from fodc/internal/integration/basic_metrics_buffering_test.go
rename to fodc/agent/internal/integration/basic_metrics_buffering_test.go
index 9fc24b1b..9647e60a 100644
--- a/fodc/internal/integration/basic_metrics_buffering_test.go
+++ b/fodc/agent/internal/integration/basic_metrics_buffering_test.go
@@ -29,10 +29,10 @@ import (
. "github.com/onsi/gomega"
"github.com/prometheus/client_golang/prometheus"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/server"
- "github.com/apache/skywalking-banyandb/fodc/internal/watchdog"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/server"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/watchdog"
)
var _ = Describe("Test Case 1: Basic Metrics Buffering", func() {
diff --git a/fodc/internal/integration/buffer_overflow_test.go
b/fodc/agent/internal/integration/buffer_overflow_test.go
similarity index 97%
rename from fodc/internal/integration/buffer_overflow_test.go
rename to fodc/agent/internal/integration/buffer_overflow_test.go
index 7ead86f0..50e660fc 100644
--- a/fodc/internal/integration/buffer_overflow_test.go
+++ b/fodc/agent/internal/integration/buffer_overflow_test.go
@@ -29,10 +29,10 @@ import (
. "github.com/onsi/gomega"
"github.com/prometheus/client_golang/prometheus"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/server"
- "github.com/apache/skywalking-banyandb/fodc/internal/watchdog"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/server"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/watchdog"
)
var _ = Describe("Test Case 2: Buffer Overflow Handling", func() {
diff --git a/fodc/internal/integration/capacity_heap_test.go
b/fodc/agent/internal/integration/capacity_heap_test.go
similarity index 98%
rename from fodc/internal/integration/capacity_heap_test.go
rename to fodc/agent/internal/integration/capacity_heap_test.go
index bd0fe323..0fb0a512 100644
--- a/fodc/internal/integration/capacity_heap_test.go
+++ b/fodc/agent/internal/integration/capacity_heap_test.go
@@ -24,8 +24,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
// getConstantRawMetrics returns a constant set of rawMetrics for testing.
@@ -465,7 +465,7 @@ var _ = Describe("Test Case 4: Capacity Size and Heap Inuse
Size", func() {
heapInuseSizeAfterData, actualMemoryUsed, capacitySize)
// Step 7: Verify that memory usage is within reasonable bounds
relative to capacity
- // Allow some tolerance for overhead (maps, mutexes, etc.) -
should be within 30% of capacity
+ // Allow some tolerance for overhead (maps, mutexes, etc.) -
should be within 50% of capacity
Expect(actualMemoryUsed).To(BeNumerically(">", 0), "Actual
memory consumption should be positive")
Expect(actualMemoryUsed).To(BeNumerically("<=",
capacitySize*150/100),
"Actual memory consumption should not exceed
capacitySize by more than 50%")
diff --git a/fodc/internal/integration/integration_suite_test.go
b/fodc/agent/internal/integration/integration_suite_test.go
similarity index 100%
rename from fodc/internal/integration/integration_suite_test.go
rename to fodc/agent/internal/integration/integration_suite_test.go
diff --git a/fodc/internal/integration/metrics_export_test.go
b/fodc/agent/internal/integration/metrics_export_test.go
similarity index 98%
rename from fodc/internal/integration/metrics_export_test.go
rename to fodc/agent/internal/integration/metrics_export_test.go
index 29e25505..0e7fab8a 100644
--- a/fodc/internal/integration/metrics_export_test.go
+++ b/fodc/agent/internal/integration/metrics_export_test.go
@@ -31,11 +31,11 @@ import (
. "github.com/onsi/gomega"
"github.com/prometheus/client_golang/prometheus"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
- "github.com/apache/skywalking-banyandb/fodc/internal/server"
- "github.com/apache/skywalking-banyandb/fodc/internal/watchdog"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/server"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/watchdog"
)
// volatileMetricNames contains names of metrics that are known to be volatile
(gauges that change frequently).
diff --git a/fodc/internal/metrics/parse.go
b/fodc/agent/internal/metrics/parse.go
similarity index 100%
rename from fodc/internal/metrics/parse.go
rename to fodc/agent/internal/metrics/parse.go
diff --git a/fodc/internal/metrics/parse_test.go
b/fodc/agent/internal/metrics/parse_test.go
similarity index 100%
rename from fodc/internal/metrics/parse_test.go
rename to fodc/agent/internal/metrics/parse_test.go
diff --git a/fodc/internal/server/server.go
b/fodc/agent/internal/server/server.go
similarity index 98%
rename from fodc/internal/server/server.go
rename to fodc/agent/internal/server/server.go
index d245ca66..f9bfec97 100644
--- a/fodc/internal/server/server.go
+++ b/fodc/agent/internal/server/server.go
@@ -27,7 +27,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
"github.com/apache/skywalking-banyandb/pkg/logger"
)
diff --git a/fodc/internal/server/server_test.go
b/fodc/agent/internal/server/server_test.go
similarity index 97%
rename from fodc/internal/server/server_test.go
rename to fodc/agent/internal/server/server_test.go
index eef2aba4..0b7716cb 100644
--- a/fodc/internal/server/server_test.go
+++ b/fodc/agent/internal/server/server_test.go
@@ -25,8 +25,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/exporter"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/exporter"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
)
func TestNewServer_ValidConfig(t *testing.T) {
diff --git a/fodc/internal/watchdog/watchdog.go
b/fodc/agent/internal/watchdog/watchdog.go
similarity index 98%
rename from fodc/internal/watchdog/watchdog.go
rename to fodc/agent/internal/watchdog/watchdog.go
index f7b3f33a..fc6b5271 100644
--- a/fodc/internal/watchdog/watchdog.go
+++ b/fodc/agent/internal/watchdog/watchdog.go
@@ -26,7 +26,7 @@ import (
"sync"
"time"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
"github.com/apache/skywalking-banyandb/pkg/logger"
)
diff --git a/fodc/internal/watchdog/watchdog_test.go
b/fodc/agent/internal/watchdog/watchdog_test.go
similarity index 99%
rename from fodc/internal/watchdog/watchdog_test.go
rename to fodc/agent/internal/watchdog/watchdog_test.go
index 2c956456..a1ff21e6 100644
--- a/fodc/internal/watchdog/watchdog_test.go
+++ b/fodc/agent/internal/watchdog/watchdog_test.go
@@ -30,8 +30,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/apache/skywalking-banyandb/fodc/internal/flightrecorder"
- "github.com/apache/skywalking-banyandb/fodc/internal/metrics"
+
"github.com/apache/skywalking-banyandb/fodc/agent/internal/flightrecorder"
+ "github.com/apache/skywalking-banyandb/fodc/agent/internal/metrics"
)
const testMetricsCPUUsage = "cpu_usage 75.5"