Skip to content

Commit

Permalink
move func and fix strs
Browse files Browse the repository at this point in the history
  • Loading branch information
deniseli committed Jul 23, 2024
1 parent 51f5ecb commit 8b85653
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,17 +824,6 @@ func (s *Service) AcquireLease(ctx context.Context, stream *connect.BidiStream[f
}

func (s *Service) Call(ctx context.Context, req *connect.Request[ftlv1.CallRequest]) (*connect.Response[ftlv1.CallResponse], error) {
logger := log.FromContext(ctx)

requestCounter, err := otel.GetMeterProvider().Meter("ftl.verb").Int64Counter(
"requests",
metric.WithDescription("Count of FTL verb calls via the controller"))
if err != nil {
logger.Errorf(err, "Failed to instrument otel metric `ftl.call.request`")
} else {
requestCounter.Add(ctx, 1, metric.WithAttributes(attribute.String("ftl.module.name", req.Msg.Verb.Module), attribute.String("ftl.verb.name", req.Msg.Verb.Name)))
}

return s.callWithRequest(ctx, req, optional.None[model.RequestKey](), "")
}

Expand Down Expand Up @@ -944,6 +933,18 @@ func (s *Service) callWithRequest(
sourceAddress string,
) (*connect.Response[ftlv1.CallResponse], error) {
start := time.Now()

logger := log.FromContext(ctx)

requestCounter, err := otel.GetMeterProvider().Meter("ftl.call").Int64Counter(
"requests",
metric.WithDescription("Count of FTL verb calls via the controller"))
if err != nil {
logger.Errorf(err, "Failed to instrument otel metric `ftl.call.requests`")
} else {
requestCounter.Add(ctx, 1, metric.WithAttributes(attribute.String("ftl.module.name", req.Msg.Verb.Module), attribute.String("ftl.verb.name", req.Msg.Verb.Name)))
}

if req.Msg.Verb == nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("verb is required"))
}
Expand Down

0 comments on commit 8b85653

Please sign in to comment.