Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed May 2, 2023
1 parent e009cc8 commit 0c15f1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions orca/call_metrics.go
Expand Up @@ -50,8 +50,8 @@ type CallMetricsRecorder interface {

type callMetricsRecorderCtxKey struct{}

// CallMetricsRecorderFromContext returns the RPC specific custom metrics
// recorder [CallMetricsRecorder] embedded in the provided RPC context.
// CallMetricsRecorderFromContext returns the RPC-specific custom metrics
// recorder embedded in the provided RPC context.
//
// Returns nil if no custom metrics recorder is found in the provided context,
// which will be the case when custom metrics reporting is not enabled.
Expand Down Expand Up @@ -99,11 +99,11 @@ func (rw *recorderWrapper) setTrailerMetadata(ctx context.Context) {

b, err := proto.Marshal(sm.toLoadReportProto())
if err != nil {
logger.Warningf("failed to marshal load report: %v", err)
logger.Warningf("Failed to marshal load report: %v", err)
return
}
if err := grpc.SetTrailer(ctx, metadata.Pairs(internal.TrailerMetadataKey, string(b))); err != nil {
logger.Warningf("failed to set trailer metadata: %v", err)
logger.Warningf("Failed to set trailer metadata: %v", err)
}
}

Expand Down
3 changes: 1 addition & 2 deletions orca/server_metrics.go
Expand Up @@ -152,7 +152,7 @@ func newServerMetricsRecorder() *serverMetricsRecorder {
func (s *serverMetricsRecorder) ServerMetrics() *ServerMetrics {
s.mu.Lock()
defer s.mu.Unlock()
ret := &ServerMetrics{
return &ServerMetrics{
CPUUtilization: s.state.CPUUtilization,
MemUtilization: s.state.MemUtilization,
QPS: s.state.QPS,
Expand All @@ -161,7 +161,6 @@ func (s *serverMetricsRecorder) ServerMetrics() *ServerMetrics {
RequestCost: copyMap(s.state.RequestCost),
NamedMetrics: copyMap(s.state.NamedMetrics),
}
return ret
}

func copyMap(m map[string]float64) map[string]float64 {
Expand Down
4 changes: 3 additions & 1 deletion orca/service.go
Expand Up @@ -110,8 +110,10 @@ func NewService(opts ServiceOptions) (*Service, error) {
}

// Register creates a new ORCA service implementation configured using the
// provided options and registers the same on the provided service registrar.
// provided options and registers the same on the provided grpc Server.
func Register(s *grpc.Server, opts ServiceOptions) error {
// TODO(https://github.com/cncf/xds/issues/41): replace *grpc.Server with
// grpc.ServiceRegistrar when possible.
service, err := NewService(opts)
if err != nil {
return err
Expand Down

0 comments on commit 0c15f1f

Please sign in to comment.