Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joremysh committed Nov 4, 2024
1 parent 9f156a3 commit 2992775
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.5

retract v0.3.2 // Published accidentally.

//replace github.com/instill-ai/protogen-go => ./../protogen-go
replace github.com/instill-ai/protogen-go => ./../protogen-go

require (
github.com/DATA-DOG/go-sqlmock v1.5.2
Expand Down
33 changes: 33 additions & 0 deletions pkg/handler/publichandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,39 @@ func (h *PublicHandler) ValidateToken(ctx context.Context, req *mgmtPB.ValidateT
return &mgmtPB.ValidateTokenResponse{UserUid: userUID}, nil
}

// GetModelTriggerCount returns the model trigger count of a given
// requester within a timespan. Results are grouped by trigger status.
func (h *PublicHandler) GetModelTriggerCount(ctx context.Context, req *mgmtPB.GetModelTriggerCountRequest) (*mgmtPB.GetModelTriggerCountResponse, error) {
eventName := "GetModelTriggerCount"
ctx, span := tracer.Start(ctx, eventName,
trace.WithSpanKind(trace.SpanKindServer))
defer span.End()

logUUID, _ := uuid.NewV4()
logger, _ := logger.GetZapLogger(ctx)

ctxUserUID, err := h.Service.ExtractCtxUser(ctx, false)
if err != nil {
span.SetStatus(1, err.Error())
return nil, err
}

resp, err := h.Service.GetModelTriggerCount(ctx, req, ctxUserUID)
if err != nil {
span.SetStatus(1, err.Error())
return nil, fmt.Errorf("fetching credit chart records: %w", err)
}

logger.Info(string(custom_otel.NewLogMessage(
span,
logUUID.String(),
ctxUserUID,
eventName,
)))

return resp, nil
}

func (h *PublicHandler) ListPipelineTriggerRecords(ctx context.Context, req *mgmtPB.ListPipelineTriggerRecordsRequest) (*mgmtPB.ListPipelineTriggerRecordsResponse, error) {
eventName := "ListPipelineTriggerRecords"
ctx, span := tracer.Start(ctx, eventName,
Expand Down

0 comments on commit 2992775

Please sign in to comment.