This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-go.git
The following commit(s) were added to refs/heads/main by this push:
new 14cdc63 Refactor: Replace emptyReporter with DiscardReporter (#218)
14cdc63 is described below
commit 14cdc630ceb6c82f35836effca47bc4b315ecc5a
Author: zhujiajun <[email protected]>
AuthorDate: Thu Apr 24 13:52:53 2025 +0800
Refactor: Replace emptyReporter with DiscardReporter (#218)
---
plugins/core/reporter/discard_reporter.go | 2 +-
plugins/core/reporter/discard_reporter_test.go | 4 ++--
plugins/core/tracer.go | 31 +-------------------------
3 files changed, 4 insertions(+), 33 deletions(-)
diff --git a/plugins/core/reporter/discard_reporter.go
b/plugins/core/reporter/discard_reporter.go
index 3531d46..4ac5cc1 100644
--- a/plugins/core/reporter/discard_reporter.go
+++ b/plugins/core/reporter/discard_reporter.go
@@ -39,7 +39,7 @@ func (r *discardReporter) SendLog(log *logv3.LogData) {
}
func (r *discardReporter) ConnectionStatus() ConnectionStatus {
// do nothing
- return 0
+ return ConnectionStatusDisconnect
}
func (r *discardReporter) Close() {
// do nothing
diff --git a/plugins/core/reporter/discard_reporter_test.go
b/plugins/core/reporter/discard_reporter_test.go
index 795ae7b..d097bcc 100644
--- a/plugins/core/reporter/discard_reporter_test.go
+++ b/plugins/core/reporter/discard_reporter_test.go
@@ -31,8 +31,8 @@ func TestDiscardReporter(t *testing.T) {
r.SendTracing(nil)
r.SendMetrics(nil)
r.SendLog(nil)
- if status := r.ConnectionStatus(); status != 0 {
- t.Errorf("expect 0, actual is %d", status)
+ if status := r.ConnectionStatus(); status !=
reporter.ConnectionStatusDisconnect {
+ t.Errorf("expect 2, actual is %d", status)
}
r.Close()
}
diff --git a/plugins/core/tracer.go b/plugins/core/tracer.go
index 38ae431..184f5c8 100644
--- a/plugins/core/tracer.go
+++ b/plugins/core/tracer.go
@@ -27,8 +27,6 @@ import (
"github.com/apache/skywalking-go/plugins/core/operator"
"github.com/apache/skywalking-go/plugins/core/reporter"
-
- logv3 "skywalking.apache.org/repo/goapi/collect/logging/v3"
)
// nolint
@@ -111,7 +109,7 @@ func NewEntity(service, instanceEnvName string)
*reporter.Entity {
func newTracer() *Tracer {
return &Tracer{
initFlag: 0,
- Reporter: &emptyReporter{},
+ Reporter: reporter.NewDiscardReporter(),
Sampler: NewConstSampler(false),
Log: &LogWrapper{newDefaultLogger()},
cdsWatchers: make([]reporter.AgentConfigChangeWatcher, 0),
@@ -129,33 +127,6 @@ func (t *Tracer) ChangeLogger(logger interface{}) {
t.Log.ChangeLogger(logger.(operator.LogOperator))
}
-// nolint
-type emptyReporter struct{}
-
-// nolint
-func (e *emptyReporter) Boot(entity *reporter.Entity, cdsWatchers
[]reporter.AgentConfigChangeWatcher) {
-}
-
-// nolint
-func (e *emptyReporter) SendTracing(spans []reporter.ReportedSpan) {
-}
-
-// nolint
-func (e *emptyReporter) SendMetrics(metrics []reporter.ReportedMeter) {
-}
-
-// nolint
-func (e *emptyReporter) SendLog(log *logv3.LogData) {
-}
-
-func (e *emptyReporter) ConnectionStatus() reporter.ConnectionStatus {
- return reporter.ConnectionStatusDisconnect
-}
-
-// nolint
-func (e *emptyReporter) Close() {
-}
-
type LogWrapper struct {
Logger operator.LogOperator
}