10000 feat: integrate agentAPI with resources monitoring logic by defelmnq · Pull Request #16438 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: integrate agentAPI with resources monitoring logic #16438

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

Merged
merged 32 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d42cad
work on new agent version
defelmnq Feb 4, 2025
7b2d19e
improve function for resources monitoring
defelmnq Feb 10, 2025
0124d60
add missing files
defelmnq Feb 10, 2025
3661e8c
work on resources monitor tests
defelmnq Feb 11, 2025
a5a788e
apply fmt and lint
defelmnq Feb 11, 2025
91d1515
work on dbauthz tests
defelmnq Feb 11, 2025
0bc7632
work on dbauthz
defelmnq Feb 11, 2025
3085041
work on rbac
defelmnq Feb 11, 2025
120a37b
continue to iterate
defelmnq Feb 11, 2025
dd8ed40
continue to iterate
defelmnq Feb 11, 2025
0a8941b
continue to iterate
defelmnq Feb 11, 2025
f3388b4
work on tests
defelmnq Feb 11, 2025
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
Prev Previous commit
add collectedAt
  • Loading branch information
defelmnq committed Feb 14, 2025
commit 3bec3247b51659b2ed6bccaf76b275b78625cbfc
13 changes: 10 additions & 3 deletions agent/proto/resourcesmonitor/queue.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package resourcesmonitor

import (
"time"

"google.golang.org/protobuf/types/known/timestamppb"

"github.com/coder/coder/v2/agent/proto"
)

type Datapoint struct {
Memory *MemoryDatapoint
Volumes []*VolumeDatapoint
CollectedAt time.Time
Memory *MemoryDatapoint
Volumes []*VolumeDatapoint
}

type MemoryDatapoint struct {
Expand Down Expand Up @@ -55,7 +60,9 @@ func (q *Queue) ItemsAsProto() []*proto.PushResourcesMonitoringUsageRequest_Data
items := make([]*proto.PushResourcesMonitoringUsageRequest_Datapoint, 0, len(q.items))

for _, item := range q.items {
protoItem := &proto.PushResourcesMonitoringUsageRequest_Datapoint{}
protoItem := &proto.PushResourcesMonitoringUsageRequest_Datapoint{
CollectedAt: timestamppb.New(item.CollectedAt),
}
if item.Memory != nil {
protoItem.Memory = &proto.PushResourcesMonitoringUsageRequest_Datapoint_MemoryUsage{
Total: item.Memory.Total,
Expand Down
3 changes: 2 additions & 1 deletion agent/proto/resourcesmonitor/resources_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type datapointsPusher interface {
func (m *monitor) Start(ctx context.Context) error {
m.clock.TickerFunc(ctx, time.Duration(m.config.Config.CollectionIntervalSeconds)*time.Second, func() error {
datapoint := Datapoint{
Volumes: make([]*VolumeDatapoint, 0, len(m.config.Volumes)),
CollectedAt: m.clock.Now(),
Volumes: make([]*VolumeDatapoint, 0, len(m.config.Volumes)),
}

if m.config.Memory != nil && m.config.Memory.Enabled {
Expand Down
Loading
0