From 549ba3925e046c3cd7c6a5336a2787fed9a962ec Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Fri, 27 Dec 2024 11:02:43 -0500 Subject: [PATCH] [jaegerreceiver] Remove unused remote sampling server Signed-off-by: Yuri Shkuro --- receiver/jaegerreceiver/jaeger_agent_test.go | 37 -------------------- receiver/jaegerreceiver/trace_receiver.go | 33 ++--------------- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/receiver/jaegerreceiver/jaeger_agent_test.go b/receiver/jaegerreceiver/jaeger_agent_test.go index 1c0765052ef1..6a2f1409aa44 100644 --- a/receiver/jaegerreceiver/jaeger_agent_test.go +++ b/receiver/jaegerreceiver/jaeger_agent_test.go @@ -5,9 +5,7 @@ package jaegerreceiver import ( "context" - "fmt" "net" - "net/http" "testing" "time" @@ -130,41 +128,6 @@ func (*mockSamplingHandler) GetSamplingStrategy(context.Context, *api_v2.Samplin return &api_v2.SamplingStrategyResponse{StrategyType: api_v2.SamplingStrategyType_PROBABILISTIC}, nil } -func TestJaegerHTTP(t *testing.T) { - s, _ := initializeGRPCTestServer(t, func(s *grpc.Server) { - api_v2.RegisterSamplingManagerServer(s, &mockSamplingHandler{}) - }) - defer s.GracefulStop() - - endpoint := testutil.GetAvailableLocalAddress(t) - config := &configuration{ - AgentHTTPEndpoint: endpoint, - } - set := receivertest.NewNopSettings() - jr, err := newJaegerReceiver(jaegerAgent, config, nil, set) - require.NoError(t, err) - t.Cleanup(func() { require.NoError(t, jr.Shutdown(context.Background())) }) - - assert.NoError(t, jr.Start(context.Background(), componenttest.NewNopHost()), "Start failed") - - // allow http server to start - assert.Eventually(t, func() bool { - var conn net.Conn - conn, err = net.Dial("tcp", endpoint) - if err == nil && conn != nil { - conn.Close() - return true - } - return false - }, 10*time.Second, 5*time.Millisecond, "failed to wait for the port to be open") - - resp, err := http.Get(fmt.Sprintf("http://%s/sampling?service=test", endpoint)) - assert.NoError(t, err, "should not have failed to make request") - assert.NotNil(t, resp) - defer resp.Body.Close() - assert.Equal(t, 500, resp.StatusCode, "should have returned 200") -} - func testJaegerAgent(t *testing.T, agentEndpoint string, receiverConfig *configuration) { // 1. Create the Jaeger receiver aka "server" sink := new(consumertest.TracesSink) diff --git a/receiver/jaegerreceiver/trace_receiver.go b/receiver/jaegerreceiver/trace_receiver.go index 3e3b44c83e72..feb39dc7c83d 100644 --- a/receiver/jaegerreceiver/trace_receiver.go +++ b/receiver/jaegerreceiver/trace_receiver.go @@ -15,8 +15,6 @@ import ( apacheThrift "github.com/apache/thrift/lib/go/thrift" "github.com/gorilla/mux" - "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" - "github.com/jaegertracing/jaeger/cmd/agent/app/httpserver" "github.com/jaegertracing/jaeger/cmd/agent/app/processors" "github.com/jaegertracing/jaeger/cmd/agent/app/servers" "github.com/jaegertracing/jaeger/cmd/agent/app/servers/thriftudp" @@ -24,7 +22,6 @@ import ( "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/proto-gen/api_v2" "github.com/jaegertracing/jaeger/thrift-gen/agent" - "github.com/jaegertracing/jaeger/thrift-gen/baggage" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" "go.opentelemetry.io/collector/component" @@ -48,7 +45,6 @@ type configuration struct { AgentCompactThrift ProtocolUDP AgentBinaryThrift ProtocolUDP - AgentHTTPEndpoint string } // Receiver type is used to receive spans that were originally intended to be sent to Jaeger. @@ -168,23 +164,10 @@ func consumeTraces(ctx context.Context, batch *jaeger.Batch, consumer consumer.T } var ( - _ agent.Agent = (*agentHandler)(nil) - _ api_v2.CollectorServiceServer = (*jReceiver)(nil) - _ configmanager.ClientConfigManager = (*notImplementedConfigManager)(nil) + _ agent.Agent = (*agentHandler)(nil) + _ api_v2.CollectorServiceServer = (*jReceiver)(nil) ) -var errNotImplemented = errors.New("not implemented") - -type notImplementedConfigManager struct{} - -func (notImplementedConfigManager) GetSamplingStrategy(_ context.Context, _ string) (*api_v2.SamplingStrategyResponse, error) { - return nil, errNotImplemented -} - -func (notImplementedConfigManager) GetBaggageRestrictions(_ context.Context, _ string) ([]*baggage.BaggageRestriction, error) { - return nil, errNotImplemented -} - type agentHandler struct { nextConsumer consumer.Traces obsrecv *receiverhelper.ObsReport @@ -277,18 +260,6 @@ func (jr *jReceiver) startAgent(host component.Host) error { }(processor) } - if jr.config.AgentHTTPEndpoint != "" { - jr.agentServer = httpserver.NewHTTPServer(jr.config.AgentHTTPEndpoint, ¬ImplementedConfigManager{}, metrics.NullFactory, jr.settings.Logger) - - jr.goroutines.Add(1) - go func() { - defer jr.goroutines.Done() - if err := jr.agentServer.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) && err != nil { - componentstatus.ReportStatus(host, componentstatus.NewFatalErrorEvent(fmt.Errorf("jaeger agent server error: %w", err))) - } - }() - } - return nil }