Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mTLS support for Otel and removing logger for trace service #368

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/internal/nozzle/otel_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/cloudfoundry/metric-store-release/src/pkg/logger"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

type OtelServer struct {
Expand Down Expand Up @@ -55,15 +54,14 @@ func (s *OtelServer) Start(addr string, otelTlsConfig *tls.Config) {
s.log.Info("OtelServer starting grpc server at ", zap.String("address", addr))

// Initialize gRPC server with TLS credentials
grpcServer := grpc.NewServer(grpc.Creds(credentials.NewTLS(otelTlsConfig)))
grpcServer := grpc.NewServer()
// Start the gRPC server in a separate goroutine
go s.startGRPCServer(addr, grpcServer, otelTlsConfig)

// Register Metric and Trace services with the gRPC server
metricspb.RegisterMetricsServiceServer(grpcServer, s.ms)
tracepb.RegisterTraceServiceServer(grpcServer, s.ts)

// Start the gRPC server in a separate goroutine
go s.startGRPCServer(addr, grpcServer)

s.log.Info("Starting Metrics and Trace Servers")
s.ms.StartListening()
s.ts.StartListening()
Expand All @@ -89,7 +87,7 @@ func NewOtelServer(
}

// StartGRPCServer starts the gRPC server and listens for incoming connections.
func (s *OtelServer) startGRPCServer(addr string, grpcServer *grpc.Server) {
func (s *OtelServer) startGRPCServer(addr string, grpcServer *grpc.Server, otelTlsConfig *tls.Config) {
defer func() {
close(s.done)
}()
Expand All @@ -99,8 +97,7 @@ func (s *OtelServer) startGRPCServer(addr string, grpcServer *grpc.Server) {
if err != nil {
s.log.Panic("Failed to resolve address", zap.Error(err))
}

listener, err := net.ListenTCP("tcp", resolvedAddr)
listener, err := tls.Listen("tcp", resolvedAddr.String(), otelTlsConfig)
if err != nil {
s.log.Panic("Failed to start listener", zap.Error(err))
}
Expand Down
7 changes: 3 additions & 4 deletions src/internal/nozzle/trace_service.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package nozzle

import (
"strconv"
"time"

"code.cloudfoundry.org/go-diodes"
"github.com/cloudfoundry/metric-store-release/src/internal/metrics"
"github.com/cloudfoundry/metric-store-release/src/internal/nozzle/rollup"
"github.com/cloudfoundry/metric-store-release/src/pkg/logger"
"github.com/cloudfoundry/metric-store-release/src/pkg/persistence/transform"
"strconv"
"time"

"github.com/cloudfoundry/metric-store-release/src/pkg/ingressclient"
"github.com/cloudfoundry/metric-store-release/src/pkg/rpc"
Expand Down Expand Up @@ -159,8 +160,6 @@ func (s *TraceService) convertToSpan(sp *ot.Span) *rpc.Span {
}

func (s *TraceService) addToRollup(span *rpc.Span) {
s.log.Log("msg", "TraceService.addToRollup:", "span", span)

s.totalRollup.Record(span.SourceId, span.Labels, 1)
s.durationRollup.Record(span.SourceId, span.Labels, span.Duration)
}
Expand Down
Loading