Skip to content
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

Improve the go project layout #273

Merged
merged 4 commits into from
Jun 29, 2022
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 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- (Experimental) Support Protocol Dubbo2 ([#184](https://github.com/CloudDectective-Harmonycloud/kindling/pull/184))

### Enhancements
- Improve the go project layout ([#273](https://github.com/CloudDectective-Harmonycloud/kindling/pull/273))
- Correct the configurations and disable the `dubbo` protocol parser by default since it is still experimental now. ([#270](https://github.com/CloudDectective-Harmonycloud/kindling/pull/270))
- Implement self-metrics using opentelemetry for cgoreceiver ([#269](https://github.com/CloudDectective-Harmonycloud/kindling/pull/269))
- Use cgo to replace UDS for transferring data from the probe to the collector to improve the performance ([#264](https://github.com/CloudDectective-Harmonycloud/kindling/pull/264))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"

"github.com/Kindling-project/kindling/collector/application"
"github.com/Kindling-project/kindling/collector/version"
"github.com/Kindling-project/kindling/collector/internal/application"
"github.com/Kindling-project/kindling/collector/pkg/version"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion collector/collector-version-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GitCommit=$(git rev-parse --short HEAD || echo unsupported)
echo "Git commit:" $GitCommit
go build -o kindling-collector -ldflags="-X 'github.com/Kindling-project/kindling/collector/version.CodeVersion=$GitCommit'"
go build -o kindling-collector -ldflags="-X 'github.com/Kindling-project/kindling/collector/version.CodeVersion=$GitCommit'" ./cmd/kindling-collector/

3 changes: 1 addition & 2 deletions collector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ require (
github.com/hashicorp/golang-lru v0.5.4
github.com/mdlayher/netlink v1.6.0
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc
github.com/pebbe/zmq4 v1.2.7
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_golang v1.11.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.7.1
Expand Down
6 changes: 0 additions & 6 deletions collector/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc h1:Ak86L+yD
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pebbe/zmq4 v1.2.7 h1:6EaX83hdFSRUEhgzSW1E/SPoTS3JeYZgYkBvwdcrA9A=
github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48=
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
Expand Down Expand Up @@ -469,7 +467,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -578,7 +575,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand All @@ -591,7 +587,6 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -838,7 +833,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
"flag"
"fmt"

"github.com/Kindling-project/kindling/collector/analyzer"
"github.com/Kindling-project/kindling/collector/analyzer/loganalyzer"
"github.com/Kindling-project/kindling/collector/analyzer/network"
"github.com/Kindling-project/kindling/collector/analyzer/tcpconnectanalyzer"
"github.com/Kindling-project/kindling/collector/analyzer/tcpmetricanalyzer"
"github.com/Kindling-project/kindling/collector/component"
"github.com/Kindling-project/kindling/collector/consumer"
"github.com/Kindling-project/kindling/collector/consumer/exporter/logexporter"
"github.com/Kindling-project/kindling/collector/consumer/exporter/otelexporter"
"github.com/Kindling-project/kindling/collector/consumer/processor/aggregateprocessor"
"github.com/Kindling-project/kindling/collector/consumer/processor/k8sprocessor"
"github.com/Kindling-project/kindling/collector/receiver"
"github.com/Kindling-project/kindling/collector/receiver/cgoreceiver"
"github.com/Kindling-project/kindling/collector/pkg/component"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer/loganalyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer/network"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer/tcpconnectanalyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer/tcpmetricanalyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/exporter/logexporter"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/exporter/otelexporter"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/processor/aggregateprocessor"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/processor/k8sprocessor"
"github.com/Kindling-project/kindling/collector/pkg/component/receiver"
"github.com/Kindling-project/kindling/collector/pkg/component/receiver/cgoreceiver"
"github.com/spf13/viper"
"go.uber.org/multierr"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package application

import (
"github.com/Kindling-project/kindling/collector/analyzer"
"github.com/Kindling-project/kindling/collector/component"
"github.com/Kindling-project/kindling/collector/consumer"
"github.com/Kindling-project/kindling/collector/consumer/exporter"
"github.com/Kindling-project/kindling/collector/consumer/processor"
"github.com/Kindling-project/kindling/collector/receiver"
"github.com/Kindling-project/kindling/collector/pkg/component"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/exporter"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/processor"
"github.com/Kindling-project/kindling/collector/pkg/component/receiver"
"github.com/spf13/viper"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/Kindling-project/kindling/collector/consumer/processor/k8sprocessor"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/processor/k8sprocessor"
"github.com/spf13/viper"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
receivers:
udsreceiver:
zeromqpull:
endpoint: ipc:///home/kindling-sub/0
zeromqreq:
endpoint: ipc:///home/kindling/0
subscribe:
- name: syscall_exit-writev
category: net
- name: syscall_exit-readv
category: net
- name: syscall_exit-write
category: net
- name: syscall_exit-read
category: net
- name: syscall_exit-sendto
category: net
- name: syscall_exit-recvfrom
category: net
- name: syscall_exit-sendmsg
category: net
- name: syscall_exit-recvmsg
category: net
- name: grpc_uprobe
category: net
- name: kprobe-tcp_close
- name: kprobe-tcp_rcv_established
- name: kprobe-tcp_drop
- name: kprobe-tcp_retransmit_skb
cgoreceiver:
subscribe:
- name: syscall_exit-writev
category: net
- name: syscall_exit-readv
category: net
- name: syscall_exit-write
category: net
- name: syscall_exit-read
category: net
- name: syscall_exit-sendto
category: net
- name: syscall_exit-recvfrom
category: net
- name: syscall_exit-sendmsg
category: net
- name: syscall_exit-recvmsg
category: net
- name: kprobe-tcp_close
- name: kprobe-tcp_rcv_established
- name: kprobe-tcp_drop
- name: kprobe-tcp_retransmit_skb
- name: syscall_exit-connect
- name: kretprobe-tcp_connect
- name: kprobe-tcp_set_state
analyzers:
mockanalyzer:
num: 10
Expand Down
2 changes: 1 addition & 1 deletion collector/pkg/aggregator/aggregator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

type Aggregator interface {
Expand Down
3 changes: 2 additions & 1 deletion collector/pkg/aggregator/defaultaggregator/agg_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package defaultaggregator

import (
"errors"
"github.com/Kindling-project/kindling/collector/model"
"sync"
"sync/atomic"

"github.com/Kindling-project/kindling/collector/pkg/model"
)

type AggregatorKind int
Expand Down
5 changes: 3 additions & 2 deletions collector/pkg/aggregator/defaultaggregator/agg_values_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/stretchr/testify/assert"
"reflect"
"sync"
"testing"

"github.com/Kindling-project/kindling/collector/pkg/model"
"github.com/stretchr/testify/assert"
)

func startTask(workerNum int, task func(wg *sync.WaitGroup)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"sync/atomic"
"time"

"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

// DataGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"sync"

"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

// DataGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"sync"
"testing"
"time"

"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

func TestConcurrentAggregator(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions collector/pkg/aggregator/defaultaggregator/value_recorder.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"sync"

"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

type valueRecorder struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package defaultaggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"reflect"
"testing"

"github.com/Kindling-project/kindling/collector/pkg/aggregator"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

func TestRecord(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion collector/pkg/aggregator/label_key.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package aggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"sort"
"strconv"

"github.com/Kindling-project/kindling/collector/pkg/model"
)

type vType string
Expand Down
3 changes: 2 additions & 1 deletion collector/pkg/aggregator/label_key_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package aggregator

import (
"github.com/Kindling-project/kindling/collector/model"
"reflect"
"testing"

"github.com/Kindling-project/kindling/collector/pkg/model"
)

func TestLabelSelectors_GetLabelKeys(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package analyzer

import "github.com/Kindling-project/kindling/collector/model"
import "github.com/Kindling-project/kindling/collector/pkg/model"

type Type string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package loganalyzer

import (
"github.com/Kindling-project/kindling/collector/analyzer"
"github.com/Kindling-project/kindling/collector/component"
"github.com/Kindling-project/kindling/collector/consumer"
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/component"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer"
"github.com/Kindling-project/kindling/collector/pkg/model"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package analyzer
import (
"testing"

"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/model"
"github.com/stretchr/testify/assert"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"sync"
"time"

"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/model/constnames"
"github.com/Kindling-project/kindling/collector/model/constvalues"
"github.com/Kindling-project/kindling/collector/pkg/model"
"github.com/Kindling-project/kindling/collector/pkg/model/constnames"
"github.com/Kindling-project/kindling/collector/pkg/model/constvalues"
)

func createDataGroup() interface{} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"sync"
"time"

"github.com/Kindling-project/kindling/collector/metadata/conntracker"
"github.com/Kindling-project/kindling/collector/model"
"github.com/Kindling-project/kindling/collector/pkg/metadata/conntracker"
"github.com/Kindling-project/kindling/collector/pkg/model"
)

const (
Expand Down
Loading