The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
fix: more perf fixes
ddux9dfe19fd7dbb
diff --git a/backend/app/controllers/session_detail.controller.go b/backend/app/controllers/session_detail.controller.goindex 8cb3f752..255b6e90 100644--- a/backend/app/controllers/session_detail.controller.go+++ b/backend/app/controllers/session_detail.controller.go@@ -18,6 +18,10 @@ import (type sessionDetailController struct{}+type sessionDetailRequest struct {+ StartedAt *time.Time `json:"startedAt"`+}+type SessionExceptionInfo struct {Id uuid.UUID `json:"id"`ExceptionHash string `json:"exceptionHash"`@@ -56,8 +60,14 @@ func (s sessionDetailController) GetSessionDetail(c *gin.Context) {return}+ var request sessionDetailRequest+ _ = c.ShouldBindJSON(&request)+span := traceway.StartSpan(c, "loading session")- session, err := repositories.SessionRepository.FindById(c, projectId, sessionId)+ session, err := repositories.SessionRepository.FindById(c, projectId, sessionId, request.StartedAt)+ if session == nil && err == nil && request.StartedAt != nil {+ session, err = repositories.SessionRepository.FindById(c, projectId, sessionId, nil)+ }span.End()if err != nil {c.AbortWithError(500, traceway.NewStackTraceErrorf("error loading session: %w", err))diff --git a/backend/app/controllers/task_detail.controller.go b/backend/app/controllers/task_detail.controller.goindex 7f906d61..545265ef 100644--- a/backend/app/controllers/task_detail.controller.go+++ b/backend/app/controllers/task_detail.controller.go@@ -64,7 +64,11 @@ func (t taskDetailController) GetTaskDetail(c *gin.Context) {task, err = repositories.TaskRepository.FindById(c, projectId, taskId, nil)}span.End()- if err != nil || task == nil {+ if err != nil {+ c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("error loading task: %w", err))+ return+ }+ if task == nil {c.JSON(http.StatusNotFound, gin.H{"error": "Task not found"})return}diff --git a/backend/app/repositories/session.repository.go b/backend/app/repositories/session.repository.goindex fb50ac1c..d083ed62 100644--- a/backend/app/repositories/session.repository.go+++ b/backend/app/repositories/session.repository.go@@ -91,15 +91,21 @@ func (r *sessionRepository) FindAll(ctx context.Context, projectId uuid.UUID, frreturn sessions, int64(count), nil}-func (r *sessionRepository) FindById(ctx context.Context, projectId, sessionId uuid.UUID) (*models.Session, error) {+func (r *sessionRepository) FindById(ctx context.Context, projectId, sessionId uuid.UUID, startedAt *time.Time) (*models.Session, error) {var s models.Session- err := chdb.Conn.QueryRow(ctx,- `SELECT id, project_id, started_at, ended_at, duration, client_ip, attributes, app_version, server_name, distributed_trace_id- FROM sessions FINAL- WHERE project_id = ? AND id = ?- LIMIT 1`,- projectId, sessionId).Scan(+ query := `SELECT id, project_id, started_at, ended_at, duration, client_ip, attributes, app_version, server_name, distributed_trace_id+ FROM sessions FINAL+ WHERE project_id = ? AND id = ?`+ args := []any{projectId, sessionId}+ if startedAt != nil {+ from, to := traceWindowBounds(*startedAt)+ query += ` AND started_at >= ? AND started_at <= ?`+ args = append(args, from, to)+ }+ query += ` LIMIT 1`++ err := chdb.Conn.QueryRow(ctx, query, args...).Scan(&s.Id, &s.ProjectId, &s.StartedAt, &s.EndedAt, &s.Duration, &s.ClientIP, &s.Attributes, &s.AppVersion, &s.ServerName, &s.DistributedTraceId,)if err != nil {diff --git a/backend/app/repositories/session.repository_sqlite.go b/backend/app/repositories/session.repository_sqlite.goindex 0bec561f..ca91525a 100644--- a/backend/app/repositories/session.repository_sqlite.go+++ b/backend/app/repositories/session.repository_sqlite.go@@ -235,10 +235,18 @@ func buildSessionFilterClauseSQLite(search string, filters []SessionAttributeFilreturn sb.String(), params}-func (r *sessionRepository) FindById(ctx context.Context, projectId, sessionId uuid.UUID) (*models.Session, error) {- row, err := lit.SelectSingleNamed[sessionRow](db.TelemetryDB,- "SELECT id, project_id, started_at, ended_at, duration, client_ip, attributes, app_version, server_name, distributed_trace_id FROM sessions WHERE project_id = :project_id AND id = :id LIMIT 1",- lit.P{"project_id": projectId, "id": sessionId})+func (r *sessionRepository) FindById(ctx context.Context, projectId, sessionId uuid.UUID, startedAt *time.Time) (*models.Session, error) {+ query := "SELECT id, project_id, started_at, ended_at, duration, client_ip, attributes, app_version, server_name, distributed_trace_id FROM sessions WHERE project_id = :project_id AND id = :id"+ params := lit.P{"project_id": projectId, "id": sessionId}+ if startedAt != nil {+ from, to := traceWindowBounds(*startedAt)+ query += " AND started_at >= :from AND started_at <= :to"+ params["from"] = NewSQLiteTime(from)+ params["to"] = NewSQLiteTime(to)+ }+ query += " LIMIT 1"++ row, err := lit.SelectSingleNamed[sessionRow](db.TelemetryDB, query, params)if err != nil {return nil, err}diff --git a/frontend/src/routes/sessions/+page.svelte b/frontend/src/routes/sessions/+page.svelteindex 384ec1d5..0e57eed3 100644--- a/frontend/src/routes/sessions/+page.svelte+++ b/frontend/src/routes/sessions/+page.svelte@@ -444,7 +444,7 @@{#each sessions as session}<Table.Rowclass="cursor-pointer hover:bg-muted/50"- onclick={createRowClickHandler(resolve(`/sessions/${session.id}`), 'preset', 'from', 'to')}+ onclick={createRowClickHandler(`${resolve(`/sessions/${session.id}`)}?t=${encodeURIComponent(session.startedAt)}`, 'preset', 'from', 'to')}><Table.Cell class="font-mono text-sm">{shortId(session.id)}</Table.Cell><Table.Cell class="text-sm">{formatRelativeTime(session.startedAt, timezone)}</Table.Cell>diff --git a/frontend/src/routes/sessions/[sessionId]/+page.svelte b/frontend/src/routes/sessions/[sessionId]/+page.svelteindex f6cd964b..6f753f7a 100644--- a/frontend/src/routes/sessions/[sessionId]/+page.svelte+++ b/frontend/src/routes/sessions/[sessionId]/+page.svelte@@ -82,7 +82,8 @@notFound = false;try {- const detail = await api.post(`/sessions/${sessionId}`, {}, {+ const startedAt = pageState.url.searchParams.get('t');+ const detail = await api.post(`/sessions/${sessionId}`, startedAt ? { startedAt } : {}, {projectId: projectsState.currentProjectId ?? undefined});session = detail.session;