+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ func (api *Api) Profiling(w http.ResponseWriter, r *http.Request, u *db.User) {
defer ch.Close()
q := r.URL.Query()
auditor.Audit(world, project, nil, project.ClickHouseConfig(api.globalClickHouse) != nil, nil)
utils.WriteJson(w, api.WithContext(project, cacheStatus, world, views.Profiling(r.Context(), ch, app, q, world.Ctx)))
utils.WriteJson(w, api.WithContext(project, cacheStatus, world, views.Profiling(r.Context(), ch, app, q, world)))
}

func (api *Api) Tracing(w http.ResponseWriter, r *http.Request, u *db.User) {
Expand Down
2 changes: 1 addition & 1 deletion api/views/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application,
if app.Settings != nil && app.Settings.Logs != nil {
otelService = app.Settings.Logs.Service
} else {
otelService = model.GuessService(otelServices, app.Id)
otelService = model.GuessService(otelServices, w, app)
}

if logsFromAgentFound {
Expand Down
2 changes: 1 addition & 1 deletion api/views/overview/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (v *Logs) renderEntries(entries []*model.LogEntry, w *model.World) {
}
if settings := app.Settings; settings != nil && settings.Logs != nil && settings.Logs.Service != "" {
apps[settings.Logs.Service] = app
} else if service := model.GuessService(services, app.Id); service != "" {
} else if service := model.GuessService(services, w, app); service != "" {
apps[service] = app
}
}
Expand Down
10 changes: 5 additions & 5 deletions api/views/profiling/profiling.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Query struct {
Instance string `json:"instance"`
}

func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application, query url.Values, wCtx timeseries.Context) *View {
func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application, query url.Values, w *model.World) *View {
if ch == nil {
return nil
}
Expand All @@ -61,10 +61,10 @@ func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application,
}
}
if q.From == 0 {
q.From = wCtx.From
q.From = w.Ctx.From
}
if q.To == 0 {
q.To = wCtx.To
q.To = w.Ctx.To
}

v := &View{}
Expand All @@ -86,7 +86,7 @@ func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application,
services[model.ContainerIdToServiceName(c.Id)] = true
}
}
if s := model.GuessService(maps.Keys(profileTypes), app.Id); len(services) == 0 && s != "" {
if s := model.GuessService(maps.Keys(profileTypes), w, app); len(services) == 0 && s != "" {
services[s] = true
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application,
q.Type = v.Profiles[0].Type
}

chart, containers := getChart(app, q.Type, wCtx, q.Instance)
chart, containers := getChart(app, q.Type, w.Ctx, q.Instance)
v.Chart = chart
v.Instances = maps.Keys(containers)
sort.Strings(v.Instances)
Expand Down
2 changes: 1 addition & 1 deletion api/views/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Render(ctx context.Context, ch *clickhouse.Client, app *model.Application,
if app.Settings != nil && app.Settings.Tracing != nil {
otelService = app.Settings.Tracing.Service
} else {
otelService = model.GuessService(otelServices, app.Id)
otelService = model.GuessService(otelServices, w, app)
}
for _, s := range otelServices {
v.Services = append(v.Services, Service{Name: s, Linked: s == otelService})
Expand Down
5 changes: 2 additions & 3 deletions api/views/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/coroot/coroot/db"
"github.com/coroot/coroot/model"
"github.com/coroot/coroot/rbac"
"github.com/coroot/coroot/timeseries"
)

func Overview(ctx context.Context, ch *clickhouse.Client, p *db.Project, w *model.World, view, query string) *overview.Overview {
Expand All @@ -39,8 +38,8 @@ func Incidents(w *model.World, incidents []*model.ApplicationIncident) []inciden
return incident.RenderList(w, incidents)
}

func Profiling(ctx context.Context, ch *clickhouse.Client, app *model.Application, q url.Values, wCtx timeseries.Context) *profiling.View {
return profiling.Render(ctx, ch, app, q, wCtx)
func Profiling(ctx context.Context, ch *clickhouse.Client, app *model.Application, q url.Values, w *model.World) *profiling.View {
return profiling.Render(ctx, ch, app, q, w)
}

func Tracing(ctx context.Context, ch *clickhouse.Client, app *model.Application, q url.Values, w *model.World) *tracing.View {
Expand Down
18 changes: 17 additions & 1 deletion model/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func ContainerIdToServiceName(containerId string) string {
return containerId
}

func GuessService(services []string, appId ApplicationId) string {
func guessService(services []string, appId ApplicationId) string {
for _, s := range services {
if s == appId.Name {
return s
Expand All @@ -101,3 +101,19 @@ func GuessService(services []string, appId ApplicationId) string {
}
return ""
}

func GuessService(services []string, w *World, app *Application) string {
service := guessService(services, app.Id)
if service == "" {
return ""
}
for id := range w.Applications {
if app.Id == id {
continue
}
if s := guessService(services, id); s == service {
return ""
}
}
return service
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载