Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: renameservice ->coder_service, removeagent_id label#19241

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 3 commits intomainfromstevenmasley/profile_label_cardinality
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
10 changes: 9 additions & 1 deletioncoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,14 @@ import (
"net/url"
"path/filepath"
"regexp"
"runtime/pprof"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/coder/coder/v2/coderd/oauth2provider"
"github.com/coder/coder/v2/coderd/pproflabel"
"github.com/coder/coder/v2/coderd/prebuilds"
"github.com/coder/coder/v2/coderd/wsbuilder"

Expand DownExpand Up@@ -1340,7 +1342,13 @@ func New(options *Options) *API {
).Get("/connection", api.workspaceAgentConnectionGeneric)
r.Route("/me", func(r chi.Router) {
r.Use(workspaceAgentInfo)
r.Get("/rpc", api.workspaceAgentRPC)
r.Group(func(r chi.Router) {
r.Use(
// Override the request_type for agent rpc traffic.
httpmw.WithStaticProfilingLabels(pprof.Labels(pproflabel.RequestTypeTag, "agent-rpc")),
)
r.Get("/rpc", api.workspaceAgentRPC)
})
r.Patch("/logs", api.patchWorkspaceAgentLogs)
r.Patch("/app-status", api.patchWorkspaceAgentAppStatus)
// Deprecated: Required to support legacy agents
Expand Down
15 changes: 14 additions & 1 deletioncoderd/httpmw/pprof.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,9 +22,22 @@ func WithProfilingLabels(next http.Handler) http.Handler {
requestType = "websocket"
}

pprof.Do(ctx, pproflabel.Service(pproflabel.ServiceHTTPServer,"request_type", requestType), func(ctx context.Context) {
pprof.Do(ctx, pproflabel.Service(pproflabel.ServiceHTTPServer,pproflabel.RequestTypeTag, requestType), func(ctx context.Context) {
r = r.WithContext(ctx)
next.ServeHTTP(rw, r)
})
})
}

func WithStaticProfilingLabels(labels pprof.LabelSet) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()

pprof.Do(ctx, labels, func(ctx context.Context) {
r = r.WithContext(ctx)
next.ServeHTTP(rw, r)
})
})
}
}
10 changes: 9 additions & 1 deletioncoderd/pproflabel/pproflabel.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,22 @@ func Go(ctx context.Context, labels pprof.LabelSet, f func(context.Context)) {
go pprof.Do(ctx, labels, f)
}

func Do(ctx context.Context, labels pprof.LabelSet, f func(context.Context)) {
pprof.Do(ctx, labels, f)
}

const (
ServiceTag = "service"
// ServiceTag should not collide with the pyroscope built-in tag "service".
// Use `coder_` to avoid collisions.
ServiceTag = "coder_service"

ServiceHTTPServer = "http-api"
ServiceLifecycles = "lifecycle-executor"
ServiceMetricCollector = "metrics-collector"
ServicePrebuildReconciler = "prebuilds-reconciler"
ServiceTerraformProvisioner = "terraform-provisioner"

RequestTypeTag = "coder_request_type"
Comment on lines +20 to +28
Copy link
MemberAuthor

@EmyrkEmyrkAug 7, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Prefixing these tags withcoder_ to prevent collisions. I think this was causing issues.

)

func Service(name string, pairs ...string) pprof.LabelSet {
Expand Down
19 changes: 8 additions & 11 deletionscoderd/workspaceagentsrpc.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import (
"fmt"
"io"
"net/http"
"runtime/pprof"
"sync"
"sync/atomic"
"time"
Expand DownExpand Up@@ -348,16 +347,14 @@ func (m *agentConnectionMonitor) init() {
func (m *agentConnectionMonitor) start(ctx context.Context) {
ctx, m.cancel = context.WithCancel(ctx)
m.wg.Add(2)
go pprof.Do(ctx, pprof.Labels("agent", m.workspaceAgent.ID.String()),
func(ctx context.Context) {
defer m.wg.Done()
m.sendPings(ctx)
})
go pprof.Do(ctx, pprof.Labels("agent", m.workspaceAgent.ID.String()),
func(ctx context.Context) {
defer m.wg.Done()
m.monitor(ctx)
})
go func(ctx context.Context) {
defer m.wg.Done()
m.sendPings(ctx)
}(ctx)
go func(ctx context.Context) {
defer m.wg.Done()
m.monitor(ctx)
}(ctx)
}

func (m *agentConnectionMonitor) monitor(ctx context.Context) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp