Skip to content

Commit

Permalink
[jaegerreceiver] Remove unused remote sampling server
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Dec 27, 2024
1 parent b53b5ad commit 549ba39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 68 deletions.
37 changes: 0 additions & 37 deletions receiver/jaegerreceiver/jaeger_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ package jaegerreceiver

import (
"context"
"fmt"
"net"
"net/http"
"testing"
"time"

Expand Down Expand Up @@ -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)
Expand Down
33 changes: 2 additions & 31 deletions receiver/jaegerreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ 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"
"github.com/jaegertracing/jaeger/model"
"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"
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -277,18 +260,6 @@ func (jr *jReceiver) startAgent(host component.Host) error {
}(processor)
}

if jr.config.AgentHTTPEndpoint != "" {
jr.agentServer = httpserver.NewHTTPServer(jr.config.AgentHTTPEndpoint, &notImplementedConfigManager{}, 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
}

Expand Down

0 comments on commit 549ba39

Please sign in to comment.