From abaafddd7485f912cb860be70596329e02a78da8 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 28 Sep 2022 17:31:21 -0700 Subject: [PATCH] [pdata] Rename RegiserServer func to RegiserGRPCServer --- CHANGELOG.md | 4 ++++ config/configgrpc/configgrpc_test.go | 6 +++--- exporter/otlpexporter/otlp_test.go | 6 +++--- pdata/plog/plogotlp/logs.go | 7 +++++-- pdata/plog/plogotlp/logs_test.go | 4 ++-- pdata/pmetric/pmetricotlp/metrics.go | 7 +++++-- pdata/pmetric/pmetricotlp/metrics_test.go | 4 ++-- pdata/ptrace/ptraceotlp/traces.go | 7 +++++-- pdata/ptrace/ptraceotlp/traces_test.go | 4 ++-- receiver/otlpreceiver/internal/logs/otlp_test.go | 2 +- receiver/otlpreceiver/internal/metrics/otlp_test.go | 2 +- receiver/otlpreceiver/internal/trace/otlp_test.go | 2 +- receiver/otlpreceiver/otlp.go | 6 +++--- 13 files changed, 37 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b975e6c5a9..e782351d6ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### 🚩 Deprecations 🚩 + +- Deprecate `p[metric|log|trace]otlp.RegiserServer` in favor of `p[metric|log|trace]otlp.RegiserGRPCServer` (#6180) + ## v0.61.0 Beta ### 🛑 Breaking changes 🛑 diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 9dc4eb782d9..4ac4dccb869 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -566,7 +566,7 @@ func TestHttpReception(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) s := grpc.NewServer(opts...) - ptraceotlp.RegisterServer(s, &grpcTraceServer{}) + ptraceotlp.RegisterGRPCServer(s, &grpcTraceServer{}) go func() { _ = s.Serve(ln) @@ -615,7 +615,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) s := grpc.NewServer(opts...) - ptraceotlp.RegisterServer(s, &grpcTraceServer{}) + ptraceotlp.RegisterGRPCServer(s, &grpcTraceServer{}) go func() { _ = s.Serve(ln) @@ -811,7 +811,7 @@ func TestClientInfoInterceptors(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) require.NoError(t, err) srv := grpc.NewServer(opts...) - ptraceotlp.RegisterServer(srv, mock) + ptraceotlp.RegisterGRPCServer(srv, mock) defer srv.Stop() diff --git a/exporter/otlpexporter/otlp_test.go b/exporter/otlpexporter/otlp_test.go index 9cb9419d656..4fef073e261 100644 --- a/exporter/otlpexporter/otlp_test.go +++ b/exporter/otlpexporter/otlp_test.go @@ -115,7 +115,7 @@ func otlpTracesReceiverOnGRPCServer(ln net.Listener, useTLS bool) (*mockTracesRe } // Now run it as a gRPC server - ptraceotlp.RegisterServer(rcv.srv, rcv) + ptraceotlp.RegisterGRPCServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -155,7 +155,7 @@ func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver { } // Now run it as a gRPC server - plogotlp.RegisterServer(rcv.srv, rcv) + plogotlp.RegisterGRPCServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -195,7 +195,7 @@ func otlpMetricsReceiverOnGRPCServer(ln net.Listener) *mockMetricsReceiver { } // Now run it as a gRPC server - pmetricotlp.RegisterServer(rcv.srv, rcv) + pmetricotlp.RegisterGRPCServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() diff --git a/pdata/plog/plogotlp/logs.go b/pdata/plog/plogotlp/logs.go index 36bd9579d92..0b5147db65b 100644 --- a/pdata/plog/plogotlp/logs.go +++ b/pdata/plog/plogotlp/logs.go @@ -155,11 +155,14 @@ type GRPCServer interface { // Deprecated: [0.61.0] Use GRPCServer instead type Server = GRPCServer -// RegisterServer registers the Server to the grpc.Server. -func RegisterServer(s *grpc.Server, srv GRPCServer) { +// RegisterGRPCServer registers the Server to the grpc.Server. +func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { otlpcollectorlog.RegisterLogsServiceServer(s, &rawLogsServer{srv: srv}) } +// Deprecated: [0.62.0] Use RegisterGRPCServer instead +var RegisterServer = RegisterGRPCServer + type rawLogsServer struct { srv GRPCServer } diff --git a/pdata/plog/plogotlp/logs_test.go b/pdata/plog/plogotlp/logs_test.go index d0980933a9c..58b29bdb286 100644 --- a/pdata/plog/plogotlp/logs_test.go +++ b/pdata/plog/plogotlp/logs_test.go @@ -83,7 +83,7 @@ func TestRequestJSON(t *testing.T) { func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeLogsServer{t: t}) + RegisterGRPCServer(s, &fakeLogsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -116,7 +116,7 @@ func TestGrpc(t *testing.T) { func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeLogsServer{t: t, err: errors.New("my error")}) + RegisterGRPCServer(s, &fakeLogsServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { diff --git a/pdata/pmetric/pmetricotlp/metrics.go b/pdata/pmetric/pmetricotlp/metrics.go index 65203cc7aee..6926ea3f39a 100644 --- a/pdata/pmetric/pmetricotlp/metrics.go +++ b/pdata/pmetric/pmetricotlp/metrics.go @@ -151,11 +151,14 @@ type GRPCServer interface { // Deprecated: [0.61.0] Use GRPCServer instead type Server = GRPCServer -// RegisterServer registers the GRPCServer to the grpc.Server. -func RegisterServer(s *grpc.Server, srv GRPCServer) { +// RegisterGRPCServer registers the GRPCServer to the grpc.Server. +func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { otlpcollectormetrics.RegisterMetricsServiceServer(s, &rawMetricsServer{srv: srv}) } +// Deprecated: [0.62.0] Use RegisterGRPCServer instead +var RegisterServer = RegisterGRPCServer + type rawMetricsServer struct { srv Server } diff --git a/pdata/pmetric/pmetricotlp/metrics_test.go b/pdata/pmetric/pmetricotlp/metrics_test.go index 642572ad481..fbe94173716 100644 --- a/pdata/pmetric/pmetricotlp/metrics_test.go +++ b/pdata/pmetric/pmetricotlp/metrics_test.go @@ -79,7 +79,7 @@ func TestRequestJSON(t *testing.T) { func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeMetricsServer{t: t}) + RegisterGRPCServer(s, &fakeMetricsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -112,7 +112,7 @@ func TestGrpc(t *testing.T) { func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeMetricsServer{t: t, err: errors.New("my error")}) + RegisterGRPCServer(s, &fakeMetricsServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { diff --git a/pdata/ptrace/ptraceotlp/traces.go b/pdata/ptrace/ptraceotlp/traces.go index 37dd41c00d2..d97fbc2812e 100644 --- a/pdata/ptrace/ptraceotlp/traces.go +++ b/pdata/ptrace/ptraceotlp/traces.go @@ -156,11 +156,14 @@ type GRPCServer interface { // Deprecated: [0.61.0] Use GRPCServer instead type Server = GRPCServer -// RegisterServer registers the GRPCServer to the grpc.Server. -func RegisterServer(s *grpc.Server, srv GRPCServer) { +// RegisterGRPCServer registers the GRPCServer to the grpc.Server. +func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { otlpcollectortrace.RegisterTraceServiceServer(s, &rawTracesServer{srv: srv}) } +// Deprecated: [0.62.0] Use RegisterGRPCServer instead +var RegisterServer = RegisterGRPCServer + type rawTracesServer struct { srv GRPCServer } diff --git a/pdata/ptrace/ptraceotlp/traces_test.go b/pdata/ptrace/ptraceotlp/traces_test.go index 13767cfb60e..de82ba4b71d 100644 --- a/pdata/ptrace/ptraceotlp/traces_test.go +++ b/pdata/ptrace/ptraceotlp/traces_test.go @@ -83,7 +83,7 @@ func TestRequestJSON(t *testing.T) { func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeTracesServer{t: t}) + RegisterGRPCServer(s, &fakeTracesServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -116,7 +116,7 @@ func TestGrpc(t *testing.T) { func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterServer(s, &fakeTracesServer{t: t, err: errors.New("my error")}) + RegisterGRPCServer(s, &fakeTracesServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { diff --git a/receiver/otlpreceiver/internal/logs/otlp_test.go b/receiver/otlpreceiver/internal/logs/otlp_test.go index 4c219dce29c..c2483d6816a 100644 --- a/receiver/otlpreceiver/internal/logs/otlp_test.go +++ b/receiver/otlpreceiver/internal/logs/otlp_test.go @@ -92,7 +92,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, lc consumer.Logs) net.Addr { r := New(config.NewComponentIDWithName("otlp", "log"), lc, componenttest.NewNopReceiverCreateSettings()) // Now run it as a gRPC server srv := grpc.NewServer() - plogotlp.RegisterServer(srv, r) + plogotlp.RegisterGRPCServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/internal/metrics/otlp_test.go b/receiver/otlpreceiver/internal/metrics/otlp_test.go index bca9909ca1e..8eea97e23af 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp_test.go +++ b/receiver/otlpreceiver/internal/metrics/otlp_test.go @@ -93,7 +93,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) net.Addr { r := New(config.NewComponentIDWithName("otlp", "metrics"), mc, componenttest.NewNopReceiverCreateSettings()) // Now run it as a gRPC server srv := grpc.NewServer() - pmetricotlp.RegisterServer(srv, r) + pmetricotlp.RegisterGRPCServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/internal/trace/otlp_test.go b/receiver/otlpreceiver/internal/trace/otlp_test.go index 09d6bec9bc7..2d8306645e3 100644 --- a/receiver/otlpreceiver/internal/trace/otlp_test.go +++ b/receiver/otlpreceiver/internal/trace/otlp_test.go @@ -90,7 +90,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) net.Addr { r := New(config.NewComponentIDWithName("otlp", "trace"), tc, componenttest.NewNopReceiverCreateSettings()) // Now run it as a gRPC server srv := grpc.NewServer() - ptraceotlp.RegisterServer(srv, r) + ptraceotlp.RegisterGRPCServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index 0156cb2e106..2806c627a92 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -113,15 +113,15 @@ func (r *otlpReceiver) startProtocolServers(host component.Host) error { r.serverGRPC = grpc.NewServer(opts...) if r.traceReceiver != nil { - ptraceotlp.RegisterServer(r.serverGRPC, r.traceReceiver) + ptraceotlp.RegisterGRPCServer(r.serverGRPC, r.traceReceiver) } if r.metricsReceiver != nil { - pmetricotlp.RegisterServer(r.serverGRPC, r.metricsReceiver) + pmetricotlp.RegisterGRPCServer(r.serverGRPC, r.metricsReceiver) } if r.logReceiver != nil { - plogotlp.RegisterServer(r.serverGRPC, r.logReceiver) + plogotlp.RegisterGRPCServer(r.serverGRPC, r.logReceiver) } err = r.startGRPCServer(r.cfg.GRPC, host)