Skip to content

Commit

Permalink
Remove obsreport.GRPCServerWithObservabilityEnabled, enable observabi…
Browse files Browse the repository at this point in the history
…lity in config (#3315)

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored May 26, 2021
1 parent 4f4fa63 commit 56be32d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 49 deletions.
5 changes: 5 additions & 0 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strings"
"time"

"go.opencensus.io/plugin/ocgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -307,6 +308,10 @@ func (gss *GRPCServerSettings) ToServerOption(ext map[config.ComponentID]compone
)
}

// Enable OpenCensus observability plugin.
// TODO: Change to OpenTelemetry when collector is changed.
opts = append(opts, grpc.StatsHandler(&ocgrpc.ServerHandler{}))

return opts, nil
}

Expand Down
4 changes: 2 additions & 2 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestDefaultGrpcServerSettings(t *testing.T) {
gss := &GRPCServerSettings{}
opts, err := gss.ToServerOption(map[config.ComponentID]component.Extension{})
assert.NoError(t, err)
assert.Len(t, opts, 0)
assert.Len(t, opts, 1)
}

func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
}
opts, err := gss.ToServerOption(map[config.ComponentID]component.Extension{})
assert.NoError(t, err)
assert.Len(t, opts, 7)
assert.Len(t, opts, 8)
}

func TestGrpcServerAuthSettings(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions exporter/otlpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/pdatagrpc"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
)

type mockReceiver struct {
Expand Down Expand Up @@ -76,7 +75,7 @@ func (r *mockTracesReceiver) GetLastRequest() pdata.Traces {
func otlpTracesReceiverOnGRPCServer(ln net.Listener) *mockTracesReceiver {
rcv := &mockTracesReceiver{
mockReceiver: mockReceiver{
srv: obsreport.GRPCServerWithObservabilityEnabled(),
srv: grpc.NewServer(),
},
}

Expand Down Expand Up @@ -113,7 +112,7 @@ func (r *mockLogsReceiver) GetLastRequest() pdata.Logs {
func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver {
rcv := &mockLogsReceiver{
mockReceiver: mockReceiver{
srv: obsreport.GRPCServerWithObservabilityEnabled(),
srv: grpc.NewServer(),
},
}

Expand Down Expand Up @@ -151,7 +150,7 @@ func (r *mockMetricsReceiver) GetLastRequest() pdata.Metrics {
func otlpMetricsReceiverOnGRPCServer(ln net.Listener) *mockMetricsReceiver {
rcv := &mockMetricsReceiver{
mockReceiver: mockReceiver{
srv: obsreport.GRPCServerWithObservabilityEnabled(),
srv: grpc.NewServer(),
},
}

Expand Down
31 changes: 0 additions & 31 deletions obsreport/observability.go

This file was deleted.

3 changes: 1 addition & 2 deletions receiver/opencensusreceiver/ocmetrics/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/exporter/opencensusexporter"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/translator/internaldata"
)

Expand Down Expand Up @@ -365,7 +364,7 @@ func ocReceiverOnGRPCServer(t *testing.T, sr consumer.Metrics) (net.Addr, func()
require.NoError(t, err, "Failed to create the Receiver: %v", err)

// Now run it as a gRPC server
srv := obsreport.GRPCServerWithObservabilityEnabled()
srv := grpc.NewServer()
agentmetricspb.RegisterMetricsServiceServer(srv, oci)
go func() {
_ = srv.Serve(ln)
Expand Down
4 changes: 2 additions & 2 deletions receiver/opencensusreceiver/octrace/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opencensus.io/plugin/ocgrpc"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
Expand All @@ -40,7 +41,6 @@ import (
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/exporter/opencensusexporter"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/translator/internaldata"
)

Expand Down Expand Up @@ -378,7 +378,7 @@ func ocReceiverOnGRPCServer(t *testing.T, sr consumer.Traces) (net.Addr, func())
require.NoError(t, err, "Failed to create the Receiver: %v", err)

// Now run it as a gRPC server
srv := obsreport.GRPCServerWithObservabilityEnabled()
srv := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
agenttracepb.RegisterTraceServiceServer(srv, oci)
go func() {
_ = srv.Serve(ln)
Expand Down
3 changes: 1 addition & 2 deletions receiver/opencensusreceiver/opencensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/receiver/opencensusreceiver/ocmetrics"
"go.opentelemetry.io/collector/receiver/opencensusreceiver/octrace"
)
Expand Down Expand Up @@ -177,7 +176,7 @@ func (ocr *ocReceiver) grpcServer(host component.Host) (*grpc.Server, error) {
if err != nil {
return nil, err
}
ocr.serverGRPC = obsreport.GRPCServerWithObservabilityEnabled(opts...)
ocr.serverGRPC = grpc.NewServer(opts...)
}

return ocr.serverGRPC, nil
Expand Down
3 changes: 1 addition & 2 deletions receiver/otlpreceiver/logs/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
collectorlog "go.opentelemetry.io/collector/internal/data/protogen/collector/logs/v1"
"go.opentelemetry.io/collector/internal/pdatagrpc"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
)

func TestExport(t *testing.T) {
Expand Down Expand Up @@ -116,7 +115,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Logs) (net.Addr, func())
require.NoError(t, err)

// Now run it as a gRPC server
srv := obsreport.GRPCServerWithObservabilityEnabled()
srv := grpc.NewServer()
collectorlog.RegisterLogsServiceServer(srv, r)
go func() {
_ = srv.Serve(ln)
Expand Down
3 changes: 1 addition & 2 deletions receiver/otlpreceiver/metrics/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
collectormetrics "go.opentelemetry.io/collector/internal/data/protogen/collector/metrics/v1"
"go.opentelemetry.io/collector/internal/pdatagrpc"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
)

func TestExport(t *testing.T) {
Expand Down Expand Up @@ -123,7 +122,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) (net.Addr, func

r := New(receiverID, mc)
// Now run it as a gRPC server
srv := obsreport.GRPCServerWithObservabilityEnabled()
srv := grpc.NewServer()
collectormetrics.RegisterMetricsServiceServer(srv, r)
go func() {
_ = srv.Serve(ln)
Expand Down
3 changes: 1 addition & 2 deletions receiver/otlpreceiver/trace/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
collectortrace "go.opentelemetry.io/collector/internal/data/protogen/collector/trace/v1"
"go.opentelemetry.io/collector/internal/pdatagrpc"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
)

func TestExport(t *testing.T) {
Expand Down Expand Up @@ -118,7 +117,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) (net.Addr, func(
require.NoError(t, err)

// Now run it as a gRPC server
srv := obsreport.GRPCServerWithObservabilityEnabled()
srv := grpc.NewServer()
collectortrace.RegisterTraceServiceServer(srv, r)
go func() {
_ = srv.Serve(ln)
Expand Down

0 comments on commit 56be32d

Please sign in to comment.