feat: add logSender for sending logs on agent v2 API (#12046)

Adds a new subcomponent of the agent for queueing up logs until they can be sent over the Agent API.

Subsequent PR will change the agent to use this instead of the HTTP API for posting logs.

Relates to #10534
This commit is contained in:
Spike Curtis
2024-02-15 16:57:17 +04:00
committed by GitHub
parent 627232eae9
commit 2aff014e5d
3 changed files with 652 additions and 0 deletions
+13
View File
@@ -7,6 +7,7 @@ import (
"github.com/google/uuid"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/codersdk"
@@ -298,3 +299,15 @@ func ProtoFromAppHealthsRequest(req PostAppHealthsRequest) (*proto.BatchUpdateAp
}
return pReq, nil
}
func ProtoFromLog(log Log) (*proto.Log, error) {
lvl, ok := proto.Log_Level_value[strings.ToUpper(string(log.Level))]
if !ok {
return nil, xerrors.Errorf("unknown log level: %s", log.Level)
}
return &proto.Log{
CreatedAt: timestamppb.New(log.CreatedAt),
Output: log.Output,
Level: proto.Log_Level(lvl),
}, nil
}