Skip to content

The only tool you need to know what is happening and how to fix it.

Added message tracking

ddux1cd8af4e6c3a
diff --git a/CLAUDE.md b/CLAUDE.md
index 31539376..9ddf8fea 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -134,6 +134,18 @@ CLICKHOUSE_TLS=false
- `metric_records` - Time-series system metrics
- `exception_stack_traces` - Exceptions with hash grouping
+### Database Migrations
+**Important**:
+- Each migration file must contain exactly ONE SQL statement
+- Only create `.up.sql` files (no down migrations)
+- Each migration must have a unique numbered name
+
+Example - Adding two columns requires two separate migrations:
+```
+0013_add_app_version_to_transactions.up.sql # ALTER TABLE ... ADD COLUMN app_version
+0014_add_server_name_to_transactions.up.sql # ALTER TABLE ... ADD COLUMN server_name
+```
+
### Exception Hash Normalization
The backend normalizes stack traces before hashing:
- Removes error message content (keeps type only)
diff --git a/backend/.env.docker b/backend/.env.docker
index 284be51c..3665f077 100644
--- a/backend/.env.docker
+++ b/backend/.env.docker
@@ -1,4 +1,3 @@
-TOKEN="demotoken"
APP_TOKEN="nice"
CLICKHOUSE_SERVER=localhost:9000
CLICKHOUSE_DATABASE=traceway
diff --git a/backend/app/controllers/clientcontrollers/client.controller.go b/backend/app/controllers/clientcontrollers/client.controller.go
index f9930ab3..766e7c6b 100644
--- a/backend/app/controllers/clientcontrollers/client.controller.go
+++ b/backend/app/controllers/clientcontrollers/client.controller.go
@@ -17,8 +17,9 @@ import (
type clientController struct{}
type ReportRequest struct {
- App string `json:"app"`
CollectionFrames []*clientmodels.CollectionFrame `json:"collectionFrames"`
+ AppVersion string `json:"appVersion"`
+ ServerName string `json:"serverName"`
}
func (e clientController) Report(c *gin.Context) {
@@ -37,13 +38,13 @@ func (e clientController) Report(c *gin.Context) {
metricRecordsToInsert := []models.MetricRecord{}
for _, cf := range request.CollectionFrames {
for _, ct := range cf.Transactions {
- t := ct.ToTransaction()
+ t := ct.ToTransaction(request.AppVersion, request.ServerName)
t.ProjectId = projectId
transactionsToInsert = append(transactionsToInsert, t)
}
for _, cst := range cf.StackTraces {
- est := cst.ToExceptionStackTrace(computeExceptionHash(cst.StackTrace))
+ est := cst.ToExceptionStackTrace(computeExceptionHash(cst.StackTrace), request.AppVersion, request.ServerName)
est.ProjectId = projectId
exceptionStackTraceToInsert = append(exceptionStackTraceToInsert, est)
}
diff --git a/backend/app/migrations/ch/0013_add_app_version_to_transactions.up.sql b/backend/app/migrations/ch/0013_add_app_version_to_transactions.up.sql
new file mode 100644
index 00000000..b55b2086
--- /dev/null
+++ b/backend/app/migrations/ch/0013_add_app_version_to_transactions.up.sql
@@ -0,0 +1 @@
+ALTER TABLE transactions ADD COLUMN IF NOT EXISTS app_version String DEFAULT '';
diff --git a/backend/app/migrations/ch/0014_add_server_name_to_transactions.up.sql b/backend/app/migrations/ch/0014_add_server_name_to_transactions.up.sql
new file mode 100644
index 00000000..e743b316
--- /dev/null
+++ b/backend/app/migrations/ch/0014_add_server_name_to_transactions.up.sql
@@ -0,0 +1 @@
+ALTER TABLE transactions ADD COLUMN IF NOT EXISTS server_name String DEFAULT '';
diff --git a/backend/app/migrations/ch/0015_add_app_version_to_exceptions.up.sql b/backend/app/migrations/ch/0015_add_app_version_to_exceptions.up.sql
new file mode 100644
index 00000000..ab9c577d
--- /dev/null
+++ b/backend/app/migrations/ch/0015_add_app_version_to_exceptions.up.sql
@@ -0,0 +1 @@
+ALTER TABLE exception_stack_traces ADD COLUMN IF NOT EXISTS app_version String DEFAULT '';
diff --git a/backend/app/migrations/ch/0016_add_server_name_to_exceptions.up.sql b/backend/app/migrations/ch/0016_add_server_name_to_exceptions.up.sql
new file mode 100644
index 00000000..ea2aea42
--- /dev/null
+++ b/backend/app/migrations/ch/0016_add_server_name_to_exceptions.up.sql
@@ -0,0 +1 @@
+ALTER TABLE exception_stack_traces ADD COLUMN IF NOT EXISTS server_name String DEFAULT '';
diff --git a/backend/app/migrations/ch/0017_add_is_message_to_exceptions.up.sql b/backend/app/migrations/ch/0017_add_is_message_to_exceptions.up.sql
new file mode 100644
index 00000000..4f628fe9
--- /dev/null
+++ b/backend/app/migrations/ch/0017_add_is_message_to_exceptions.up.sql
@@ -0,0 +1 @@
+ALTER TABLE exception_stack_traces ADD COLUMN IF NOT EXISTS is_message UInt8 DEFAULT 0;
diff --git a/backend/app/models/clientmodels/clientmodels.model.go b/backend/app/models/clientmodels/clientmodels.model.go
index 8929d2c4..098aff7d 100644
--- a/backend/app/models/clientmodels/clientmodels.model.go
+++ b/backend/app/models/clientmodels/clientmodels.model.go
@@ -10,15 +10,19 @@ type ClientExceptionStackTrace struct {
StackTrace string `json:"stackTrace"`
RecordedAt time.Time `json:"recordedAt"`
Scope map[string]string `json:"scope"`
+ IsMessage bool `json:"isMessage"`
}
-func (c *ClientExceptionStackTrace) ToExceptionStackTrace(exceptionHash string) models.ExceptionStackTrace {
+func (c *ClientExceptionStackTrace) ToExceptionStackTrace(exceptionHash, appVersion, serverName string) models.ExceptionStackTrace {
return models.ExceptionStackTrace{
ExceptionHash: exceptionHash,
TransactionId: c.TransactionId,
StackTrace: c.StackTrace,
RecordedAt: c.RecordedAt,
Scope: c.Scope,
+ IsMessage: c.IsMessage,
+ AppVersion: appVersion,
+ ServerName: serverName,
}
}
@@ -47,7 +51,7 @@ type ClientTransaction struct {
Scope map[string]string `json:"scope"`
}
-func (c *ClientTransaction) ToTransaction() models.Transaction {
+func (c *ClientTransaction) ToTransaction(appVersion, serverName string) models.Transaction {
return models.Transaction{
Id: c.Id,
Endpoint: c.Endpoint,
@@ -57,6 +61,8 @@ func (c *ClientTransaction) ToTransaction() models.Transaction {
BodySize: int32(c.BodySize),
ClientIP: c.ClientIP,
Scope: c.Scope,
+ AppVersion: appVersion,
+ ServerName: serverName,
}
}
diff --git a/backend/app/models/exception_stack_trace.model.go b/backend/app/models/exception_stack_trace.model.go
index a02d763c..0f3b70c7 100644
--- a/backend/app/models/exception_stack_trace.model.go
+++ b/backend/app/models/exception_stack_trace.model.go
@@ -9,6 +9,9 @@ type ExceptionStackTrace struct {
StackTrace string `json:"stackTrace" ch:"stack_trace"`
RecordedAt time.Time `json:"recordedAt" ch:"recorded_at"`
Scope map[string]string `json:"scope" ch:"scope"`
+ AppVersion string `json:"appVersion" ch:"app_version"`
+ ServerName string `json:"serverName" ch:"server_name"`
+ IsMessage bool `json:"isMessage" ch:"is_message"`
}
type ExceptionTrendPoint struct {
diff --git a/backend/app/models/transaction.model.go b/backend/app/models/transaction.model.go
index 31ad9c25..34e8a854 100644
--- a/backend/app/models/transaction.model.go
+++ b/backend/app/models/transaction.model.go
@@ -13,6 +13,8 @@ type Transaction struct {
BodySize int32 `json:"bodySize" ch:"body_size"`
ClientIP string `json:"clientIP" ch:"client_ip"`
Scope map[string]string `json:"scope" ch:"scope"`
+ AppVersion string `json:"appVersion" ch:"app_version"`
+ ServerName string `json:"serverName" ch:"server_name"`
}
type EndpointStats struct {
diff --git a/backend/app/repositories/exception_stack_trace.repository.go b/backend/app/repositories/exception_stack_trace.repository.go
index 1a6ba0fa..ff039ca0 100644
--- a/backend/app/repositories/exception_stack_trace.repository.go
+++ b/backend/app/repositories/exception_stack_trace.repository.go
@@ -14,7 +14,7 @@ var ErrExceptionNotFound = errors.New("exception not found")
type exceptionStackTraceRepository struct{}
func (e *exceptionStackTraceRepository) InsertAsync(ctx context.Context, lines []models.ExceptionStackTrace) error {
- batch, err := (*chdb.Conn).PrepareBatch(ctx, "INSERT INTO exception_stack_traces (project_id, transaction_id, exception_hash, stack_trace, recorded_at, scope)")
+ batch, err := (*chdb.Conn).PrepareBatch(ctx, "INSERT INTO exception_stack_traces (project_id, transaction_id, exception_hash, stack_trace, recorded_at, scope, app_version, server_name, is_message)")
if err != nil {
return err
}
@@ -25,7 +25,11 @@ func (e *exceptionStackTraceRepository) InsertAsync(ctx context.Context, lines [
scopeJSON = string(scopeBytes)
}
}
- if err := batch.Append(est.ProjectId, est.TransactionId, est.ExceptionHash, est.StackTrace, est.RecordedAt, scopeJSON); err != nil {
+ isMessage := uint8(0)
+ if est.IsMessage {
+ isMessage = 1
+ }
+ if err := batch.Append(est.ProjectId, est.TransactionId, est.ExceptionHash, est.StackTrace, est.RecordedAt, scopeJSON, est.AppVersion, est.ServerName, isMessage); err != nil {
return err
}
}
@@ -111,7 +115,7 @@ func (e *exceptionStackTraceRepository) FindByHash(ctx context.Context, projectI
// Get individual occurrences with pagination (including scope)
rows, err := (*chdb.Conn).Query(ctx,
- "SELECT project_id, transaction_id, exception_hash, stack_trace, recorded_at, scope FROM exception_stack_traces WHERE project_id = ? AND exception_hash = ? ORDER BY recorded_at DESC LIMIT ? OFFSET ?",
+ "SELECT project_id, transaction_id, exception_hash, stack_trace, recorded_at, scope, app_version, server_name, is_message FROM exception_stack_traces WHERE project_id = ? AND exception_hash = ? ORDER BY recorded_at DESC LIMIT ? OFFSET ?",
projectId, exceptionHash, pageSize, offset)
if err != nil {
return nil, nil, 0, err
@@ -122,9 +126,11 @@ func (e *exceptionStackTraceRepository) FindByHash(ctx context.Context, projectI
for rows.Next() {
var o models.ExceptionStackTrace
var scopeJSON string
- if err := rows.Scan(&o.ProjectId, &o.TransactionId, &o.ExceptionHash, &o.StackTrace, &o.RecordedAt, &scopeJSON); err != nil {
+ var isMessage uint8
+ if err := rows.Scan(&o.ProjectId, &o.TransactionId, &o.ExceptionHash, &o.StackTrace, &o.RecordedAt, &scopeJSON, &o.AppVersion, &o.ServerName, &isMessage); err != nil {
return nil, nil, 0, err
}
+ o.IsMessage = isMessage == 1
// Parse scope JSON
if scopeJSON != "" && scopeJSON != "{}" {
if err := json.Unmarshal([]byte(scopeJSON), &o.Scope); err != nil {
diff --git a/backend/app/repositories/transaction.repository.go b/backend/app/repositories/transaction.repository.go
index 0ec43515..b6811b14 100644
--- a/backend/app/repositories/transaction.repository.go
+++ b/backend/app/repositories/transaction.repository.go
@@ -11,7 +11,7 @@ import (
type transactionRepository struct{}
func (e *transactionRepository) InsertAsync(ctx context.Context, lines []models.Transaction) error {
- batch, err := (*chdb.Conn).PrepareBatch(ctx, "INSERT INTO transactions (id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope)")
+ batch, err := (*chdb.Conn).PrepareBatch(ctx, "INSERT INTO transactions (id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope, app_version, server_name)")
if err != nil {
return err
}
@@ -22,7 +22,7 @@ func (e *transactionRepository) InsertAsync(ctx context.Context, lines []models.
scopeJSON = string(scopeBytes)
}
}
- if err := batch.Append(t.Id, t.ProjectId, t.Endpoint, t.Duration, t.RecordedAt, t.StatusCode, t.BodySize, t.ClientIP, scopeJSON); err != nil {
+ if err := batch.Append(t.Id, t.ProjectId, t.Endpoint, t.Duration, t.RecordedAt, t.StatusCode, t.BodySize, t.ClientIP, scopeJSON, t.AppVersion, t.ServerName); err != nil {
return err
}
}
@@ -55,7 +55,7 @@ func (e *transactionRepository) FindAll(ctx context.Context, projectId string, f
orderBy = "recorded_at"
}
- query := "SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope FROM transactions WHERE project_id = ? AND recorded_at >= ? AND recorded_at <= ? ORDER BY " + orderBy + " DESC LIMIT ? OFFSET ?"
+ query := "SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope, app_version, server_name FROM transactions WHERE project_id = ? AND recorded_at >= ? AND recorded_at <= ? ORDER BY " + orderBy + " DESC LIMIT ? OFFSET ?"
rows, err := (*chdb.Conn).Query(ctx, query, projectId, fromDate, toDate, pageSize, offset)
if err != nil {
return nil, 0, err
@@ -66,7 +66,7 @@ func (e *transactionRepository) FindAll(ctx context.Context, projectId string, f
for rows.Next() {
var t models.Transaction
var scopeJSON string
- if err := rows.Scan(&t.Id, &t.ProjectId, &t.Endpoint, &t.Duration, &t.RecordedAt, &t.StatusCode, &t.BodySize, &t.ClientIP, &scopeJSON); err != nil {
+ if err := rows.Scan(&t.Id, &t.ProjectId, &t.Endpoint, &t.Duration, &t.RecordedAt, &t.StatusCode, &t.BodySize, &t.ClientIP, &scopeJSON, &t.AppVersion, &t.ServerName); err != nil {
return nil, 0, err
}
// Parse scope JSON
@@ -173,7 +173,7 @@ func (e *transactionRepository) FindByEndpoint(ctx context.Context, projectId st
sortDir = "ASC"
}
- query := "SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope FROM transactions WHERE project_id = ? AND endpoint = ? AND recorded_at >= ? AND recorded_at <= ? ORDER BY " + orderBy + " " + sortDir + " LIMIT ? OFFSET ?"
+ query := "SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, scope, app_version, server_name FROM transactions WHERE project_id = ? AND endpoint = ? AND recorded_at >= ? AND recorded_at <= ? ORDER BY " + orderBy + " " + sortDir + " LIMIT ? OFFSET ?"
rows, err := (*chdb.Conn).Query(ctx, query, projectId, endpoint, fromDate, toDate, pageSize, offset)
if err != nil {
return nil, 0, err
@@ -184,7 +184,7 @@ func (e *transactionRepository) FindByEndpoint(ctx context.Context, projectId st
for rows.Next() {
var t models.Transaction
var scopeJSON string
- if err := rows.Scan(&t.Id, &t.ProjectId, &t.Endpoint, &t.Duration, &t.RecordedAt, &t.StatusCode, &t.BodySize, &t.ClientIP, &scopeJSON); err != nil {
+ if err := rows.Scan(&t.Id, &t.ProjectId, &t.Endpoint, &t.Duration, &t.RecordedAt, &t.StatusCode, &t.BodySize, &t.ClientIP, &scopeJSON, &t.AppVersion, &t.ServerName); err != nil {
return nil, 0, err
}
// Parse scope JSON
diff --git a/clients/go-client/devtesting/devtesting.go b/clients/go-client/devtesting/devtesting.go
index f958e944..816977f2 100644
--- a/clients/go-client/devtesting/devtesting.go
+++ b/clients/go-client/devtesting/devtesting.go
@@ -19,7 +19,6 @@ func testGin() {
router := gin.Default()
router.Use(tracewaygin.New(
- "tracewaydemo",
"default_token_change_me@http://localhost:8082/api/report",
traceway.WithDebug(true),
))
diff --git a/clients/go-client/traceway.go b/clients/go-client/traceway.go
index 1a8ccf39..e01e87b0 100644
--- a/clients/go-client/traceway.go
+++ b/clients/go-client/traceway.go
@@ -216,6 +216,7 @@ type ExceptionStackTrace struct {
StackTrace string `json:"stackTrace"`
RecordedAt time.Time `json:"recordedAt"`
Scope map[string]string `json:"scope,omitempty"`
+ IsMessage bool `json:"isMessage"`
}
type MetricRecord struct {
@@ -273,7 +274,6 @@ type CollectionFrameStore struct {
lastUploadStarted *time.Time
// Config fields
- app string
apiUrl string
token string
debug bool
@@ -281,10 +281,11 @@ type CollectionFrameStore struct {
collectionInterval time.Duration
uploadTimeout time.Duration
metricsInterval time.Duration
+ version string
+ serverName string
}
func InitCollectionFrameStore(
- app string,
apiUrl string,
token string,
debug bool,
@@ -292,6 +293,8 @@ func InitCollectionFrameStore(
collectionInterval time.Duration,
uploadTimeout time.Duration,
metricsInterval time.Duration,
+ version string,
+ serverName string,
) *CollectionFrameStore {
store := &CollectionFrameStore{
current: nil,
@@ -300,7 +303,6 @@ func InitCollectionFrameStore(
stopCh: make(chan struct{}),
messageQueue: make(chan CollectionFrameMessage),
- app: app,
apiUrl: apiUrl,
token: token,
debug: debug,
@@ -309,6 +311,8 @@ func InitCollectionFrameStore(
collectionInterval: collectionInterval,
uploadTimeout: uploadTimeout,
metricsInterval: metricsInterval,
+ version: version,
+ serverName: serverName,
}
store.wg.Add(1)
@@ -441,8 +445,9 @@ func (s *CollectionFrameStore) triggerUpload(framesToSend []*CollectionFrame) {
}()
jsonData, err := json.Marshal(gin.H{
- "app": s.app,
"collectionFrames": framesToSend,
+ "appVersion": s.version,
+ "serverName": s.serverName,
})
if err != nil {
if s.debug {
@@ -520,6 +525,8 @@ type TracewayOptions struct {
collectionInterval time.Duration
uploadTimeout time.Duration
metricsInterval time.Duration
+ version string
+ serverName string
}
func NewTracewayOptions(options ...func(*TracewayOptions)) *TracewayOptions {
@@ -528,6 +535,8 @@ func NewTracewayOptions(options ...func(*TracewayOptions)) *TracewayOptions {
collectionInterval: 5 * time.Second,
uploadTimeout: 2 * time.Second,
metricsInterval: 30 * time.Second,
+ version: "",
+ serverName: getHostname(),
}
for _, o := range options {
o(svr)
@@ -556,11 +565,21 @@ func WithUploadTimeout(val time.Duration) func(*TracewayOptions) {
}
func WithMetricsInterval(val time.Duration) func(*TracewayOptions) {
return func(s *TracewayOptions) {
- s.collectionInterval = val
+ s.metricsInterval = val
+ }
+}
+func WithVersion(val string) func(*TracewayOptions) {
+ return func(s *TracewayOptions) {
+ s.version = val
+ }
+}
+func WithServerName(val string) func(*TracewayOptions) {
+ return func(s *TracewayOptions) {
+ s.serverName = val
}
}
-func Init(app, connectionString string, options ...func(*TracewayOptions)) error {
+func Init(connectionString string, options ...func(*TracewayOptions)) error {
if collectionFrameStore != nil {
return fmt.Errorf("Second Traceway initialization detected")
}
@@ -572,7 +591,6 @@ func Init(app, connectionString string, options ...func(*TracewayOptions)) error
tracewayOptions := NewTracewayOptions(options...)
collectionFrameStore = InitCollectionFrameStore(
- app,
apiUrl,
token,
tracewayOptions.debug,
@@ -580,6 +598,8 @@ func Init(app, connectionString string, options ...func(*TracewayOptions)) error
tracewayOptions.collectionInterval,
tracewayOptions.uploadTimeout,
tracewayOptions.metricsInterval,
+ tracewayOptions.version,
+ tracewayOptions.serverName,
)
return nil
}
@@ -707,3 +727,35 @@ func RecoverWithContext(ctx context.Context) {
}
}
}
+
+// CaptureMessage captures a message as an exception with minimal stack trace
+func CaptureMessage(msg string) {
+ CaptureMessageWithContext(context.Background(), msg)
+}
+
+// CaptureMessageWithContext captures a message with context as an exception
+func CaptureMessageWithContext(ctx context.Context, msg string) {
+ if collectionFrameStore == nil {
+ return
+ }
+
+ _, file, line, ok := runtime.Caller(1)
+ if !ok {
+ file = "unknown"
+ line = 0
+ }
+
+ stackTrace := fmt.Sprintf("Message: %s\n at %s:%d", msg, file, line)
+
+ scope := GetScopeFromContext(ctx)
+ collectionFrameStore.messageQueue <- CollectionFrameMessage{
+ msgType: CollectionFrameMessageTypeException,
+ exceptionStackTrace: &ExceptionStackTrace{
+ TransactionId: GetTransactionIdFromContext(ctx),
+ StackTrace: stackTrace,
+ RecordedAt: time.Now(),
+ Scope: scope.GetTags(),
+ IsMessage: true,
+ },
+ }
+}
diff --git a/clients/go-client/traceway_gin/traceway_gin.go b/clients/go-client/traceway_gin/traceway_gin.go
index d9054839..072555d9 100644
--- a/clients/go-client/traceway_gin/traceway_gin.go
+++ b/clients/go-client/traceway_gin/traceway_gin.go
@@ -51,8 +51,8 @@ func wrapAndExecute(c *gin.Context) (s *string) {
return nil
}
-func New(app, connectionString string, options ...func(*traceway.TracewayOptions)) gin.HandlerFunc {
- traceway.Init(app, connectionString, options...)
+func New(connectionString string, options ...func(*traceway.TracewayOptions)) gin.HandlerFunc {
+ traceway.Init(connectionString, options...)
initCachedValues()
return func(c *gin.Context) {
diff --git a/frontend/src/routes/connection/+page.svelte b/frontend/src/routes/connection/+page.svelte
index da9027e7..b7ca4275 100644
--- a/frontend/src/routes/connection/+page.svelte
+++ b/frontend/src/routes/connection/+page.svelte
@@ -50,7 +50,7 @@
// Framework-specific code snippets
function getFrameworkCode(framework: Framework, token: string): string {
- const tokenValue = token || 'YOUR_PROJECT_TOKEN';
+ const connectionString = token ? `${token}@http://localhost:8082/api/client/report` : 'YOUR_TOKEN@http://localhost:8082/api/client/report';
switch (framework) {
case 'gin':
@@ -58,188 +58,82 @@
import (
"github.com/gin-gonic/gin"
- "github.com/tracewayapp/traceway-go"
+ "github.com/traceway-io/go-client"
+ "github.com/traceway-io/go-client/traceway_gin"
)
func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Create Gin router
- router := gin.Default()
+ r := gin.Default()
- // Add Traceway middleware
- router.Use(tw.GinMiddleware())
+ // Add Traceway middleware with optional version and server name
+ r.Use(traceway_gin.New(
+ "${connectionString}",
+ traceway.WithVersion("1.0.0"), // Optional: your app version
+ traceway.WithServerName("api-server"), // Optional: defaults to hostname
+ ))
// Your routes
- router.GET("/", func(c *gin.Context) {
+ r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "Hello World"})
})
- router.Run(":8080")
-}`;
-
- case 'fiber':
- return `package main
-
-import (
- "github.com/gofiber/fiber/v2"
- "github.com/tracewayapp/traceway-go"
-)
-
-func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Create Fiber app
- app := fiber.New()
-
- // Add Traceway middleware
- app.Use(tw.FiberMiddleware())
-
- // Your routes
- app.Get("/", func(c *fiber.Ctx) error {
- return c.JSON(fiber.Map{"message": "Hello World"})
+ // Capture custom messages
+ r.GET("/action", func(c *gin.Context) {
+ traceway.CaptureMessage("User performed action")
+ c.JSON(200, gin.H{"status": "ok"})
})
- app.Listen(":8080")
+ r.Run(":8080")
}`;
+ case 'fiber':
case 'chi':
- return `package main
-
-import (
- "encoding/json"
- "net/http"
-
- "github.com/go-chi/chi/v5"
- "github.com/tracewayapp/traceway-go"
-)
-
-func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Create Chi router
- r := chi.NewRouter()
-
- // Add Traceway middleware
- r.Use(tw.ChiMiddleware())
-
- // Your routes
- r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- json.NewEncoder(w).Encode(map[string]string{"message": "Hello World"})
- })
-
- http.ListenAndServe(":8080", r)
-}`;
-
case 'fasthttp':
- return `package main
-
-import (
- "github.com/valyala/fasthttp"
- "github.com/tracewayapp/traceway-go"
-)
-
-func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Request handler
- handler := func(ctx *fasthttp.RequestCtx) {
- ctx.SetContentType("application/json")
- ctx.WriteString(\`{"message": "Hello World"}\`)
- }
-
- // Wrap with Traceway middleware
- wrappedHandler := tw.FastHTTPMiddleware(handler)
-
- fasthttp.ListenAndServe(":8080", wrappedHandler)
-}`;
-
case 'stdlib':
- return `package main
-
-import (
- "encoding/json"
- "net/http"
-
- "github.com/tracewayapp/traceway-go"
-)
-
-func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Create a new ServeMux
- mux := http.NewServeMux()
-
- // Your routes
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- json.NewEncoder(w).Encode(map[string]string{"message": "Hello World"})
- })
-
- // Wrap with Traceway middleware
- handler := tw.HTTPMiddleware(mux)
-
- http.ListenAndServe(":8080", handler)
-}`;
-
case 'custom':
default:
- return `package main
+ return `// This framework is not currently supported.
+//
+// We welcome contributions! Please visit our GitHub repository
+// to help implement support for ${framework === 'custom' ? 'custom frameworks' : framework}:
+//
+// https://github.com/traceway-io/go-client
+//
+// In the meantime, you can use the core SDK directly:
+
+package main
import (
- "github.com/tracewayapp/traceway-go"
+ "github.com/traceway-io/go-client"
)
func main() {
- // Initialize Traceway client
- tw := traceway.New(traceway.Config{
- Token: "${tokenValue}",
- ServerURL: "http://localhost:8082", // Your Traceway server
- })
- defer tw.Close()
-
- // Manual instrumentation example
- // Use tw.StartTransaction() and tw.EndTransaction() to track requests
- // See documentation for your specific framework integration
+ // Initialize Traceway
+ traceway.Init(
+ "${connectionString}",
+ traceway.WithVersion("1.0.0"),
+ traceway.WithServerName("my-server"),
+ )
+
+ // Capture exceptions manually
+ // traceway.CaptureException(err)
+ // traceway.CaptureExceptionWithContext(ctx, err)
+
+ // Capture messages
+ // traceway.CaptureMessage("Something happened")
+ // traceway.CaptureMessageWithContext(ctx, "Something happened")
}`;
}
}
function getInstallCommand(framework: Framework): string {
- const base = 'go get github.com/tracewayapp/traceway-go';
+ const base = 'go get github.com/traceway-io/go-client';
switch (framework) {
case 'gin':
return `${base}\ngo get github.com/gin-gonic/gin`;
case 'fiber':
- return `${base}\ngo get github.com/gofiber/fiber/v2`;
case 'chi':
- return `${base}\ngo get github.com/go-chi/chi/v5`;
case 'fasthttp':
- return `${base}\ngo get github.com/valyala/fasthttp`;
case 'stdlib':
case 'custom':
default:
@@ -268,7 +162,7 @@ func main() {
const installCommand = $derived(
projectWithToken
? getInstallCommand(projectWithToken.framework)
- : 'go get github.com/tracewayapp/traceway-go'
+ : 'go get github.com/traceway-io/go-client'
);
async function copyCode() {
diff --git a/frontend/src/routes/issues/+page.svelte b/frontend/src/routes/issues/+page.svelte
index a92830f8..d6fddfe5 100644
--- a/frontend/src/routes/issues/+page.svelte
+++ b/frontend/src/routes/issues/+page.svelte
@@ -67,7 +67,7 @@
const daysBackLabel = $derived(daysOptions.find(o => o.value === daysBack)?.label ?? "Select period");
const pageSizeLabel = $derived(pageSizeOptions.find(o => o.value === pageSize.toString())?.label ?? pageSize.toString());
-
+
async function loadData() {
loading = true;
error = '';
diff --git a/frontend/src/routes/issues/[exceptionHash]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
index cda622cd..d4d6e5f9 100644
--- a/frontend/src/routes/issues/[exceptionHash]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
@@ -25,6 +25,9 @@
stackTrace: string;
recordedAt: string;
scope: Record<string, string> | null;
+ appVersion: string;
+ serverName: string;
+ isMessage: boolean;
};
let group = $state<ExceptionGroup | null>(null);
@@ -36,6 +39,9 @@
// Get scope from the most recent occurrence for display
const latestScope = $derived(occurrences[0]?.scope);
+ const latestAppVersion = $derived(occurrences[0]?.appVersion);
+ const latestServerName = $derived(occurrences[0]?.serverName);
+ const isMessage = $derived(occurrences[0]?.isMessage ?? false);
const hasMoreOccurrences = $derived(total > 10);
async function loadData() {
@@ -132,11 +138,24 @@
<!-- Summary Card -->
<Card.Root>
<Card.Header>
- <Card.Title>Exception Details</Card.Title>
+ <div class="flex items-center gap-2">
+ <Card.Title>Exception Details</Card.Title>
+ {#if isMessage}
+ <span class="inline-flex items-center rounded-md bg-blue-50 dark:bg-blue-900/30 px-2 py-1 text-xs font-medium text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-700/10 dark:ring-blue-400/30">
+ Message
+ </span>
+ {/if}
+ </div>
<Card.Description>
First seen: {new Date(group.firstSeen).toLocaleString()} ·
Last seen: {new Date(group.lastSeen).toLocaleString()} ·
Occurrences: {group.count}
+ {#if latestAppVersion}
+ · Version: {latestAppVersion}
+ {/if}
+ {#if latestServerName}
+ · Server: {latestServerName}
+ {/if}
</Card.Description>
</Card.Header>
<Card.Content>