008a19dbdd
Block internal-flavored paths / Block forbidden paths (push) Waiting to run
CI / Detect changes (push) Waiting to run
CI / Platform (Go) (push) Blocked by required conditions
CI / Canvas (Next.js) (push) Blocked by required conditions
CI / Shellcheck (E2E scripts) (push) Blocked by required conditions
CI / Canvas Deploy Reminder (push) Blocked by required conditions
CI / Python Lint & Test (push) Waiting to run
CI / all-required (push) Waiting to run
E2E API Smoke Test / detect-changes (push) Waiting to run
E2E API Smoke Test / E2E API Smoke Test (push) Blocked by required conditions
E2E Chat / detect-changes (push) Waiting to run
E2E Chat / E2E Chat (push) Blocked by required conditions
E2E Staging Canvas (Playwright) / detect-changes (push) Waiting to run
E2E Staging Canvas (Playwright) / Canvas tabs E2E (push) Blocked by required conditions
Handlers Postgres Integration / detect-changes (push) Waiting to run
Handlers Postgres Integration / Handlers Postgres Integration (push) Blocked by required conditions
Harness Replays / detect-changes (push) Waiting to run
Harness Replays / Harness Replays (push) Blocked by required conditions
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (push) Waiting to run
Lint no tenant GITEA or GITHUB token write / Scan for repo-host token write into tenant workspace surface (push) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (push) Waiting to run
publish-workspace-server-image / Production auto-deploy (push) Blocked by required conditions
Secret scan / Scan diff for credential-shaped strings (push) Waiting to run
publish-workspace-server-image / build-and-push (push) Has been cancelled
Co-authored-by: agent-dev-a <agent-dev-a@agents.moleculesai.app> Co-committed-by: agent-dev-a <agent-dev-a@agents.moleculesai.app>
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package handlers
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
var langfuseClient = &http.Client{Timeout: 10 * time.Second}
|
|
|
|
type TracesHandler struct{}
|
|
|
|
func NewTracesHandler() *TracesHandler {
|
|
return &TracesHandler{}
|
|
}
|
|
|
|
// List handles GET /workspaces/:id/traces
|
|
// Proxies to Langfuse API to get recent traces for a workspace.
|
|
func (h *TracesHandler) List(c *gin.Context) {
|
|
workspaceID := c.Param("id")
|
|
|
|
langfuseHost := os.Getenv("LANGFUSE_HOST")
|
|
langfusePublic := os.Getenv("LANGFUSE_PUBLIC_KEY")
|
|
langfuseSecret := os.Getenv("LANGFUSE_SECRET_KEY")
|
|
|
|
if langfuseHost == "" || langfusePublic == "" || langfuseSecret == "" {
|
|
c.JSON(http.StatusOK, []interface{}{})
|
|
return
|
|
}
|
|
|
|
// Fetch traces from Langfuse, filtered by workspace tag or name
|
|
url := fmt.Sprintf("%s/api/public/traces?limit=20&orderBy=timestamp&orderDir=desc&tags=%s",
|
|
langfuseHost, workspaceID)
|
|
|
|
req, err := http.NewRequestWithContext(c.Request.Context(), "GET", url, nil)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create request"})
|
|
return
|
|
}
|
|
req.SetBasicAuth(langfusePublic, langfuseSecret)
|
|
|
|
resp, err := langfuseClient.Do(req)
|
|
if err != nil {
|
|
// Langfuse not available — return empty
|
|
c.JSON(http.StatusOK, []interface{}{})
|
|
return
|
|
}
|
|
defer func() { _ = resp.Body.Close() }()
|
|
|
|
body, err := io.ReadAll(resp.Body)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to read response body"})
|
|
return
|
|
}
|
|
c.Data(resp.StatusCode, "application/json", body)
|
|
}
|