The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
logs v1
dduxd5ac29f18897
diff --git a/CLAUDE.md b/CLAUDE.mdindex 31e7e107..bc4f99c6 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -515,6 +515,7 @@ backend/| POST | `/api/report` | Client | Telemetry ingestion (gzipped) || POST | `/api/otel/v1/traces` | Client | OTLP/HTTP trace ingestion || POST | `/api/otel/v1/metrics` | Client | OTLP/HTTP metric ingestion |+| POST | `/api/otel/v1/logs` | Client | OTLP/HTTP log ingestion |**Auth & Registration**| Method | Endpoint | Auth | Purpose |@@ -611,6 +612,11 @@ backend/| POST | `/api/invitations/:token/accept` | None | Accept (new user) || POST | `/api/invitations/:token/accept-existing` | App | Accept (existing user) |+**Logs**+| Method | Endpoint | Auth | Purpose |+|--------|----------|------|---------|+| POST | `/api/logs` | App | List/search logs (filters: severity, service, trace, body) |+**Source Maps**| Method | Endpoint | Auth | Purpose ||--------|----------|------|---------|@@ -646,6 +652,7 @@ func (c *ReportController) Report(ctx *gin.Context) {| `metric_records` | Time-series system metrics | Monthly || `endpoints` | Endpoint aggregates (materialized) | None || `archived_exceptions` | Archived/resolved exceptions | None |+| `log_records` | OTel logs with 3 attribute maps (resource/scope/log), 30-day TTL | Daily (`toDate(timestamp)`) |#### Tables (PostgreSQL)| Table | Purpose |diff --git a/backend/app/controllers/log.controller.go b/backend/app/controllers/log.controller.gonew file mode 100644index 00000000..4a96ff07--- /dev/null+++ b/backend/app/controllers/log.controller.go@@ -0,0 +1,190 @@+package controllers++import (+ "context"+ "encoding/hex"+ "net/http"+ "time"++ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ traceway "go.tracewayapp.com"++ "github.com/tracewayapp/traceway/backend/app/middleware"+ "github.com/tracewayapp/traceway/backend/app/models"+ "github.com/tracewayapp/traceway/backend/app/repositories"+)++type logController struct{}++var LogController = logController{}++type LogAttributeFilterRequest struct {+ Scope string `json:"scope"` // "resource" | "scope" | "log"+ Key string `json:"key"`+ Value string `json:"value"`+}++type LogSearchRequest struct {+ FromDate time.Time `json:"fromDate"`+ ToDate time.Time `json:"toDate"`+ OrderBy string `json:"orderBy"`+ SortDirection string `json:"sortDirection"`+ Search string `json:"search"`+ SearchType string `json:"searchType"`+ MinSeverity uint8 `json:"minSeverity"`+ ServiceName string `json:"serviceName"`+ TraceId string `json:"traceId"`+ DistributedTraceId string `json:"distributedTraceId"`+ ExcludeTraceId string `json:"excludeTraceId"`+ AttributeFilters []LogAttributeFilterRequest `json:"attributeFilters"`+ Pagination PaginationParams `json:"pagination"`+}++// Max time range allowed for body search without any other selector. Keeps a+// naïve "find all logs containing 'error' for the past 30 days" query from+// scanning the full body column.+const bodySearchUnscopedMaxRange = 24 * time.Hour++func (l logController) List(c *gin.Context) {+ projectId, err := middleware.GetProjectId(c)+ if err != nil {+ c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("RequireProjectAccess middleware must be applied: %w", err))+ return+ }++ var request LogSearchRequest+ if err := c.ShouldBindJSON(&request); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})+ return+ }++ // Loki-style gate: a body substring search without any selector can scan+ // the entire body column across the requested range. Require at least one+ // selector (service / severity / trace / attribute) OR a short time range.+ searchType := request.SearchType+ if searchType == "" {+ searchType = "body"+ }+ if request.Search != "" && searchType == "body" {+ hasSelector := request.MinSeverity > 0 ||+ request.ServiceName != "" ||+ request.TraceId != "" ||+ request.DistributedTraceId != "" ||+ len(request.AttributeFilters) > 0+ rangeTooWide := request.ToDate.Sub(request.FromDate) > bodySearchUnscopedMaxRange+ if !hasSelector && rangeTooWide {+ c.JSON(http.StatusUnprocessableEntity, gin.H{+ "error": "Body search over more than 24 hours requires a filter (service, severity, trace, or attribute). Narrow the time range or add a filter to continue.",+ })+ return+ }+ }++ attrFilters := make([]repositories.LogAttributeFilter, 0, len(request.AttributeFilters))+ for _, f := range request.AttributeFilters {+ if f.Key == "" || f.Scope == "" {+ continue+ }+ attrFilters = append(attrFilters, repositories.LogAttributeFilter{+ Scope: f.Scope,+ Key: f.Key,+ Value: f.Value,+ })+ }++ params := repositories.LogSearchParams{+ ProjectId: projectId,+ FromDate: request.FromDate,+ ToDate: request.ToDate,+ Search: request.Search,+ SearchType: searchType,+ MinSeverity: request.MinSeverity,+ ServiceName: request.ServiceName,+ TraceId: request.TraceId,+ AttributeFilters: attrFilters,+ OrderBy: request.OrderBy,+ SortDirection: request.SortDirection,+ Page: request.Pagination.Page,+ PageSize: request.Pagination.PageSize,+ }++ if request.DistributedTraceId != "" {+ dtid, err := uuid.Parse(request.DistributedTraceId)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "invalid distributedTraceId"})+ return+ }+ traceIds, err := l.resolveDistributedTraceIds(c, dtid, projectId, request.ExcludeTraceId)+ if err != nil {+ c.AbortWithError(500, traceway.NewStackTraceErrorf("error resolving distributed trace: %w", err))+ return+ }+ if len(traceIds) == 0 {+ c.JSON(http.StatusOK, PaginatedResponse[models.LogRecord]{+ Data: []models.LogRecord{},+ Pagination: Pagination{+ Page: request.Pagination.Page,+ PageSize: request.Pagination.PageSize,+ Total: 0,+ TotalPages: 0,+ },+ })+ return+ }+ params.TraceIds = traceIds+ params.TraceId = ""+ }++ span := traceway.StartSpan(c, "loading logs")+ records, total, err := repositories.LogRecordRepository.Search(c, params)+ span.End()+ if err != nil {+ c.AbortWithError(500, traceway.NewStackTraceErrorf("error loading logs: %w", err))+ return+ }++ c.JSON(http.StatusOK, PaginatedResponse[models.LogRecord]{+ Data: records,+ Pagination: Pagination{+ Page: request.Pagination.Page,+ PageSize: request.Pagination.PageSize,+ Total: total,+ TotalPages: (total + int64(request.Pagination.PageSize) - 1) / int64(request.Pagination.PageSize),+ },+ })+}++func (l logController) resolveDistributedTraceIds(ctx context.Context, dtid uuid.UUID, projectId uuid.UUID, excludeTraceHex string) ([]string, error) {+ projectIds := []uuid.UUID{projectId}++ endpoints, err := repositories.EndpointRepository.FindByDistributedTraceId(ctx, dtid, projectIds)+ if err != nil {+ return nil, err+ }+ tasks, err := repositories.TaskRepository.FindByDistributedTraceId(ctx, dtid, projectIds)+ if err != nil {+ return nil, err+ }++ seen := make(map[string]struct{}, len(endpoints)+len(tasks))+ result := make([]string, 0, len(endpoints)+len(tasks))+ add := func(id uuid.UUID) {+ h := hex.EncodeToString(id[:])+ if _, ok := seen[h]; ok {+ return+ }+ if h == excludeTraceHex {+ return+ }+ seen[h] = struct{}{}+ result = append(result, h)+ }+ for _, ep := range endpoints {+ add(ep.Id)+ }+ for _, t := range tasks {+ add(t.Id)+ }+ return result, nil+}diff --git a/backend/app/controllers/otelcontrollers/codec.go b/backend/app/controllers/otelcontrollers/codec.goindex 7a9e22b0..ac1bc3af 100644--- a/backend/app/controllers/otelcontrollers/codec.go+++ b/backend/app/controllers/otelcontrollers/codec.go@@ -8,8 +8,9 @@ import ("strings""github.com/gin-gonic/gin"- coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"+ collogspb "go.opentelemetry.io/proto/otlp/collector/logs/v1"colmetricspb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"+ coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1""google.golang.org/protobuf/encoding/protojson""google.golang.org/protobuf/proto")@@ -91,3 +92,32 @@ func writeMetricsResponse(c *gin.Context) {c.Data(http.StatusOK, "application/json", data)}}++func decodeLogsRequest(c *gin.Context) (*collogspb.ExportLogsServiceRequest, error) {+ body, err := readBody(c)+ if err != nil {+ return nil, err+ }+ req := &collogspb.ExportLogsServiceRequest{}+ if isProtobuf(c) {+ if err := proto.Unmarshal(body, req); err != nil {+ return nil, fmt.Errorf("failed to unmarshal protobuf: %w", err)+ }+ } else {+ if err := protojson.Unmarshal(body, req); err != nil {+ return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)+ }+ }+ return req, nil+}++func writeLogsResponse(c *gin.Context) {+ resp := &collogspb.ExportLogsServiceResponse{}+ if isProtobuf(c) {+ data, _ := proto.Marshal(resp)+ c.Data(http.StatusOK, "application/x-protobuf", data)+ } else {+ data, _ := protojson.Marshal(resp)+ c.Data(http.StatusOK, "application/json", data)+ }+}diff --git a/backend/app/controllers/otelcontrollers/helpers.go b/backend/app/controllers/otelcontrollers/helpers.goindex a52129ef..2367b420 100644--- a/backend/app/controllers/otelcontrollers/helpers.go+++ b/backend/app/controllers/otelcontrollers/helpers.go@@ -53,6 +53,26 @@ func nanoToTime(nanos uint64) time.Time {return time.Unix(0, int64(nanos))}+// spanUUIDToHex returns the hex representation of the last 8 bytes of a span-derived UUID+// (those last 8 bytes carry the original OTel span ID). Mirrors otelSpanIDToUUID going the+// other direction, producing the same format we store in log_records.span_id.+func spanUUIDToHex(u uuid.UUID) string {+ return hex.EncodeToString(u[8:])+}++// ptrSpanUUID wraps otelSpanIDToUUID for nullable parent-span-id capture: returns nil when+// the span has no parent bytes, or when the OTel span ID is malformed.+func ptrSpanUUID(raw []byte) *uuid.UUID {+ if len(raw) == 0 {+ return nil+ }+ u := otelSpanIDToUUID(raw)+ if u == uuid.Nil {+ return nil+ }+ return &u+}+func extractAttributes(attrs []*commonpb.KeyValue) map[string]string {if len(attrs) == 0 {return nildiff --git a/backend/app/controllers/otelcontrollers/logs_converter.go b/backend/app/controllers/otelcontrollers/logs_converter.gonew file mode 100644index 00000000..8bbbf40b--- /dev/null+++ b/backend/app/controllers/otelcontrollers/logs_converter.go@@ -0,0 +1,169 @@+package otelcontrollers++import (+ "encoding/hex"+ "encoding/json"+ "strconv"+ "strings"++ "github.com/google/uuid"+ collogspb "go.opentelemetry.io/proto/otlp/collector/logs/v1"+ commonpb "go.opentelemetry.io/proto/otlp/common/v1"+ logspb "go.opentelemetry.io/proto/otlp/logs/v1"++ "github.com/tracewayapp/traceway/backend/app/models"+)++func convertLogs(projectId uuid.UUID, req *collogspb.ExportLogsServiceRequest) []models.LogRecord {+ var records []models.LogRecord++ for _, rl := range req.ResourceLogs {+ resAttrs := extractAttributes(rl.GetResource().GetAttributes())+ serviceName := getStringAttribute(rl.GetResource().GetAttributes(), "service.name")+ resourceSchemaUrl := rl.GetSchemaUrl()++ for _, sl := range rl.ScopeLogs {+ scope := sl.GetScope()+ scopeName := scope.GetName()+ scopeVersion := scope.GetVersion()+ scopeAttrs := extractAttributes(scope.GetAttributes())+ scopeSchemaUrl := sl.GetSchemaUrl()++ for _, lr := range sl.LogRecords {+ records = append(records, toLogRecord(projectId, lr, serviceName, resourceSchemaUrl, resAttrs, scopeSchemaUrl, scopeName, scopeVersion, scopeAttrs))+ }+ }+ }++ return records+}++func toLogRecord(+ projectId uuid.UUID,+ lr *logspb.LogRecord,+ serviceName string,+ resourceSchemaUrl string,+ resourceAttrs map[string]string,+ scopeSchemaUrl string,+ scopeName string,+ scopeVersion string,+ scopeAttrs map[string]string,+) models.LogRecord {+ ts := lr.TimeUnixNano+ if ts == 0 {+ ts = lr.ObservedTimeUnixNano+ }++ severityNumber := uint8(lr.SeverityNumber)+ severityText := strings.ToUpper(lr.SeverityText)+ if severityText == "" {+ severityText = severityTextFromNumber(severityNumber)+ }++ return models.LogRecord{+ Id: uuid.New(),+ ProjectId: projectId,+ Timestamp: nanoToTime(ts),+ TraceId: hex.EncodeToString(lr.TraceId),+ SpanId: hex.EncodeToString(lr.SpanId),+ TraceFlags: uint8(lr.Flags),+ SeverityText: severityText,+ SeverityNumber: severityNumber,+ ServiceName: serviceName,+ Body: anyValueToString(lr.Body),+ ResourceSchemaUrl: resourceSchemaUrl,+ ResourceAttributes: resourceAttrs,+ ScopeSchemaUrl: scopeSchemaUrl,+ ScopeName: scopeName,+ ScopeVersion: scopeVersion,+ ScopeAttributes: scopeAttrs,+ LogAttributes: extractAttributes(lr.Attributes),+ }+}++func severityTextFromNumber(n uint8) string {+ switch {+ case n == 0:+ return ""+ case n <= 4:+ return "TRACE"+ case n <= 8:+ return "DEBUG"+ case n <= 12:+ return "INFO"+ case n <= 16:+ return "WARN"+ case n <= 20:+ return "ERROR"+ default:+ return "FATAL"+ }+}++func anyValueToString(v *commonpb.AnyValue) string {+ if v == nil || v.Value == nil {+ return ""+ }+ switch val := v.Value.(type) {+ case *commonpb.AnyValue_StringValue:+ return val.StringValue+ case *commonpb.AnyValue_IntValue:+ return strconv.FormatInt(val.IntValue, 10)+ case *commonpb.AnyValue_DoubleValue:+ return strconv.FormatFloat(val.DoubleValue, 'g', -1, 64)+ case *commonpb.AnyValue_BoolValue:+ return strconv.FormatBool(val.BoolValue)+ case *commonpb.AnyValue_BytesValue:+ return string(val.BytesValue)+ case *commonpb.AnyValue_ArrayValue:+ items := make([]interface{}, 0, len(val.ArrayValue.Values))+ for _, item := range val.ArrayValue.Values {+ items = append(items, anyValueToJSON(item))+ }+ if b, err := json.Marshal(items); err == nil {+ return string(b)+ }+ return ""+ case *commonpb.AnyValue_KvlistValue:+ m := make(map[string]interface{}, len(val.KvlistValue.Values))+ for _, kv := range val.KvlistValue.Values {+ m[kv.Key] = anyValueToJSON(kv.Value)+ }+ if b, err := json.Marshal(m); err == nil {+ return string(b)+ }+ return ""+ }+ return ""+}++func anyValueToJSON(v *commonpb.AnyValue) interface{} {+ if v == nil || v.Value == nil {+ return nil+ }+ switch val := v.Value.(type) {+ case *commonpb.AnyValue_StringValue:+ return val.StringValue+ case *commonpb.AnyValue_IntValue:+ return val.IntValue+ case *commonpb.AnyValue_DoubleValue:+ return val.DoubleValue+ case *commonpb.AnyValue_BoolValue:+ return val.BoolValue+ case *commonpb.AnyValue_BytesValue:+ return val.BytesValue+ case *commonpb.AnyValue_ArrayValue:+ out := make([]interface{}, 0, len(val.ArrayValue.Values))+ for _, item := range val.ArrayValue.Values {+ out = append(out, anyValueToJSON(item))+ }+ return out+ case *commonpb.AnyValue_KvlistValue:+ out := make(map[string]interface{}, len(val.KvlistValue.Values))+ for _, kv := range val.KvlistValue.Values {+ out[kv.Key] = anyValueToJSON(kv.Value)+ }+ return out+ }+ return nil+}diff --git a/backend/app/controllers/otelcontrollers/otel.controller.go b/backend/app/controllers/otelcontrollers/otel.controller.goindex 30286d1e..7c42a80c 100644--- a/backend/app/controllers/otelcontrollers/otel.controller.go+++ b/backend/app/controllers/otelcontrollers/otel.controller.go@@ -146,3 +146,39 @@ func (o otelController) ExportMetrics(c *gin.Context) {writeMetricsResponse(c)}++func (o otelController) ExportLogs(c *gin.Context) {+ projectId, err := middleware.GetProjectId(c)+ if err != nil {+ c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("UseClientAuth middleware must be applied: %w", err))+ return+ }++ if project, exists := c.Get(middleware.ProjectContextKey); exists {+ if p, ok := project.(*models.Project); ok && p.OrganizationId != nil {+ if attrs := traceway.GetAttributesFromContext(c); attrs != nil {+ attrs.SetTag("organization_id", fmt.Sprintf("%d", *p.OrganizationId))+ }+ if !hooks.CanReport(*p.OrganizationId) {+ c.AbortWithStatus(http.StatusTooManyRequests)+ return+ }+ }+ }++ req, err := decodeLogsRequest(c)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})+ return+ }++ records := convertLogs(projectId, req)+ if len(records) > 0 {+ if err := repositories.LogRecordRepository.InsertAsync(c, records); err != nil {+ c.AbortWithError(500, traceway.NewStackTraceErrorf("error inserting OTEL log records: %w", err))+ return+ }+ }++ writeLogsResponse(c)+}diff --git a/backend/app/controllers/otelcontrollers/trace_converter.go b/backend/app/controllers/otelcontrollers/trace_converter.goindex 6bfd0307..d5373c96 100644--- a/backend/app/controllers/otelcontrollers/trace_converter.go+++ b/backend/app/controllers/otelcontrollers/trace_converter.go@@ -46,29 +46,40 @@ func convertTraces(projectId uuid.UUID, req *coltracepb.ExportTraceServiceRequesscopeName string}var allSpans []spanEntry- parentMap := map[string]string{} // childSpanId → parentSpanId+ parentMap := map[string]string{} // childSpanId → parentSpanId+ spanById := map[string]*tracepb.Span{} // spanId → span (for trace_id lookup)for _, ss := range rs.ScopeSpans {for _, span := range ss.Spans {allSpans = append(allSpans, spanEntry{span: span, scopeName: ss.GetScope().GetName()})+ spanById[string(span.SpanId)] = spanif len(span.ParentSpanId) > 0 {parentMap[string(span.SpanId)] = string(span.ParentSpanId)}}}- // Build spanToTraceId by walking up to the root for each span+ // Build spanToTraceId. Prefer each span's native OTel trace_id so logs on+ // the wire (which carry trace_id as hex) can be joined against the+ // converted traces via traceIdUuidToHex(endpoint.id). Fall back to walking+ // parents + minting a UUID only when the OTel trace_id is missing or+ // malformed — an unusual case but worth handling defensively.spanToTraceId := map[string]uuid.UUID{}var resolveTraceId func(spanIdStr string) uuid.UUIDresolveTraceId = func(spanIdStr string) uuid.UUID {if tid, ok := spanToTraceId[spanIdStr]; ok {return tid}+ if sp, ok := spanById[spanIdStr]; ok && len(sp.TraceId) > 0 {+ if tid := otelTraceIDToUUID(sp.TraceId); tid != uuid.Nil {+ spanToTraceId[spanIdStr] = tid+ return tid+ }+ }if parentId, hasParent := parentMap[spanIdStr]; hasParent {tid := resolveTraceId(parentId)spanToTraceId[spanIdStr] = tidreturn tid}- // This is a root spantid := uuid.New()spanToTraceId[spanIdStr] = tidreturn tid@@ -99,12 +110,14 @@ func convertTraces(projectId uuid.UUID, req *coltracepb.ExportTraceServiceReques}if isRoot {+ rootSpanId := spanIdif (span.Kind == tracepb.Span_SPAN_KIND_SERVER || span.Kind == tracepb.Span_SPAN_KIND_INTERNAL) && hasHTTPAttributes(spanAttrs) {ep := buildEndpoint(traceId, projectId, span, spanAttrs, allAttrs,startTime, duration, serverName, appVersion,)ep.DistributedTraceId = distributedTraceId+ ep.SpanId = &rootSpanIdendpoints = append(endpoints, ep)} else if span.Kind == tracepb.Span_SPAN_KIND_CONSUMER {t := buildTask(@@ -112,6 +125,7 @@ func convertTraces(projectId uuid.UUID, req *coltracepb.ExportTraceServiceRequesstartTime, endTime, duration, serverName, appVersion,)t.DistributedTraceId = distributedTraceId+ t.SpanId = &rootSpanIdtasks = append(tasks, t)} else if hasGenAiAttributes(spanAttrs) {aiTrace := buildAiTrace(@@ -134,13 +148,14 @@ func convertTraces(projectId uuid.UUID, req *coltracepb.ExportTraceServiceReques}spans = append(spans, models.Span{- Id: spanId,- TraceId: traceId,- ProjectId: projectId,- Name: spanName,- StartTime: startTime,- Duration: duration,- RecordedAt: startTime,+ Id: spanId,+ TraceId: traceId,+ ProjectId: projectId,+ Name: spanName,+ StartTime: startTime,+ Duration: duration,+ RecordedAt: startTime,+ ParentSpanId: ptrSpanUUID(span.ParentSpanId),})}diff --git a/backend/app/controllers/routes.go b/backend/app/controllers/routes.goindex b1aec01c..feac36f4 100644--- a/backend/app/controllers/routes.go+++ b/backend/app/controllers/routes.go@@ -36,6 +36,7 @@ func RegisterControllers(router *gin.RouterGroup) {otelGroup := router.Group("/otel")otelGroup.POST("/v1/traces", middleware.UseClientAuth, otelcontrollers.OtelController.ExportTraces)otelGroup.POST("/v1/metrics", middleware.UseClientAuth, otelcontrollers.OtelController.ExportMetrics)+ otelGroup.POST("/v1/logs", middleware.UseClientAuth, otelcontrollers.OtelController.ExportLogs)// Project managementrouter.GET("/projects", middleware.UseAppAuth, ProjectController.ListProjects)@@ -93,6 +94,9 @@ func RegisterControllers(router *gin.RouterGroup) {// Distributed tracesrouter.POST("/distributed-traces/:distributedTraceId", middleware.UseAppAuth, DistributedTraceController.GetDistributedTrace)+ // Logs (projectId in body)+ router.POST("/logs", middleware.UseAppAuth, middleware.RequireProjectAccess, LogController.List)+// Exceptions (projectId in body)router.POST("/exception-stack-traces", middleware.UseAppAuth, middleware.RequireProjectAccess, ExceptionStackTraceController.FindGrouppedExceptionStackTraces)router.POST("/exception-stack-traces/archive", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.RequireWriteAccess, ExceptionStackTraceController.ArchiveExceptions)diff --git a/backend/app/migrations/ch/0045_create_log_records.up.sql b/backend/app/migrations/ch/0045_create_log_records.up.sqlnew file mode 100644index 00000000..ac44bea2--- /dev/null+++ b/backend/app/migrations/ch/0045_create_log_records.up.sql@@ -0,0 +1,31 @@+CREATE TABLE IF NOT EXISTS log_records (+ id UUID CODEC(ZSTD(1)),+ project_id UUID CODEC(ZSTD(1)),+ timestamp DateTime64(9) CODEC(Delta, ZSTD(1)),+ timestamp_date Date DEFAULT toDate(timestamp),+ trace_id String CODEC(ZSTD(1)),+ span_id String CODEC(ZSTD(1)),+ trace_flags UInt8,+ severity_text LowCardinality(String) CODEC(ZSTD(1)),+ severity_number UInt8,+ service_name LowCardinality(String) CODEC(ZSTD(1)),+ body String CODEC(ZSTD(1)),+ resource_schema_url LowCardinality(String) CODEC(ZSTD(1)),+ resource_attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ scope_schema_url LowCardinality(String) CODEC(ZSTD(1)),+ scope_name String CODEC(ZSTD(1)),+ scope_version LowCardinality(String) CODEC(ZSTD(1)),+ scope_attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ log_attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ INDEX idx_trace_id trace_id TYPE bloom_filter(0.001) GRANULARITY 1,+ INDEX idx_res_attr_key mapKeys(resource_attributes) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_res_attr_value mapValues(resource_attributes) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_log_attr_key mapKeys(log_attributes) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_log_attr_value mapValues(log_attributes) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_body body TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1+)+ENGINE = MergeTree+PARTITION BY timestamp_date+ORDER BY (project_id, service_name, severity_number, timestamp)+TTL timestamp_date + INTERVAL 30 DAY+SETTINGS index_granularity = 8192diff --git a/backend/app/migrations/ch/0046_add_parent_span_id_to_spans.up.sql b/backend/app/migrations/ch/0046_add_parent_span_id_to_spans.up.sqlnew file mode 100644index 00000000..b1c0d6c9--- /dev/null+++ b/backend/app/migrations/ch/0046_add_parent_span_id_to_spans.up.sql@@ -0,0 +1 @@+ALTER TABLE spans ADD COLUMN parent_span_id Nullable(UUID) DEFAULT NULLdiff --git a/backend/app/migrations/ch/0047_add_span_id_to_endpoints.up.sql b/backend/app/migrations/ch/0047_add_span_id_to_endpoints.up.sqlnew file mode 100644index 00000000..d8ab425c--- /dev/null+++ b/backend/app/migrations/ch/0047_add_span_id_to_endpoints.up.sql@@ -0,0 +1 @@+ALTER TABLE endpoints ADD COLUMN span_id Nullable(UUID) DEFAULT NULLdiff --git a/backend/app/migrations/ch/0048_add_span_id_to_tasks.up.sql b/backend/app/migrations/ch/0048_add_span_id_to_tasks.up.sqlnew file mode 100644index 00000000..83ecbeff--- /dev/null+++ b/backend/app/migrations/ch/0048_add_span_id_to_tasks.up.sql@@ -0,0 +1 @@+ALTER TABLE tasks ADD COLUMN span_id Nullable(UUID) DEFAULT NULLdiff --git a/backend/app/migrations/sqlite_telemetry/0003_create_log_records.up.sql b/backend/app/migrations/sqlite_telemetry/0003_create_log_records.up.sqlnew file mode 100644index 00000000..508d6000--- /dev/null+++ b/backend/app/migrations/sqlite_telemetry/0003_create_log_records.up.sql@@ -0,0 +1,22 @@+CREATE TABLE IF NOT EXISTS log_records (+ id TEXT NOT NULL,+ project_id TEXT NOT NULL,+ timestamp DATETIME NOT NULL,+ trace_id TEXT NOT NULL DEFAULT '',+ span_id TEXT NOT NULL DEFAULT '',+ trace_flags INTEGER NOT NULL DEFAULT 0,+ severity_text TEXT NOT NULL DEFAULT '',+ severity_number INTEGER NOT NULL DEFAULT 0,+ service_name TEXT NOT NULL DEFAULT '',+ body TEXT NOT NULL DEFAULT '',+ resource_schema_url TEXT NOT NULL DEFAULT '',+ resource_attributes TEXT NOT NULL DEFAULT '{}',+ scope_schema_url TEXT NOT NULL DEFAULT '',+ scope_name TEXT NOT NULL DEFAULT '',+ scope_version TEXT NOT NULL DEFAULT '',+ scope_attributes TEXT NOT NULL DEFAULT '{}',+ log_attributes TEXT NOT NULL DEFAULT '{}'+);+CREATE INDEX IF NOT EXISTS idx_log_records_project_timestamp ON log_records(project_id, timestamp);+CREATE INDEX IF NOT EXISTS idx_log_records_project_trace ON log_records(project_id, trace_id);+CREATE INDEX IF NOT EXISTS idx_log_records_project_service ON log_records(project_id, service_name, timestamp);diff --git a/backend/app/migrations/sqlite_telemetry/0004_add_parent_span_id_to_spans.up.sql b/backend/app/migrations/sqlite_telemetry/0004_add_parent_span_id_to_spans.up.sqlnew file mode 100644index 00000000..08d42793--- /dev/null+++ b/backend/app/migrations/sqlite_telemetry/0004_add_parent_span_id_to_spans.up.sql@@ -0,0 +1 @@+ALTER TABLE spans ADD COLUMN parent_span_id TEXT DEFAULT NULL;diff --git a/backend/app/migrations/sqlite_telemetry/0005_add_span_id_to_root_traces.up.sql b/backend/app/migrations/sqlite_telemetry/0005_add_span_id_to_root_traces.up.sqlnew file mode 100644index 00000000..3919fad5--- /dev/null+++ b/backend/app/migrations/sqlite_telemetry/0005_add_span_id_to_root_traces.up.sql@@ -0,0 +1,2 @@+ALTER TABLE endpoints ADD COLUMN span_id TEXT DEFAULT NULL;+ALTER TABLE tasks ADD COLUMN span_id TEXT DEFAULT NULL;diff --git a/backend/app/models/endpoint.model.go b/backend/app/models/endpoint.model.goindex 2d6000e3..566bc359 100644--- a/backend/app/models/endpoint.model.go+++ b/backend/app/models/endpoint.model.go@@ -20,6 +20,7 @@ type Endpoint struct {AppVersion string `json:"appVersion" ch:"app_version"`ServerName string `json:"serverName" ch:"server_name"`DistributedTraceId *uuid.UUID `json:"distributedTraceId,omitempty" ch:"distributed_trace_id"`+ SpanId *uuid.UUID `json:"spanId,omitempty" ch:"span_id"`}type EndpointStats struct {diff --git a/backend/app/models/log_record.model.go b/backend/app/models/log_record.model.gonew file mode 100644index 00000000..8a083b5e--- /dev/null+++ b/backend/app/models/log_record.model.go@@ -0,0 +1,27 @@+package models++import (+ "time"++ "github.com/google/uuid"+)++type LogRecord struct {+ Id uuid.UUID `json:"id" ch:"id"`+ ProjectId uuid.UUID `json:"projectId" ch:"project_id"`+ Timestamp time.Time `json:"timestamp" ch:"timestamp"`+ TraceId string `json:"traceId" ch:"trace_id"`+ SpanId string `json:"spanId" ch:"span_id"`+ TraceFlags uint8 `json:"traceFlags" ch:"trace_flags"`+ SeverityText string `json:"severityText" ch:"severity_text"`+ SeverityNumber uint8 `json:"severityNumber" ch:"severity_number"`+ ServiceName string `json:"serviceName" ch:"service_name"`+ Body string `json:"body" ch:"body"`+ ResourceSchemaUrl string `json:"resourceSchemaUrl" ch:"resource_schema_url"`+ ResourceAttributes map[string]string `json:"resourceAttributes" ch:"resource_attributes"`+ ScopeSchemaUrl string `json:"scopeSchemaUrl" ch:"scope_schema_url"`+ ScopeName string `json:"scopeName" ch:"scope_name"`+ ScopeVersion string `json:"scopeVersion" ch:"scope_version"`+ ScopeAttributes map[string]string `json:"scopeAttributes" ch:"scope_attributes"`+ LogAttributes map[string]string `json:"logAttributes" ch:"log_attributes"`+}diff --git a/backend/app/models/span.model.go b/backend/app/models/span.model.goindex 0a34af0c..fd330a8e 100644--- a/backend/app/models/span.model.go+++ b/backend/app/models/span.model.go@@ -7,11 +7,12 @@ import ()type Span struct {- Id uuid.UUID `json:"id" ch:"id"`- TraceId uuid.UUID `json:"traceId" ch:"trace_id"`- ProjectId uuid.UUID `json:"projectId" ch:"project_id"`- Name string `json:"name" ch:"name"`- StartTime time.Time `json:"startTime" ch:"start_time"`- Duration time.Duration `json:"duration" ch:"duration"`- RecordedAt time.Time `json:"recordedAt" ch:"recorded_at"`+ Id uuid.UUID `json:"id" ch:"id"`+ TraceId uuid.UUID `json:"traceId" ch:"trace_id"`+ ProjectId uuid.UUID `json:"projectId" ch:"project_id"`+ Name string `json:"name" ch:"name"`+ StartTime time.Time `json:"startTime" ch:"start_time"`+ Duration time.Duration `json:"duration" ch:"duration"`+ RecordedAt time.Time `json:"recordedAt" ch:"recorded_at"`+ ParentSpanId *uuid.UUID `json:"parentSpanId,omitempty" ch:"parent_span_id"`}diff --git a/backend/app/models/task.model.go b/backend/app/models/task.model.goindex 92aac96c..4484d16f 100644--- a/backend/app/models/task.model.go+++ b/backend/app/models/task.model.go@@ -17,6 +17,7 @@ type Task struct {AppVersion string `json:"appVersion" ch:"app_version"`ServerName string `json:"serverName" ch:"server_name"`DistributedTraceId *uuid.UUID `json:"distributedTraceId,omitempty" ch:"distributed_trace_id"`+ SpanId *uuid.UUID `json:"spanId,omitempty" ch:"span_id"`}type TaskStats struct {diff --git a/backend/app/repositories/endpoint.repository.go b/backend/app/repositories/endpoint.repository.goindex 754a151f..8efb7b3b 100644--- a/backend/app/repositories/endpoint.repository.go+++ b/backend/app/repositories/endpoint.repository.go@@ -18,7 +18,7 @@ import (type endpointRepository struct{}func (e *endpointRepository) InsertAsync(ctx context.Context, lines []models.Endpoint) error {- batch, err := chdb.Conn.PrepareBatch(clickhouse.Context(context.Background(), clickhouse.WithAsync(false)), "INSERT INTO endpoints (id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id)")+ batch, err := chdb.Conn.PrepareBatch(clickhouse.Context(context.Background(), clickhouse.WithAsync(false)), "INSERT INTO endpoints (id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id, span_id)")if err != nil {return err}@@ -29,7 +29,7 @@ func (e *endpointRepository) InsertAsync(ctx context.Context, lines []models.EndattributesJSON = string(attributesBytes)}}- if err := batch.Append(t.Id, t.ProjectId, t.Endpoint, int64(t.Duration), t.RecordedAt, t.StatusCode, t.BodySize, t.ClientIP, attributesJSON, t.AppVersion, t.ServerName, t.DistributedTraceId); err != nil {+ if err := batch.Append(t.Id, t.ProjectId, t.Endpoint, int64(t.Duration), t.RecordedAt, t.StatusCode, t.BodySize, t.ClientIP, attributesJSON, t.AppVersion, t.ServerName, t.DistributedTraceId, t.SpanId); err != nil {return err}}@@ -278,7 +278,7 @@ func (e *endpointRepository) FindByEndpoint(ctx context.Context, projectId uuid.// FindById returns a single endpoint by IDfunc (e *endpointRepository) FindById(ctx context.Context, projectId, endpointId uuid.UUID) (*models.Endpoint, error) {- query := `SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id+ query := `SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id, span_idFROM endpointsWHERE project_id = ? AND id = ?LIMIT 1`@@ -288,7 +288,7 @@ func (e *endpointRepository) FindById(ctx context.Context, projectId, endpointIderr := chdb.Conn.QueryRow(ctx, query, projectId, endpointId).Scan(&t.Id, &t.ProjectId, &t.Endpoint, &t.Duration, &t.RecordedAt,- &t.StatusCode, &t.BodySize, &t.ClientIP, &attributesJSON, &t.AppVersion, &t.ServerName, &t.DistributedTraceId)+ &t.StatusCode, &t.BodySize, &t.ClientIP, &attributesJSON, &t.AppVersion, &t.ServerName, &t.DistributedTraceId, &t.SpanId)if err != nil {if errors.Is(err, sql.ErrNoRows) {diff --git a/backend/app/repositories/endpoint.repository_sqlite.go b/backend/app/repositories/endpoint.repository_sqlite.goindex b2ec0024..41865393 100644--- a/backend/app/repositories/endpoint.repository_sqlite.go+++ b/backend/app/repositories/endpoint.repository_sqlite.go@@ -30,6 +30,7 @@ type endpoint struct {AppVersion string `lit:"app_version"`ServerName string `lit:"server_name"`DistributedTraceId *uuid.UUID `lit:"distributed_trace_id"`+ SpanId *uuid.UUID `lit:"span_id"`}type groupedEndpointRow struct {@@ -96,6 +97,7 @@ func endpointToRow(e models.Endpoint) endpoint {AppVersion: e.AppVersion,ServerName: e.ServerName,DistributedTraceId: e.DistributedTraceId,+ SpanId: e.SpanId,}}@@ -112,6 +114,7 @@ func (r *endpoint) toModel() models.Endpoint {AppVersion: r.AppVersion,ServerName: r.ServerName,DistributedTraceId: r.DistributedTraceId,+ SpanId: r.SpanId,}if r.Attributes != nil {e.Attributes = map[string]string(r.Attributes)@@ -332,7 +335,7 @@ func (e *endpointRepository) FindByEndpoint(ctx context.Context, projectId uuid.func (e *endpointRepository) FindById(ctx context.Context, projectId, endpointId uuid.UUID) (*models.Endpoint, error) {row, err := lit.SelectSingleNamed[endpoint](db.TelemetryDB,- `SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id+ `SELECT id, project_id, endpoint, duration, recorded_at, status_code, body_size, client_ip, attributes, app_version, server_name, distributed_trace_id, span_idFROM endpoints WHERE project_id = :project_id AND id = :id LIMIT 1`,lit.P{"project_id": projectId, "id": endpointId})if err != nil {diff --git a/backend/app/repositories/log_record.repository.go b/backend/app/repositories/log_record.repository.gonew file mode 100644index 00000000..6ac66db3--- /dev/null+++ b/backend/app/repositories/log_record.repository.go@@ -0,0 +1,312 @@+//go:build pgch++package repositories++import (+ "context"+ "strings"+ "time"++ "github.com/ClickHouse/clickhouse-go/v2"+ "github.com/google/uuid"++ "github.com/tracewayapp/traceway/backend/app/chdb"+ "github.com/tracewayapp/traceway/backend/app/models"+)++// LogAttributeFilter selects logs by an exact attribute value. Scope is one of+// "resource", "scope", or "log"; picks which of the three Map columns to query.+// Leverages the map bloom-filter indexes — cheap even on wide time ranges.+type LogAttributeFilter struct {+ Scope string+ Key string+ Value string+}++type LogSearchParams struct {+ ProjectId uuid.UUID+ FromDate time.Time+ ToDate time.Time+ Search string+ SearchType string+ MinSeverity uint8+ ServiceName string+ TraceId string+ TraceIds []string+ AttributeFilters []LogAttributeFilter+ OrderBy string+ SortDirection string+ Page int+ PageSize int+}++type logRecordRepository struct{}++func (r *logRecordRepository) InsertAsync(ctx context.Context, records []models.LogRecord) error {+ if len(records) == 0 {+ return nil+ }++ batch, err := chdb.Conn.PrepareBatch(+ clickhouse.Context(context.Background(), clickhouse.WithAsync(false)),+ "INSERT INTO log_records (id, project_id, timestamp, trace_id, span_id, trace_flags, severity_text, severity_number, service_name, body, resource_schema_url, resource_attributes, scope_schema_url, scope_name, scope_version, scope_attributes, log_attributes)",+ )+ if err != nil {+ return err+ }++ for _, lr := range records {+ resAttrs := lr.ResourceAttributes+ if resAttrs == nil {+ resAttrs = map[string]string{}+ }+ scopeAttrs := lr.ScopeAttributes+ if scopeAttrs == nil {+ scopeAttrs = map[string]string{}+ }+ logAttrs := lr.LogAttributes+ if logAttrs == nil {+ logAttrs = map[string]string{}+ }++ if err := batch.Append(+ lr.Id,+ lr.ProjectId,+ lr.Timestamp,+ lr.TraceId,+ lr.SpanId,+ lr.TraceFlags,+ lr.SeverityText,+ lr.SeverityNumber,+ lr.ServiceName,+ lr.Body,+ lr.ResourceSchemaUrl,+ resAttrs,+ lr.ScopeSchemaUrl,+ lr.ScopeName,+ lr.ScopeVersion,+ scopeAttrs,+ logAttrs,+ ); err != nil {+ return err+ }+ }++ return batch.Send()+}++func (r *logRecordRepository) Search(ctx context.Context, params LogSearchParams) ([]models.LogRecord, int64, error) {+ where, args := r.buildWhere(params)++ countQuery := "SELECT count() FROM log_records WHERE " + where+ var count uint64+ if err := chdb.Conn.QueryRow(ctx, countQuery, args...).Scan(&count); err != nil {+ return nil, 0, err+ }+ if count == 0 {+ return nil, 0, nil+ }++ orderBy := r.resolveOrderBy(params.OrderBy)+ direction := "DESC"+ if strings.EqualFold(params.SortDirection, "asc") {+ direction = "ASC"+ }++ if params.PageSize <= 0 {+ params.PageSize = 50+ }+ if params.Page <= 0 {+ params.Page = 1+ }+ offset := (params.Page - 1) * params.PageSize++ query := `SELECT id, project_id, timestamp, trace_id, span_id, trace_flags,+ severity_text, severity_number, service_name, body,+ resource_schema_url, resource_attributes,+ scope_schema_url, scope_name, scope_version, scope_attributes,+ log_attributes+ FROM log_records+ WHERE ` + where + ` ORDER BY ` + orderBy + ` ` + direction + ` LIMIT ? OFFSET ?`++ args = append(args, params.PageSize, offset)++ rows, err := chdb.Conn.Query(ctx, query, args...)+ if err != nil {+ return nil, 0, err+ }+ defer rows.Close()++ var records []models.LogRecord+ for rows.Next() {+ var lr models.LogRecord+ if err := rows.Scan(+ &lr.Id,+ &lr.ProjectId,+ &lr.Timestamp,+ &lr.TraceId,+ &lr.SpanId,+ &lr.TraceFlags,+ &lr.SeverityText,+ &lr.SeverityNumber,+ &lr.ServiceName,+ &lr.Body,+ &lr.ResourceSchemaUrl,+ &lr.ResourceAttributes,+ &lr.ScopeSchemaUrl,+ &lr.ScopeName,+ &lr.ScopeVersion,+ &lr.ScopeAttributes,+ &lr.LogAttributes,+ ); err != nil {+ return nil, 0, err+ }+ records = append(records, lr)+ }++ return records, int64(count), nil+}++func (r *logRecordRepository) FindByTraceId(ctx context.Context, projectId uuid.UUID, traceId string) ([]models.LogRecord, error) {+ query := `SELECT id, project_id, timestamp, trace_id, span_id, trace_flags,+ severity_text, severity_number, service_name, body,+ resource_schema_url, resource_attributes,+ scope_schema_url, scope_name, scope_version, scope_attributes,+ log_attributes+ FROM log_records+ WHERE project_id = ? AND trace_id = ?+ ORDER BY timestamp ASC`++ rows, err := chdb.Conn.Query(ctx, query, projectId, traceId)+ if err != nil {+ return nil, err+ }+ defer rows.Close()++ var records []models.LogRecord+ for rows.Next() {+ var lr models.LogRecord+ if err := rows.Scan(+ &lr.Id,+ &lr.ProjectId,+ &lr.Timestamp,+ &lr.TraceId,+ &lr.SpanId,+ &lr.TraceFlags,+ &lr.SeverityText,+ &lr.SeverityNumber,+ &lr.ServiceName,+ &lr.Body,+ &lr.ResourceSchemaUrl,+ &lr.ResourceAttributes,+ &lr.ScopeSchemaUrl,+ &lr.ScopeName,+ &lr.ScopeVersion,+ &lr.ScopeAttributes,+ &lr.LogAttributes,+ ); err != nil {+ return nil, err+ }+ records = append(records, lr)+ }+ return records, nil+}++func (r *logRecordRepository) buildWhere(params LogSearchParams) (string, []interface{}) {+ clauses := []string{"project_id = ?", "timestamp >= ?", "timestamp <= ?"}+ args := []interface{}{params.ProjectId, params.FromDate, params.ToDate}++ if params.MinSeverity > 0 {+ clauses = append(clauses, "severity_number >= ?")+ args = append(args, params.MinSeverity)+ }+ if params.ServiceName != "" {+ clauses = append(clauses, "service_name = ?")+ args = append(args, params.ServiceName)+ }+ if len(params.TraceIds) > 0 {+ placeholders := make([]string, len(params.TraceIds))+ for i, tid := range params.TraceIds {+ placeholders[i] = "?"+ args = append(args, tid)+ }+ clauses = append(clauses, "trace_id IN ("+strings.Join(placeholders, ", ")+")")+ } else if params.TraceId != "" {+ clauses = append(clauses, "trace_id = ?")+ args = append(args, params.TraceId)+ }++ for _, f := range params.AttributeFilters {+ col := attrColumn(f.Scope)+ if col == "" {+ continue+ }+ clauses = append(clauses, col+"[?] = ?")+ args = append(args, f.Key, f.Value)+ }++ if params.Search != "" {+ switch params.SearchType {+ case "service":+ clauses = append(clauses, "service_name ILIKE ?")+ args = append(args, "%"+params.Search+"%")+ case "trace":+ clauses = append(clauses, "trace_id = ?")+ args = append(args, params.Search)+ default:+ // Prefer hasToken() for single-word searches — it actually uses the+ // tokenbf_v1 index on body. Fall back to ILIKE when the term is not+ // a single alphanumeric token (multi-word, punctuation, etc.).+ if isSingleToken(params.Search) {+ clauses = append(clauses, "hasToken(body, ?)")+ args = append(args, params.Search)+ } else {+ clauses = append(clauses, "body ILIKE ?")+ args = append(args, "%"+params.Search+"%")+ }+ }+ }++ return strings.Join(clauses, " AND "), args+}++func attrColumn(scope string) string {+ switch scope {+ case "resource":+ return "resource_attributes"+ case "scope":+ return "scope_attributes"+ case "log":+ return "log_attributes"+ default:+ return ""+ }+}++// isSingleToken reports whether s is a single alphanumeric/underscore token —+// the only shape that tokenbf_v1 on body can accelerate via hasToken().+func isSingleToken(s string) bool {+ if s == "" {+ return false+ }+ for _, r := range s {+ if !(r == '_' || (r >= '0' && r <= '9') || (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z')) {+ return false+ }+ }+ return true+}++func (r *logRecordRepository) resolveOrderBy(orderBy string) string {+ allowed := map[string]string{+ "timestamp": "timestamp",+ "severity_number": "severity_number",+ "service_name": "service_name",+ }+ if col, ok := allowed[orderBy]; ok {+ return col+ }+ return "timestamp"+}++var LogRecordRepository = logRecordRepository{}diff --git a/backend/app/repositories/log_record.repository_sqlite.go b/backend/app/repositories/log_record.repository_sqlite.gonew file mode 100644index 00000000..e87f445a--- /dev/null+++ b/backend/app/repositories/log_record.repository_sqlite.go@@ -0,0 +1,298 @@+//go:build !pgch++package repositories++import (+ "context"+ "fmt"+ "strings"+ "time"++ "github.com/google/uuid"+ "github.com/tracewayapp/lit/v2"++ "github.com/tracewayapp/traceway/backend/app/db"+ "github.com/tracewayapp/traceway/backend/app/models"+)++// LogAttributeFilter — see the ClickHouse-side definition. Kept identical here+// so callers don't need a build-tag guard.+type LogAttributeFilter struct {+ Scope string+ Key string+ Value string+}++type LogSearchParams struct {+ ProjectId uuid.UUID+ FromDate time.Time+ ToDate time.Time+ Search string+ SearchType string+ MinSeverity uint8+ ServiceName string+ TraceId string+ TraceIds []string+ AttributeFilters []LogAttributeFilter+ OrderBy string+ SortDirection string+ Page int+ PageSize int+}++type logRecord struct {+ Id uuid.UUID `lit:"id"`+ ProjectId uuid.UUID `lit:"project_id"`+ Timestamp SQLiteTime `lit:"timestamp"`+ TraceId string `lit:"trace_id"`+ SpanId string `lit:"span_id"`+ TraceFlags uint8 `lit:"trace_flags"`+ SeverityText string `lit:"severity_text"`+ SeverityNumber uint8 `lit:"severity_number"`+ ServiceName string `lit:"service_name"`+ Body string `lit:"body"`+ ResourceSchemaUrl string `lit:"resource_schema_url"`+ ResourceAttributes SQLiteJSONMap `lit:"resource_attributes"`+ ScopeSchemaUrl string `lit:"scope_schema_url"`+ ScopeName string `lit:"scope_name"`+ ScopeVersion string `lit:"scope_version"`+ ScopeAttributes SQLiteJSONMap `lit:"scope_attributes"`+ LogAttributes SQLiteJSONMap `lit:"log_attributes"`+}++func init() {+ models.ExtensionModelRegistrations = append(models.ExtensionModelRegistrations, func(driver lit.Driver) {+ lit.RegisterModel[logRecord](driver)+ })+}++func logRecordToRow(lr models.LogRecord) logRecord {+ return logRecord{+ Id: lr.Id,+ ProjectId: lr.ProjectId,+ Timestamp: NewSQLiteTime(lr.Timestamp),+ TraceId: lr.TraceId,+ SpanId: lr.SpanId,+ TraceFlags: lr.TraceFlags,+ SeverityText: lr.SeverityText,+ SeverityNumber: lr.SeverityNumber,+ ServiceName: lr.ServiceName,+ Body: lr.Body,+ ResourceSchemaUrl: lr.ResourceSchemaUrl,+ ResourceAttributes: NewSQLiteJSONMap(lr.ResourceAttributes),+ ScopeSchemaUrl: lr.ScopeSchemaUrl,+ ScopeName: lr.ScopeName,+ ScopeVersion: lr.ScopeVersion,+ ScopeAttributes: NewSQLiteJSONMap(lr.ScopeAttributes),+ LogAttributes: NewSQLiteJSONMap(lr.LogAttributes),+ }+}++func (r *logRecord) toModel() models.LogRecord {+ lr := models.LogRecord{+ Id: r.Id,+ ProjectId: r.ProjectId,+ Timestamp: r.Timestamp.Time,+ TraceId: r.TraceId,+ SpanId: r.SpanId,+ TraceFlags: r.TraceFlags,+ SeverityText: r.SeverityText,+ SeverityNumber: r.SeverityNumber,+ ServiceName: r.ServiceName,+ Body: r.Body,+ ResourceSchemaUrl: r.ResourceSchemaUrl,+ ScopeSchemaUrl: r.ScopeSchemaUrl,+ ScopeName: r.ScopeName,+ ScopeVersion: r.ScopeVersion,+ }+ if r.ResourceAttributes != nil {+ lr.ResourceAttributes = map[string]string(r.ResourceAttributes)+ }+ if r.ScopeAttributes != nil {+ lr.ScopeAttributes = map[string]string(r.ScopeAttributes)+ }+ if r.LogAttributes != nil {+ lr.LogAttributes = map[string]string(r.LogAttributes)+ }+ return lr+}++type logRecordRepository struct{}++func (r *logRecordRepository) InsertAsync(ctx context.Context, records []models.LogRecord) error {+ if len(records) == 0 {+ return nil+ }+ for _, lr := range records {+ row := logRecordToRow(lr)+ if err := lit.InsertExistingUuid(db.TelemetryDB, &row); err != nil {+ return err+ }+ }+ return nil+}++func (r *logRecordRepository) Search(ctx context.Context, params LogSearchParams) ([]models.LogRecord, int64, error) {+ where, args := r.buildWhere(params)++ countResult, err := lit.SelectSingleNamed[models.CountResult](db.TelemetryDB,+ "SELECT COUNT(*) AS count FROM log_records WHERE "+where, args)+ if err != nil {+ return nil, 0, err+ }+ count := int64(0)+ if countResult != nil {+ count = int64(countResult.Count)+ }+ if count == 0 {+ return nil, 0, nil+ }++ orderBy := r.resolveOrderBy(params.OrderBy)+ direction := "DESC"+ if strings.EqualFold(params.SortDirection, "asc") {+ direction = "ASC"+ }++ if params.PageSize <= 0 {+ params.PageSize = 50+ }+ if params.Page <= 0 {+ params.Page = 1+ }+ offset := (params.Page - 1) * params.PageSize++ args["limit"] = params.PageSize+ args["offset"] = offset++ query := fmt.Sprintf(`SELECT id, project_id, timestamp, trace_id, span_id, trace_flags,+ severity_text, severity_number, service_name, body,+ resource_schema_url, resource_attributes,+ scope_schema_url, scope_name, scope_version, scope_attributes,+ log_attributes+ FROM log_records+ WHERE %s+ ORDER BY %s %s+ LIMIT :limit OFFSET :offset`, where, orderBy, direction)++ rows, err := lit.SelectNamed[logRecord](db.TelemetryDB, query, args)+ if err != nil {+ return nil, 0, err+ }++ records := make([]models.LogRecord, 0, len(rows))+ for _, row := range rows {+ records = append(records, row.toModel())+ }+ return records, count, nil+}++func (r *logRecordRepository) FindByTraceId(ctx context.Context, projectId uuid.UUID, traceId string) ([]models.LogRecord, error) {+ rows, err := lit.SelectNamed[logRecord](db.TelemetryDB,+ `SELECT id, project_id, timestamp, trace_id, span_id, trace_flags,+ severity_text, severity_number, service_name, body,+ resource_schema_url, resource_attributes,+ scope_schema_url, scope_name, scope_version, scope_attributes,+ log_attributes+ FROM log_records+ WHERE project_id = :project_id AND trace_id = :trace_id+ ORDER BY timestamp ASC`,+ lit.P{"project_id": projectId, "trace_id": traceId})+ if err != nil {+ return nil, err+ }++ records := make([]models.LogRecord, 0, len(rows))+ for _, row := range rows {+ records = append(records, row.toModel())+ }+ return records, nil+}++func (r *logRecordRepository) buildWhere(params LogSearchParams) (string, lit.P) {+ clauses := []string{"project_id = :project_id", "timestamp >= :from", "timestamp <= :to"}+ args := lit.P{+ "project_id": params.ProjectId,+ "from": NewSQLiteTime(params.FromDate),+ "to": NewSQLiteTime(params.ToDate),+ }++ if params.MinSeverity > 0 {+ clauses = append(clauses, "severity_number >= :min_severity")+ args["min_severity"] = params.MinSeverity+ }+ if params.ServiceName != "" {+ clauses = append(clauses, "service_name = :service_name")+ args["service_name"] = params.ServiceName+ }+ if len(params.TraceIds) > 0 {+ placeholders := make([]string, len(params.TraceIds))+ for i, tid := range params.TraceIds {+ key := fmt.Sprintf("tid%d", i)+ placeholders[i] = ":" + key+ args[key] = tid+ }+ clauses = append(clauses, "trace_id IN ("+strings.Join(placeholders, ", ")+")")+ } else if params.TraceId != "" {+ clauses = append(clauses, "trace_id = :trace_id")+ args["trace_id"] = params.TraceId+ }++ for i, f := range params.AttributeFilters {+ col := attrColumn(f.Scope)+ if col == "" {+ continue+ }+ keyPH := fmt.Sprintf("attr_k%d", i)+ valPH := fmt.Sprintf("attr_v%d", i)+ clauses = append(clauses,+ fmt.Sprintf("json_extract(%s, '$.' || :%s) = :%s", col, keyPH, valPH))+ args[keyPH] = f.Key+ args[valPH] = f.Value+ }++ if params.Search != "" {+ switch params.SearchType {+ case "service":+ clauses = append(clauses, "INSTR(LOWER(service_name), LOWER(:search)) > 0")+ args["search"] = params.Search+ case "trace":+ if _, exists := args["trace_id"]; !exists {+ clauses = append(clauses, "trace_id = :search")+ args["search"] = params.Search+ }+ default:+ clauses = append(clauses, "INSTR(LOWER(body), LOWER(:search)) > 0")+ args["search"] = params.Search+ }+ }++ return strings.Join(clauses, " AND "), args+}++func attrColumn(scope string) string {+ switch scope {+ case "resource":+ return "resource_attributes"+ case "scope":+ return "scope_attributes"+ case "log":+ return "log_attributes"+ default:+ return ""+ }+}++func (r *logRecordRepository) resolveOrderBy(orderBy string) string {+ allowed := map[string]string{+ "timestamp": "timestamp",+ "severity_number": "severity_number",+ "service_name": "service_name",+ }+ if col, ok := allowed[orderBy]; ok {+ return col+ }+ return "timestamp"+}++var LogRecordRepository = logRecordRepository{}diff --git a/backend/app/repositories/span.repository.go b/backend/app/repositories/span.repository.goindex 945895c3..caa9a4f2 100644--- a/backend/app/repositories/span.repository.go+++ b/backend/app/repositories/span.repository.go@@ -19,7 +19,7 @@ func (r *spanRepository) InsertAsync(ctx context.Context, spans []models.Span) e}batch, err := chdb.Conn.PrepareBatch(clickhouse.Context(context.Background(), clickhouse.WithAsync(false)),- "INSERT INTO spans (id, trace_id, project_id, name, start_time, duration, recorded_at)")+ "INSERT INTO spans (id, trace_id, project_id, name, start_time, duration, recorded_at, parent_span_id)")if err != nil {return err}@@ -33,6 +33,7 @@ func (r *spanRepository) InsertAsync(ctx context.Context, spans []models.Span) es.StartTime,int64(s.Duration),s.RecordedAt,+ s.ParentSpanId,); err != nil {return err}@@ -43,7 +44,7 @@ func (r *spanRepository) InsertAsync(ctx context.Context, spans []models.Span) efunc (r *spanRepository) FindByTraceId(ctx context.Context, projectId, traceId uuid.UUID) ([]models.Span, error) {query := `SELECT- id, trace_id, project_id, name, start_time, duration, recorded_at+ id, trace_id, project_id, name, start_time, duration, recorded_at, parent_span_idFROM spansWHERE project_id = ? AND trace_id = ?ORDER BY start_time ASC`@@ -59,7 +60,7 @@ func (r *spanRepository) FindByTraceId(ctx context.Context, projectId, traceId uvar s models.Spanif err := rows.Scan(&s.Id, &s.TraceId, &s.ProjectId,- &s.Name, &s.StartTime, &s.Duration, &s.RecordedAt,+ &s.Name, &s.StartTime, &s.Duration, &s.RecordedAt, &s.ParentSpanId,); err != nil {return nil, err}diff --git a/backend/app/repositories/span.repository_sqlite.go b/backend/app/repositories/span.repository_sqlite.goindex d671529b..75db4084 100644--- a/backend/app/repositories/span.repository_sqlite.go+++ b/backend/app/repositories/span.repository_sqlite.go@@ -13,13 +13,14 @@ import ()type span struct {- Id uuid.UUID `lit:"id"`- TraceId uuid.UUID `lit:"trace_id"`- ProjectId uuid.UUID `lit:"project_id"`- Name string `lit:"name"`- StartTime SQLiteTime `lit:"start_time"`- Duration int64 `lit:"duration"`- RecordedAt SQLiteTime `lit:"recorded_at"`+ Id uuid.UUID `lit:"id"`+ TraceId uuid.UUID `lit:"trace_id"`+ ProjectId uuid.UUID `lit:"project_id"`+ Name string `lit:"name"`+ StartTime SQLiteTime `lit:"start_time"`+ Duration int64 `lit:"duration"`+ RecordedAt SQLiteTime `lit:"recorded_at"`+ ParentSpanId *uuid.UUID `lit:"parent_span_id"`}func init() {@@ -30,25 +31,27 @@ func init() {func spanToRow(s models.Span) span {return span{- Id: s.Id,- TraceId: s.TraceId,- ProjectId: s.ProjectId,- Name: s.Name,- StartTime: NewSQLiteTime(s.StartTime),- Duration: int64(s.Duration),- RecordedAt: NewSQLiteTime(s.RecordedAt),+ Id: s.Id,+ TraceId: s.TraceId,+ ProjectId: s.ProjectId,+ Name: s.Name,+ StartTime: NewSQLiteTime(s.StartTime),+ Duration: int64(s.Duration),+ RecordedAt: NewSQLiteTime(s.RecordedAt),+ ParentSpanId: s.ParentSpanId,}}func (r *span) toModel() models.Span {return models.Span{- Id: r.Id,- TraceId: r.TraceId,- ProjectId: r.ProjectId,- Name: r.Name,- StartTime: r.StartTime.Time,- Duration: time.Duration(r.Duration),- RecordedAt: r.RecordedAt.Time,+ Id: r.Id,+ TraceId: r.TraceId,+ ProjectId: r.ProjectId,+ Name: r.Name,+ StartTime: r.StartTime.Time,+ Duration: time.Duration(r.Duration),+ RecordedAt: r.RecordedAt.Time,+ ParentSpanId: r.ParentSpanId,}}@@ -71,7 +74,7 @@ func (r *spanRepository) InsertAsync(ctx context.Context, spans []models.Span) efunc (r *spanRepository) FindByTraceId(ctx context.Context, projectId, traceId uuid.UUID) ([]models.Span, error) {rows, err := lit.SelectNamed[span](db.TelemetryDB,- `SELECT id, trace_id, project_id, name, start_time, duration, recorded_at+ `SELECT id, trace_id, project_id, name, start_time, duration, recorded_at, parent_span_idFROM spansWHERE project_id = :project_id AND trace_id = :trace_idORDER BY start_time ASC`,diff --git a/backend/app/repositories/task.repository.go b/backend/app/repositories/task.repository.goindex b4f0d461..990630af 100644--- a/backend/app/repositories/task.repository.go+++ b/backend/app/repositories/task.repository.go@@ -18,7 +18,7 @@ import (type taskRepository struct{}func (e *taskRepository) InsertAsync(ctx context.Context, lines []models.Task) error {- batch, err := chdb.Conn.PrepareBatch(clickhouse.Context(context.Background(), clickhouse.WithAsync(false)), "INSERT INTO tasks (id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id)")+ batch, err := chdb.Conn.PrepareBatch(clickhouse.Context(context.Background(), clickhouse.WithAsync(false)), "INSERT INTO tasks (id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id, span_id)")if err != nil {return err}@@ -29,7 +29,7 @@ func (e *taskRepository) InsertAsync(ctx context.Context, lines []models.Task) eattributesJSON = string(attributesBytes)}}- if err := batch.Append(t.Id, t.ProjectId, t.TaskName, int64(t.Duration), t.RecordedAt, t.ClientIP, attributesJSON, t.AppVersion, t.ServerName, t.DistributedTraceId); err != nil {+ if err := batch.Append(t.Id, t.ProjectId, t.TaskName, int64(t.Duration), t.RecordedAt, t.ClientIP, attributesJSON, t.AppVersion, t.ServerName, t.DistributedTraceId, t.SpanId); err != nil {return err}}@@ -202,7 +202,7 @@ func (e *taskRepository) FindByTaskName(ctx context.Context, projectId uuid.UUID// FindById returns a single task by IDfunc (e *taskRepository) FindById(ctx context.Context, projectId, taskId uuid.UUID) (*models.Task, error) {- query := `SELECT id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id+ query := `SELECT id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id, span_idFROM tasksWHERE project_id = ? AND id = ?LIMIT 1`@@ -212,7 +212,7 @@ func (e *taskRepository) FindById(ctx context.Context, projectId, taskId uuid.UUerr := chdb.Conn.QueryRow(ctx, query, projectId, taskId).Scan(&t.Id, &t.ProjectId, &t.TaskName, &t.Duration, &t.RecordedAt,- &t.ClientIP, &attributesJSON, &t.AppVersion, &t.ServerName, &t.DistributedTraceId)+ &t.ClientIP, &attributesJSON, &t.AppVersion, &t.ServerName, &t.DistributedTraceId, &t.SpanId)if err != nil {if errors.Is(err, sql.ErrNoRows) {diff --git a/backend/app/repositories/task.repository_sqlite.go b/backend/app/repositories/task.repository_sqlite.goindex 032ef9eb..124a2bb0 100644--- a/backend/app/repositories/task.repository_sqlite.go+++ b/backend/app/repositories/task.repository_sqlite.go@@ -26,6 +26,7 @@ type task struct {AppVersion string `lit:"app_version"`ServerName string `lit:"server_name"`DistributedTraceId *uuid.UUID `lit:"distributed_trace_id"`+ SpanId *uuid.UUID `lit:"span_id"`}type taskGroupRow struct {@@ -65,6 +66,7 @@ func taskToRow(t models.Task) task {AppVersion: t.AppVersion,ServerName: t.ServerName,DistributedTraceId: t.DistributedTraceId,+ SpanId: t.SpanId,}}@@ -79,6 +81,7 @@ func (r *task) toModel() models.Task {AppVersion: r.AppVersion,ServerName: r.ServerName,DistributedTraceId: r.DistributedTraceId,+ SpanId: r.SpanId,}if r.Attributes != nil {t.Attributes = map[string]string(r.Attributes)@@ -304,7 +307,7 @@ func (e *taskRepository) FindByTaskName(ctx context.Context, projectId uuid.UUIDfunc (e *taskRepository) FindById(ctx context.Context, projectId, taskId uuid.UUID) (*models.Task, error) {row, err := lit.SelectSingleNamed[task](db.TelemetryDB,- `SELECT id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id+ `SELECT id, project_id, task_name, duration, recorded_at, client_ip, attributes, app_version, server_name, distributed_trace_id, span_idFROM tasks WHERE project_id = :project_id AND id = :id LIMIT 1`,lit.P{"project_id": projectId, "id": taskId})if err != nil {diff --git a/examples/devtesting-embedded/README.md b/examples/devtesting-embedded/README.mdindex d387bbaa..60d1f758 100644--- a/examples/devtesting-embedded/README.md+++ b/examples/devtesting-embedded/README.md@@ -1,36 +1,71 @@# devtesting-embedded-Distributed tracing demo with a Go backend and jQuery frontend. Shows two ways to integrate `@tracewayapp/jquery`:+Embedded Traceway backend + OTel-instrumented Go service + jQuery frontend, for local development and feature testing.-## Quick Start (CDN page only)+## Quick Start```bashgo run .```-Open http://localhost:8080/cdn — works immediately, no build step. jQuery and Traceway are loaded from CDN.+Then:+- App: http://localhost:8080/cdn (no build step) or http://localhost:8080 (requires `cd frontend && npm install && npm run build` first)+- Dashboard: http://localhost:8082 — login `[email protected]` / `admin`-## Full Setup (both pages)+## What runs++- **Traceway backend**, embedded on port 8082, SQLite storage in `./storage/`.+- **Go app** on port 8080, instrumented with OpenTelemetry:+ - Traces via OTLP/HTTP → `http://localhost:8082/api/otel/v1/traces`+ - **Logs via OTLP/HTTP** → `http://localhost:8082/api/otel/v1/logs`+ - Two OTel providers in the same process to exercise the distributed-logs flow: `backend-service` and `worker-service`, both reporting to the `Backend API` project.+- **jQuery frontend** pages (`/` and `/cdn`) — unchanged; useful for exercising the jQuery SDK independently.++## Testing the logs feature++Five endpoints exercise different parts of the logs feature end-to-end:++| Endpoint | What it exercises |+|---|---|+| `GET /api/test-error` | Error log + exception recording on the root span |+| `GET /api/test-success` | DEBUG + INFO logs on a simple successful request |+| `GET /api/test-log-levels` | One log at each severity (TRACE/DEBUG/INFO/WARN/ERROR/FATAL) — validates `SeverityBadge` rendering |+| `GET /api/test-spans-with-logs` | Nested child spans (`auth.verify` → `db.query` → `cache.lookup`) with logs emitted inside each. Exercises `parent_span_id` capture and span-chip linking on the trace detail page |+| `GET /api/test-distributed-logs` | Two services (`backend-service` + `worker-service`) emit logs under a shared `traceway.distributed_trace_id`. Powers the "Load logs from other traces" button on the trace detail page |++Trigger them all at once:```bash-cd frontend && npm install && npm run build && cd ..-go run .+for path in test-error test-success test-log-levels test-spans-with-logs test-distributed-logs; do+ curl -s "http://localhost:8080/api/$path" > /dev/null+done```-## Pages+Then in the dashboard (logged in, **Backend API** project selected):++1. **Logs list** — open `/logs`. You should see six severity badges and every request's logs listed with a Message, Service (`backend-service` or `worker-service`), and trace ID. The severity dropdown and search (by Message / Service / Trace ID) should all work.+2. **Trace detail + chip linking** — open `/endpoints`, click one of the test endpoints, click a row. Under the Spans card you should see a **Logs** card listing that request's logs, each chipped with the span that emitted it. For `/api/test-spans-with-logs` specifically, verify logs emitted inside `db.query` chip as `db.query`, logs from `cache.lookup` chip as `cache.lookup`, and logs from handler code (between the child-span blocks) chip as the endpoint name.+3. **Distributed logs button** — on a trace from `/api/test-distributed-logs`, the Logs card shows a `Load logs from other traces` button. Clicking it loads logs from the `worker-service` trace under a divider.+4. **`parent_span_id`** — verify in SQLite:+ ```bash+ sqlite3 storage/traceway_telemetry.db "SELECT substr(id,1,8), name, substr(parent_span_id,1,8) FROM spans ORDER BY start_time DESC LIMIT 10;"+ ```+ Non-root spans should show a non-null `parent_span_id` matching their parent span's `id`.++## Starting from a clean slate++To re-run migrations from empty (useful after any of these migrations ship: `0045_create_log_records`, `0046_add_parent_span_id_to_spans`, `0047_add_span_id_to_endpoints`, `0048_add_span_id_to_tasks`, or their SQLite counterparts `0003_create_log_records`, `0004_add_parent_span_id_to_spans`, `0005_add_span_id_to_root_traces`):++```bash+rm -f storage/traceway.db* storage/traceway_telemetry.db*+```++The backend will re-create the schema on next start.++## Pages (legacy jQuery setup — unchanged)| URL | Description | Build required? ||-----|-------------|-----------------|| http://localhost:8080 | Node-built version — `@tracewayapp/jquery` bundled via Vite into `static/app.js` | Yes (`npm install && npm run build` in `frontend/`) |-| http://localhost:8080/cdn | CDN version — loads `@tracewayapp/[email protected]` IIFE bundle from jsdelivr | No |+| http://localhost:8080/cdn | CDN version — loads `@tracewayapp/jquery` IIFE from jsdelivr | No || http://localhost:8082 | Traceway dashboard | No |--Both pages have the same functionality: error button, success button, and a log showing trace IDs. Login to the dashboard with `[email protected]` / `admin`.--## How it works--1. Go serves both HTML pages and the API endpoints on port 8080-2. Traceway backend runs on port 8082 with SQLite storage-3. Click "Call Backend Error Endpoint" to trigger a 500 error-4. The `traceway-trace-id` header links the jQuery frontend exception to the Go backend error-5. Both appear in the Traceway dashboard under their respective projects, connected by the distributed tracediff --git a/examples/devtesting-embedded/devtesting-embedded b/examples/devtesting-embedded/devtesting-embeddednew file mode 100755index 00000000..eb7d7314Binary files /dev/null and b/examples/devtesting-embedded/devtesting-embedded differdiff --git a/examples/devtesting-embedded/go.mod b/examples/devtesting-embedded/go.modindex 1bfe44e9..bb8e841e 100644--- a/examples/devtesting-embedded/go.mod+++ b/examples/devtesting-embedded/go.mod@@ -3,10 +3,17 @@ module examples/devtesting-embeddedgo 1.25.1require (- github.com/gin-gonic/gin v1.11.0+ github.com/gin-gonic/gin v1.12.0+ github.com/google/uuid v1.6.0github.com/tracewayapp/traceway/backend v1.5.2- go.tracewayapp.com v1.0.2- go.tracewayapp.com/tracewaygin v1.0.2+ go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.68.0+ go.opentelemetry.io/otel v1.43.0+ go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.19.0+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0+ go.opentelemetry.io/otel/log v0.19.0+ go.opentelemetry.io/otel/sdk v1.43.0+ go.opentelemetry.io/otel/sdk/log v0.19.0+ go.opentelemetry.io/otel/trace v1.43.0)require (@@ -32,25 +39,28 @@ require (github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.13 // indirectgithub.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirectgithub.com/aws/smithy-go v1.24.0 // indirect- github.com/bytedance/sonic v1.14.0 // indirect- github.com/bytedance/sonic/loader v0.3.0 // indirect+ github.com/bytedance/gopkg v0.1.4 // indirect+ github.com/bytedance/sonic v1.15.0 // indirect+ github.com/bytedance/sonic/loader v0.5.1 // indirect+ github.com/cenkalti/backoff/v5 v5.0.3 // indirectgithub.com/cespare/xxhash/v2 v2.3.0 // indirectgithub.com/cloudwego/base64x v0.1.6 // indirectgithub.com/coreos/go-systemd/v22 v22.6.0 // indirect- github.com/gabriel-vasile/mimetype v1.4.8 // indirect- github.com/gin-contrib/sse v1.1.0 // indirect+ github.com/gabriel-vasile/mimetype v1.4.13 // indirect+ github.com/gin-contrib/sse v1.1.1 // indirectgithub.com/go-faster/city v1.0.1 // indirectgithub.com/go-faster/errors v0.7.1 // indirect+ github.com/go-logr/logr v1.4.3 // indirect+ github.com/go-logr/stdr v1.2.2 // indirectgithub.com/go-playground/locales v0.14.1 // indirectgithub.com/go-playground/universal-translator v0.18.1 // indirect- github.com/go-playground/validator/v10 v10.27.0 // indirect+ github.com/go-playground/validator/v10 v10.30.2 // indirectgithub.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect- github.com/goccy/go-json v0.10.2 // indirect- github.com/goccy/go-yaml v1.18.0 // indirect+ github.com/goccy/go-json v0.10.6 // indirect+ github.com/goccy/go-yaml v1.19.2 // indirectgithub.com/golang-jwt/jwt/v5 v5.3.0 // indirectgithub.com/golang-migrate/migrate/v4 v4.19.1 // indirect- github.com/google/uuid v1.6.0 // indirect- github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirectgithub.com/joho/godotenv v1.5.1 // indirectgithub.com/json-iterator/go v1.1.12 // indirectgithub.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect@@ -59,36 +69,39 @@ require (github.com/leodido/go-urn v1.4.0 // indirectgithub.com/lib/pq v1.10.9 // indirectgithub.com/mattn/go-isatty v0.0.20 // indirect- github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectgithub.com/modern-go/reflect2 v1.0.2 // indirectgithub.com/paulmach/orb v0.12.0 // indirect- github.com/pelletier/go-toml/v2 v2.2.4 // indirect+ github.com/pelletier/go-toml/v2 v2.3.0 // indirectgithub.com/pierrec/lz4/v4 v4.1.22 // indirect- github.com/quic-go/qpack v0.5.1 // indirect- github.com/quic-go/quic-go v0.54.0 // indirect+ github.com/quic-go/qpack v0.6.0 // indirect+ github.com/quic-go/quic-go v0.59.0 // indirectgithub.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirectgithub.com/segmentio/asm v1.2.1 // indirectgithub.com/shopspring/decimal v1.4.0 // indirectgithub.com/tracewayapp/lit/v2 v2.0.2 // indirectgithub.com/twitchyliquid64/golang-asm v0.15.1 // indirect- github.com/ugorji/go/codec v1.3.0 // indirect- go.opentelemetry.io/otel v1.39.0 // indirect- go.opentelemetry.io/otel/trace v1.39.0 // indirect- go.opentelemetry.io/proto/otlp v1.9.0 // indirect- go.uber.org/mock v0.5.0 // indirect+ github.com/ugorji/go/codec v1.3.1 // indirect+ go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect+ go.opentelemetry.io/auto/sdk v1.2.1 // indirect+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect+ go.opentelemetry.io/otel/metric v1.43.0 // indirect+ go.opentelemetry.io/proto/otlp v1.10.0 // indirect+ go.tracewayapp.com v1.0.2 // indirect+ go.tracewayapp.com/tracewaygin v1.0.2 // indirectgo.yaml.in/yaml/v3 v3.0.4 // indirect- golang.org/x/arch v0.20.0 // indirect- golang.org/x/crypto v0.46.0 // indirect- golang.org/x/mod v0.30.0 // indirect- golang.org/x/net v0.48.0 // indirect- golang.org/x/sync v0.19.0 // indirect- golang.org/x/sys v0.39.0 // indirect- golang.org/x/text v0.32.0 // indirect- golang.org/x/tools v0.39.0 // indirect- google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect- google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect- google.golang.org/grpc v1.75.1 // indirect- google.golang.org/protobuf v1.36.10 // indirect+ golang.org/x/arch v0.25.0 // indirect+ golang.org/x/crypto v0.49.0 // indirect+ golang.org/x/mod v0.33.0 // indirect+ golang.org/x/net v0.52.0 // indirect+ golang.org/x/sync v0.20.0 // indirect+ golang.org/x/sys v0.42.0 // indirect+ golang.org/x/text v0.35.0 // indirect+ golang.org/x/tools v0.42.0 // indirect+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect+ google.golang.org/grpc v1.80.0 // indirect+ google.golang.org/protobuf v1.36.11 // indirectlukechampine.com/uint128 v1.2.0 // indirectmodernc.org/cc/v3 v3.36.3 // indirectmodernc.org/ccgo/v3 v3.16.9 // indirectdiff --git a/examples/devtesting-embedded/go.sum b/examples/devtesting-embedded/go.sumindex ebf18c8c..bf74ab88 100644--- a/examples/devtesting-embedded/go.sum+++ b/examples/devtesting-embedded/go.sum@@ -50,10 +50,14 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 h1:5fFjR/ToSOzB2OQ/XqWpZBmNvmP/github.com/aws/aws-sdk-go-v2/service/sts v1.41.6/go.mod h1:qgFDZQSD/Kys7nJnVqYlWKnh0SSdMjAi0uSwON4wgYQ=github.com/aws/smithy-go v1.24.0 h1:LpilSUItNPFr1eY85RYgTIg5eIEPtvFbskaFcmmIUnk=github.com/aws/smithy-go v1.24.0/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0=-github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=-github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=-github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=-github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=+github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=+github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=+github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=+github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=+github.com/bytedance/sonic/loader v0.5.1 h1:Ygpfa9zwRCCKSlrp5bBP/b/Xzc3VxsAW+5NIYXrOOpI=+github.com/bytedance/sonic/loader v0.5.1/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=+github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=+github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg=@@ -85,16 +89,17 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpgithub.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=-github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=-github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=-github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=-github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=-github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=-github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=+github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=+github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=+github.com/gin-contrib/sse v1.1.1 h1:uGYpNwTacv5R68bSGMapo62iLTRa9l5zxGCps4hK6ko=+github.com/gin-contrib/sse v1.1.1/go.mod h1:QXzuVkA0YO7o/gun03UI1Q+FTI8ZV/n5t03kIQAI89s=+github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=+github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=+github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=@@ -105,14 +110,14 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/ogithub.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=-github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=-github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=+github.com/go-playground/validator/v10 v10.30.2 h1:JiFIMtSSHb2/XBUbWM4i/MpeQm9ZK2xqPNk8vgvu5JQ=+github.com/go-playground/validator/v10 v10.30.2/go.mod h1:mAf2pIOVXjTEBrwUMGKkCWKKPs9NheYGabeB04txQSc=github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=-github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=-github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=-github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=-github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=+github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=+github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=+github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=+github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=@@ -131,8 +136,8 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=-github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=-github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=+github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=+github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=@@ -167,8 +172,9 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Ngithub.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=@@ -181,8 +187,8 @@ github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrgithub.com/paulmach/orb v0.12.0 h1:z+zOwjmG3MyEEqzv92UN49Lg1JFYx0L9GpGKNVDKk1s=github.com/paulmach/orb v0.12.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=-github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=-github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=+github.com/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf421CaM=+github.com/pelletier/go-toml/v2 v2.3.0/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=@@ -190,10 +196,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEgithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=-github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=-github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=-github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=-github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=+github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=+github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=+github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=+github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=@@ -205,11 +211,13 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+Dgithub.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=-github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=+github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=@@ -217,8 +225,8 @@ github.com/tracewayapp/lit/v2 v2.0.2 h1:ZE8UlRWUOX3OZvY2UfbYSDcDUpBoTNLXl70Qujs0github.com/tracewayapp/lit/v2 v2.0.2/go.mod h1:i3zPBL5NtFgZxpxT9PvC2w4gm3S9IzDv4K5JSALtlfs=github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=-github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=-github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=+github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=+github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=@@ -228,51 +236,73 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Julgithub.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=+go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=+go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=+go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.68.0 h1:5FXSL2s6afUC1bzNzl1iedZZ8yqR7GOhbCoEXtyeK6Q=+go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.68.0/go.mod h1:MdHW7tLtkeGJnR4TyOrnd5D0zUGZQB1l84uHCe8hRpE=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=-go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=-go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=-go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=-go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=-go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=-go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=-go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=-go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=-go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=-go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=-go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=-go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=-go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=-go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=+go.opentelemetry.io/contrib/propagators/b3 v1.43.0 h1:CETqV3QLLPTy5yNrqyMr41VnAOOD4lsRved7n4QG00A=+go.opentelemetry.io/contrib/propagators/b3 v1.43.0/go.mod h1:Q4mCiCdziYzpNR0g+6UqVotAlCDZdzz6L8jwY4knOrw=+go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=+go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.19.0 h1:HIBTQ3VO5aupLKjC90JgMqpezVXwFuq6Ryjn0/izoag=+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.19.0/go.mod h1:ji9vId85hMxqfvICA0Jt8JqEdrXaAkcpkI9HPXya0ro=+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0/go.mod h1:Vl1/iaggsuRlrHf/hfPJPvVag77kKyvrLeD10kpMl+A=+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc=+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak=+go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.43.0 h1:mS47AX77OtFfKG4vtp+84kuGSFZHTyxtXIN269vChY0=+go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.43.0/go.mod h1:PJnsC41lAGncJlPUniSwM81gc80GkgWJWr3cu2nKEtU=+go.opentelemetry.io/otel/log v0.19.0 h1:KUZs/GOsw79TBBMfDWsXS+KZ4g2Ckzksd1ymzsIEbo4=+go.opentelemetry.io/otel/log v0.19.0/go.mod h1:5DQYeGmxVIr4n0/BcJvF4upsraHjg6vudJJpnkL6Ipk=+go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=+go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=+go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=+go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=+go.opentelemetry.io/otel/sdk/log v0.19.0 h1:scYVLqT22D2gqXItnWiocLUKGH9yvkkeql5dBDiXyko=+go.opentelemetry.io/otel/sdk/log v0.19.0/go.mod h1:vFBowwXGLlW9AvpuF7bMgnNI95LiW10szrOdvzBHlAg=+go.opentelemetry.io/otel/sdk/log/logtest v0.19.0 h1:BEbF7ZBB6qQloV/Ub1+3NQoOUnVtcGkU3XX4Ws3GQfk=+go.opentelemetry.io/otel/sdk/log/logtest v0.19.0/go.mod h1:Lua81/3yM0wOmoHTokLj9y9ADeA02v1naRrVrkAZuKk=+go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=+go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=+go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=+go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=+go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=+go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=+go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=+go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=-golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=-golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=+golang.org/x/arch v0.25.0 h1:qnk6Ksugpi5Bz32947rkUgDt9/s5qvqDPl/gBKdMJLE=+golang.org/x/arch v0.25.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=-golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=-golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=+golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=+golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=-golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=-golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=+golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=+golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=-golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=-golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=+golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=+golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=-golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=-golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=+golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=+golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=@@ -283,38 +313,38 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBcgolang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=-golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=-golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=+golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=+golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=-golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=-golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=+golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=+golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=-golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=-golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=+golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=+golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=-gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=-gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=-google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY=-google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE=-google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE=-google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc=-google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=-google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=+gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=+gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=+google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=+google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=-google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=-google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=+google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=+google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=diff --git a/examples/devtesting-embedded/main.go b/examples/devtesting-embedded/main.goindex a56ae0ec..a5e5aff9 100644--- a/examples/devtesting-embedded/main.go+++ b/examples/devtesting-embedded/main.go@@ -1,6 +1,7 @@package mainimport (+ "context""embed""errors""fmt"@@ -10,8 +11,20 @@ import ("time""github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"+ "go.opentelemetry.io/otel/attribute"+ "go.opentelemetry.io/otel/codes"+ "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"+ "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"+ otellog "go.opentelemetry.io/otel/log"+ sdklog "go.opentelemetry.io/otel/sdk/log"+ "go.opentelemetry.io/otel/sdk/resource"+ sdktrace "go.opentelemetry.io/otel/sdk/trace"+ semconv "go.opentelemetry.io/otel/semconv/v1.26.0"+ "go.opentelemetry.io/otel/trace"+tracewaybackend "github.com/tracewayapp/traceway/backend"- traceway "go.tracewayapp.com")//go:embed index.html@@ -28,8 +41,93 @@ const (backendToken = "backend-dev-token"frontendToken = "frontend-dev-token"monitoringToken = "monitoring-dev-token"++ backendServiceName = "backend-service"+ workerServiceName = "worker-service"++ otlpHost = "localhost:8082")+// otelService bundles a TracerProvider + LoggerProvider for a single logical service+// so we can run two services in-process to exercise the distributed-logs flow.+type otelService struct {+ name string+ tp *sdktrace.TracerProvider+ lp *sdklog.LoggerProvider+ tr trace.Tracer+ lg otellog.Logger+}++func (s *otelService) shutdown(ctx context.Context) {+ _ = s.tp.Shutdown(ctx)+ _ = s.lp.Shutdown(ctx)+}++func initOtelService(ctx context.Context, serviceName, token string) (*otelService, error) {+ headers := map[string]string{"Authorization": "Bearer " + token}++ traceExporter, err := otlptracehttp.New(ctx,+ otlptracehttp.WithEndpoint(otlpHost),+ otlptracehttp.WithInsecure(),+ otlptracehttp.WithURLPath("/api/otel/v1/traces"),+ otlptracehttp.WithHeaders(headers),+ )+ if err != nil {+ return nil, fmt.Errorf("%s trace exporter: %w", serviceName, err)+ }++ logExporter, err := otlploghttp.New(ctx,+ otlploghttp.WithEndpoint(otlpHost),+ otlploghttp.WithInsecure(),+ otlploghttp.WithURLPath("/api/otel/v1/logs"),+ otlploghttp.WithHeaders(headers),+ )+ if err != nil {+ return nil, fmt.Errorf("%s log exporter: %w", serviceName, err)+ }++ res, err := resource.New(ctx,+ resource.WithAttributes(semconv.ServiceName(serviceName)),+ )+ if err != nil {+ return nil, fmt.Errorf("%s resource: %w", serviceName, err)+ }++ tp := sdktrace.NewTracerProvider(+ sdktrace.WithBatcher(traceExporter, sdktrace.WithBatchTimeout(2*time.Second)),+ sdktrace.WithResource(res),+ )++ lp := sdklog.NewLoggerProvider(+ sdklog.WithProcessor(sdklog.NewBatchProcessor(logExporter, sdklog.WithExportInterval(2*time.Second))),+ sdklog.WithResource(res),+ )++ return &otelService{+ name: serviceName,+ tp: tp,+ lp: lp,+ tr: tp.Tracer(serviceName),+ lg: lp.Logger(serviceName),+ }, nil+}++// log emits an OTel log record. The SDK auto-attaches trace_id / span_id from ctx+// so logs emitted inside a span get chip-linked on the trace detail page.+func (s *otelService) log(ctx context.Context, sev otellog.Severity, sevText, body string, attrs ...otellog.KeyValue) {+ rec := otellog.Record{}+ now := time.Now()+ rec.SetTimestamp(now)+ rec.SetObservedTimestamp(now)+ rec.SetSeverity(sev)+ rec.SetSeverityText(sevText)+ rec.SetBody(otellog.StringValue(body))+ if len(attrs) > 0 {+ rec.AddAttributes(attrs...)+ }+ s.lg.Emit(ctx, rec)+}+func main() {go tracewaybackend.Run(tracewaybackend.WithSQLitePath("./storage/traceway.db"),@@ -41,6 +139,27 @@ func main() {tracewaybackend.WithMonitoringURL(monitoringToken+"@http://localhost:8082/api/report"),)+ // Give the backend a moment to start listening and register project tokens+ // before we start sending OTel data at it.+ time.Sleep(2 * time.Second)++ ctx := context.Background()++ backendSvc, err := initOtelService(ctx, backendServiceName, backendToken)+ if err != nil {+ panic(err)+ }+ defer backendSvc.shutdown(ctx)++ // Second OTel provider with a different service.name. Reports to the same+ // Backend API project so both sides of the "distributed trace" are visible+ // in one project. Used by /api/test-distributed-logs.+ workerSvc, err := initOtelService(ctx, workerServiceName, backendToken)+ if err != nil {+ panic(err)+ }+ defer workerSvc.shutdown(ctx)+router := gin.Default()router.Use(func(c *gin.Context) {@@ -58,10 +177,9 @@ func main() {c.Next()})- // router.Use(tracewaygin.New(- // backendToken+"@http://localhost:8082/api/report",- // tracewaygin.WithOnErrorRecording(tracewaygin.RecordingQuery|tracewaygin.RecordingBody|tracewaygin.RecordingHeader|tracewaygin.RecordingUrl),- // ))+ // otelgin creates a SERVER span per request and puts it in c.Request.Context(),+ // which is what the OTel logger reads to attach trace_id + span_id to each log.+ router.Use(otelgin.Middleware(backendServiceName, otelgin.WithTracerProvider(backendSvc.tp)))router.GET("/", func(c *gin.Context) {c.Data(http.StatusOK, "text/html; charset=utf-8", indexHTML)@@ -74,24 +192,122 @@ func main() {staticSub, _ := fs.Sub(staticFS, "static")router.StaticFS("/static", http.FS(staticSub))+ // Emits an error log + records an exception on the root span.router.GET("/api/test-error", func(c *gin.Context) {+ ctx := c.Request.Context()+ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "received test-error request")time.Sleep(time.Duration(20+rand.IntN(80)) * time.Millisecond)err := errors.New("simulated backend error for distributed trace testing")- traceway.CaptureExceptionWithContext(c.Request.Context(), err)+ backendSvc.log(ctx, otellog.SeverityError, "ERROR", "handler failed: "+err.Error())+ span := trace.SpanFromContext(ctx)+ span.RecordError(err, trace.WithStackTrace(true))+ span.SetStatus(codes.Error, err.Error())c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})})+ // Emits a DEBUG + INFO log on a successful request.router.GET("/api/test-success", func(c *gin.Context) {+ ctx := c.Request.Context()+ backendSvc.log(ctx, otellog.SeverityDebug, "DEBUG", "test-success entered")time.Sleep(time.Duration(20+rand.IntN(80)) * time.Millisecond)+ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "test-success completed")c.JSON(http.StatusOK, gin.H{"message": "success"})})+ // Emits one log at each severity level — useful for inspecting the /logs page+ // and confirming the SeverityBadge renders every variant.+ router.GET("/api/test-log-levels", func(c *gin.Context) {+ ctx := c.Request.Context()+ backendSvc.log(ctx, otellog.SeverityTrace1, "TRACE", "trace-level log for visual testing")+ backendSvc.log(ctx, otellog.SeverityDebug, "DEBUG", "debug: cache miss, falling back to db")+ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "info: request accepted")+ backendSvc.log(ctx, otellog.SeverityWarn, "WARN", "warn: connection pool at 80% capacity")+ backendSvc.log(ctx, otellog.SeverityError, "ERROR", "error: downstream returned non-2xx")+ backendSvc.log(ctx, otellog.SeverityFatal, "FATAL", "fatal: synthetic fatal for UI testing, nothing is actually broken")+ c.JSON(http.StatusOK, gin.H{"emitted": 6})+ })++ // Nested child spans + logs from each level. On the endpoint detail page:+ // - root-span logs chip as the endpoint name+ // - child-span logs chip as that child span's name (db.query / cache.lookup / auth.verify)+ // Also populates parent_span_id on each non-root span.+ router.GET("/api/test-spans-with-logs", func(c *gin.Context) {+ ctx := c.Request.Context()+ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "handler: entering /test-spans-with-logs")++ authCtx, authSpan := backendSvc.tr.Start(ctx, "auth.verify")+ backendSvc.log(authCtx, otellog.SeverityInfo, "INFO", "auth: token verified")+ time.Sleep(5 * time.Millisecond)+ authSpan.End()++ dbCtx, dbSpan := backendSvc.tr.Start(ctx, "db.query")+ backendSvc.log(dbCtx, otellog.SeverityDebug, "DEBUG", "db: executing SELECT * FROM users WHERE id = ?")+ time.Sleep(20 * time.Millisecond)++ cacheCtx, cacheSpan := backendSvc.tr.Start(dbCtx, "cache.lookup")+ backendSvc.log(cacheCtx, otellog.SeverityInfo, "INFO", "cache: key user:42 -> hit")+ time.Sleep(2 * time.Millisecond)+ cacheSpan.End()++ backendSvc.log(dbCtx, otellog.SeverityWarn, "WARN", "db: query took longer than expected",+ otellog.String("threshold_ms", "20"))+ dbSpan.End()++ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "handler: returning 200")+ c.JSON(http.StatusOK, gin.H{"status": "ok"})+ })++ // Distributed logs: emits logs from two different services (backend-service+ // and worker-service) with a shared traceway.distributed_trace_id so the+ // "Load logs from other traces" button on the trace detail page has+ // something to pull in.+ router.GET("/api/test-distributed-logs", func(c *gin.Context) {+ ctx := c.Request.Context()+ dtid := uuid.New().String()++ rootSpan := trace.SpanFromContext(ctx)+ rootSpan.SetAttributes(attribute.String("traceway.distributed_trace_id", dtid))++ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "backend: received request, about to call worker",+ otellog.String("distributed_trace_id", dtid))++ // Fresh root context (no parent) so the worker registers as a separate+ // trace in Traceway. WithSpanKind(Consumer) makes the converter treat+ // this as a task rather than another endpoint.+ workerCtx, workerSpan := workerSvc.tr.Start(context.Background(), "worker.process-job",+ trace.WithSpanKind(trace.SpanKindConsumer))+ workerSpan.SetAttributes(attribute.String("traceway.distributed_trace_id", dtid))++ workerSvc.log(workerCtx, otellog.SeverityInfo, "INFO", "worker: starting job",+ otellog.String("distributed_trace_id", dtid))+ time.Sleep(15 * time.Millisecond)+ workerSvc.log(workerCtx, otellog.SeverityDebug, "DEBUG", "worker: step 1 complete")+ time.Sleep(15 * time.Millisecond)+ workerSvc.log(workerCtx, otellog.SeverityWarn, "WARN", "worker: retryable downstream error, will retry once")+ time.Sleep(10 * time.Millisecond)+ workerSvc.log(workerCtx, otellog.SeverityInfo, "INFO", "worker: job complete")+ workerSpan.End()++ backendSvc.log(ctx, otellog.SeverityInfo, "INFO", "backend: worker reported success, returning 200")+ c.JSON(http.StatusOK, gin.H{+ "status": "ok",+ "distributedTraceId": dtid,+ })+ })+fmt.Println()fmt.Println("=================================================")- fmt.Printf(" Node build: http://localhost:%d\n", appPort)- fmt.Printf(" CDN (no build): http://localhost:%d/cdn\n", appPort)- fmt.Println(" Dashboard: http://localhost:8082")- fmt.Println(" Login: [email protected] / admin")+ fmt.Printf(" Node build: http://localhost:%d\n", appPort)+ fmt.Printf(" CDN (no build): http://localhost:%d/cdn\n", appPort)+ fmt.Println(" Dashboard: http://localhost:8082")+ fmt.Println(" Login: [email protected] / admin")+ fmt.Println()+ fmt.Println(" OTel logs test endpoints (hit with curl or browser):")+ fmt.Printf(" curl http://localhost:%d/api/test-error\n", appPort)+ fmt.Printf(" curl http://localhost:%d/api/test-success\n", appPort)+ fmt.Printf(" curl http://localhost:%d/api/test-log-levels\n", appPort)+ fmt.Printf(" curl http://localhost:%d/api/test-spans-with-logs\n", appPort)+ fmt.Printf(" curl http://localhost:%d/api/test-distributed-logs\n", appPort)fmt.Println("=================================================")fmt.Println()diff --git a/frontend/src/lib/components/app-sidebar.svelte b/frontend/src/lib/components/app-sidebar.svelteindex e394e560..cb959501 100644--- a/frontend/src/lib/components/app-sidebar.svelte+++ b/frontend/src/lib/components/app-sidebar.svelte@@ -8,6 +8,7 @@Link2,ChartNoAxesCombined,ChartNoAxesGantt,+ FileText,Gauge,ListEnd,Settings,@@ -34,6 +35,7 @@const allSidebarItems: SidebarItem[] = [{ Icon: LayoutDashboard, href: '/', title: 'Dashboard', stickyParams: [] },{ Icon: Bug, href: '/issues', title: 'Issues', stickyParams: ['preset', 'from', 'to'] },+ { Icon: FileText, href: '/logs', title: 'Logs', stickyParams: ['preset', 'from', 'to'] },{ Icon: Gauge, href: '/endpoints', title: 'Endpoints', stickyParams: ['preset', 'from', 'to'] },{ Icon: ListEnd, href: '/tasks', title: 'Tasks', stickyParams: ['preset', 'from', 'to'] },{ Icon: Workflow, href: '/ai-traces', title: 'AI Traces', stickyParams: ['preset', 'from', 'to'] },diff --git a/frontend/src/lib/components/trace-logs/expanded-log-row.svelte b/frontend/src/lib/components/trace-logs/expanded-log-row.sveltenew file mode 100644index 00000000..9ef767cc--- /dev/null+++ b/frontend/src/lib/components/trace-logs/expanded-log-row.svelte@@ -0,0 +1,75 @@+<script lang="ts" module>+ export type ExpandedLogRecord = {+ body: string;+ traceId?: string;+ spanId?: string;+ scopeName?: string;+ scopeVersion?: string;+ resourceAttributes?: Record<string, string> | null;+ scopeAttributes?: Record<string, string> | null;+ logAttributes?: Record<string, string> | null;+ };+</script>++<script lang="ts">+ import * as Table from '$lib/components/ui/table';+ import { AttributesGrid, AttributesView } from '$lib/components/ui/attributes-grid';++ let {+ log,+ colspan+ }: {+ log: ExpandedLogRecord;+ colspan: number;+ } = $props();++ function mergedAttributes(): Record<string, string> {+ const out: Record<string, string> = {};+ const push = (m: Record<string, string> | null | undefined, prefix: string) => {+ if (!m) return;+ for (const [k, v] of Object.entries(m)) {+ out[`${prefix}${k}`] = v;+ }+ };+ push(log.resourceAttributes, 'resource.');+ push(log.scopeAttributes, 'scope.');+ push(log.logAttributes, '');+ return out;+ }++ function hasAttributes(): boolean {+ for (const _ in mergedAttributes()) return true;+ return false;+ }+</script>++<!--+ The container <tr>/<td> carry a fixed muted background with `!` so Table.Row's+ built-in hover:[&>td]:bg-muted/50 can't repaint the cell on mouseover.+-->+<Table.Row class="!bg-muted/30">+ <Table.Cell {colspan} class="!bg-muted/30 px-4 py-3">+ <div class="space-y-3">+ <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3">+ <div class="sm:col-span-2 md:col-span-3">+ <AttributesView title="Body" value={log.body} />+ </div>+ {#if log.traceId}+ <AttributesView title="Trace ID" value={log.traceId} />+ {/if}+ {#if log.spanId}+ <AttributesView title="Span ID" value={log.spanId} />+ {/if}+ {#if log.scopeName}+ <AttributesView+ title="Scope"+ value={log.scopeName + (log.scopeVersion ? `@${log.scopeVersion}` : '')}+ />+ {/if}+ </div>+ {#if hasAttributes()}+ <AttributesGrid attributes={mergedAttributes()} collapsedCount={6} />+ {/if}+ </div>+ </Table.Cell>+</Table.Row>diff --git a/frontend/src/lib/components/trace-logs/trace-logs-panel.svelte b/frontend/src/lib/components/trace-logs/trace-logs-panel.sveltenew file mode 100644index 00000000..ce81cbfd--- /dev/null+++ b/frontend/src/lib/components/trace-logs/trace-logs-panel.svelte@@ -0,0 +1,324 @@+<script lang="ts">+ import { onMount } from 'svelte';+ import { api } from '$lib/api';+ import * as Card from '$lib/components/ui/card';+ import * as Table from '$lib/components/ui/table';+ import * as Tabs from '$lib/components/ui/tabs';+ import { LoadingCircle } from '$lib/components/ui/loading-circle';+ import { SeverityBadge } from '$lib/components/ui/severity-badge';+ import ExpandedLogRow from './expanded-log-row.svelte';+ import { formatDateTime } from '$lib/utils/formatters';+ import { getTimezone } from '$lib/state/timezone.svelte';+ import { spanIdUuidToHex } from '$lib/utils/span-id';+ import type { Span } from '$lib/types/spans';++ type LogRecord = {+ id: string;+ projectId: string;+ timestamp: string;+ traceId: string;+ spanId: string;+ severityText: string;+ severityNumber: number;+ serviceName: string;+ body: string;+ resourceAttributes: Record<string, string> | null;+ scopeName: string;+ scopeVersion: string;+ scopeAttributes: Record<string, string> | null;+ logAttributes: Record<string, string> | null;+ };++ let {+ projectId,+ traceId,+ distributedTraceId = null,+ spans,+ rootSpan,+ traceRecordedAt+ }: {+ projectId: string;+ traceId: string;+ distributedTraceId?: string | null;+ spans: Span[];+ rootSpan: { id: string; name: string };+ traceRecordedAt: string;+ } = $props();++ // rootSpan kept on the prop surface for future use; not referenced here now+ // that the root-span chip fallback is gone.+ void rootSpan;++ const timezone = $derived(getTimezone());++ let activeTab = $state<'this-trace' | 'all-distributed'>('this-trace');++ // This-trace data+ let logs = $state<LogRecord[]>([]);+ let loading = $state(true);+ let error = $state('');+ let expandedId = $state<string | null>(null);++ // Distributed data (lazy)+ let distributedLogs = $state<LogRecord[]>([]);+ let distributedLoading = $state(false);+ let distributedLoaded = $state(false);+ let distributedError = $state('');++ const childSpanNameByHex = $derived.by(() => {+ const m = new Map<string, string>();+ for (const s of spans) {+ const hex = spanIdUuidToHex(s.id);+ if (hex) m.set(hex, s.name);+ }+ return m;+ });++ function resolveSpanName(log: LogRecord): string | null {+ if (!log.spanId) return null;+ return childSpanNameByHex.get(log.spanId.toLowerCase()) ?? null;+ }++ function timeWindow(): { fromDate: string; toDate: string } {+ const t = new Date(traceRecordedAt).getTime();+ const hour = 60 * 60 * 1000;+ return {+ fromDate: new Date(t - hour).toISOString(),+ toDate: new Date(t + hour).toISOString()+ };+ }++ async function loadTraceLogs() {+ loading = true;+ error = '';+ try {+ const { fromDate, toDate } = timeWindow();+ const response = (await api.post(+ '/logs',+ {+ fromDate,+ toDate,+ orderBy: 'timestamp',+ sortDirection: 'asc',+ pagination: { page: 1, pageSize: 100 },+ traceId+ },+ { projectId: projectId || undefined }+ )) as { data: LogRecord[] };+ logs = response.data || [];+ } catch (e: unknown) {+ const err = e as { message?: string };+ error = err.message || 'Failed to load logs';+ } finally {+ loading = false;+ }+ }++ async function loadDistributedLogs() {+ if (!distributedTraceId) return;+ distributedLoading = true;+ distributedError = '';+ try {+ const { fromDate, toDate } = timeWindow();+ const response = (await api.post(+ '/logs',+ {+ fromDate,+ toDate,+ orderBy: 'timestamp',+ sortDirection: 'asc',+ pagination: { page: 1, pageSize: 100 },+ distributedTraceId+ },+ { projectId: projectId || undefined }+ )) as { data: LogRecord[] };+ distributedLogs = response.data || [];+ distributedLoaded = true;+ } catch (e: unknown) {+ const err = e as { message?: string };+ distributedError = err.message || 'Failed to load distributed logs';+ } finally {+ distributedLoading = false;+ }+ }++ function onTabChange(value: string) {+ if (value !== 'this-trace' && value !== 'all-distributed') return;+ activeTab = value;+ if (value === 'all-distributed' && !distributedLoaded && !distributedLoading) {+ loadDistributedLogs();+ }+ }++ function toggleExpanded(id: string) {+ expandedId = expandedId === id ? null : id;+ }++ function firstLine(body: string): string {+ if (!body) return '';+ const nl = body.indexOf('\n');+ return nl === -1 ? body : body.slice(0, nl);+ }++ onMount(() => {+ loadTraceLogs();+ });+</script>++<Card.Root class="gap-0 pb-0 overflow-hidden">+ <Card.Header>+ <Card.Title>Logs</Card.Title>+ </Card.Header>+ <Card.Content class="p-0">+ <Tabs.Root value={activeTab} onValueChange={onTabChange}>+ <Tabs.List+ class="h-auto w-full justify-start gap-4 rounded-none border-b bg-transparent p-0 pl-6 pt-0 pb-2"+ >+ <Tabs.Trigger+ value="this-trace"+ class="rounded-none border-b-2 border-transparent bg-transparent px-0 pb-2 pt-0 text-sm font-medium text-muted-foreground shadow-none data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none"+ >+ This Trace+ </Tabs.Trigger>+ {#if distributedTraceId}+ <Tabs.Trigger+ value="all-distributed"+ class="rounded-none border-b-2 border-transparent bg-transparent px-0 pb-2 pt-0 text-sm font-medium text-muted-foreground shadow-none data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none"+ >+ All Distributed Traces+ </Tabs.Trigger>+ {/if}+ </Tabs.List>++ <Tabs.Content value="this-trace" class="mt-0">+ {#if loading}+ <div class="flex items-center justify-center py-6">+ <LoadingCircle size="lg" />+ </div>+ {:else if error}+ <div class="py-6 text-center text-sm text-red-500">{error}</div>+ {:else if logs.length === 0}+ <div class="py-6 text-center text-sm text-muted-foreground">+ No logs for this trace in the surrounding time window+ </div>+ {:else}+ <Table.Root>+ <Table.Header>+ <Table.Row>+ <Table.Head class="h-8 w-[180px] py-1.5 pl-6">Timestamp</Table.Head>+ <Table.Head class="h-8 w-[80px] py-1.5">Level</Table.Head>+ <Table.Head class="h-8 py-1.5">Message</Table.Head>+ <Table.Head class="h-8 w-[220px] py-1.5 pr-6">Span</Table.Head>+ </Table.Row>+ </Table.Header>+ <Table.Body>+ {#each logs as log (log.id)}+ {@const spanName = resolveSpanName(log)}+ <Table.Row+ class="h-8 cursor-pointer hover:bg-muted/50"+ onclick={() => toggleExpanded(log.id)}+ >+ <Table.Cell class="py-1.5 pl-6 text-xs text-muted-foreground tabular-nums">+ {formatDateTime(log.timestamp, { timezone })}+ </Table.Cell>+ <Table.Cell class="py-1.5">+ <SeverityBadge+ severityText={log.severityText}+ severityNumber={log.severityNumber}+ />+ </Table.Cell>+ <Table.Cell class="max-w-[600px] truncate py-1.5 font-mono text-xs">+ {firstLine(log.body)}+ </Table.Cell>+ <Table.Cell class="py-1.5 pr-6">+ {#if spanName}+ <span+ class="inline-block max-w-[200px] truncate rounded bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground"+ title={spanName}+ >+ {spanName}+ </span>+ {:else}+ <span class="text-xs text-muted-foreground">—</span>+ {/if}+ </Table.Cell>+ </Table.Row>+ {#if expandedId === log.id}+ <ExpandedLogRow {log} colspan={4} />+ {/if}+ {/each}+ </Table.Body>+ </Table.Root>+ {/if}+ </Tabs.Content>++ {#if distributedTraceId}+ <Tabs.Content value="all-distributed" class="mt-0">+ {#if distributedLoading}+ <div class="flex items-center justify-center py-6">+ <LoadingCircle size="lg" />+ </div>+ {:else if distributedError}+ <div class="py-6 text-center text-sm text-red-500">{distributedError}</div>+ {:else if !distributedLoaded}+ <div class="py-6 text-center text-sm text-muted-foreground">+ Loading distributed logs…+ </div>+ {:else if distributedLogs.length === 0}+ <div class="py-6 text-center text-sm text-muted-foreground">+ No logs found in this distributed trace+ </div>+ {:else}+ <Table.Root>+ <Table.Header>+ <Table.Row>+ <Table.Head class="h-8 w-[180px] py-1.5 pl-6">Timestamp</Table.Head>+ <Table.Head class="h-8 w-[80px] py-1.5">Level</Table.Head>+ <Table.Head class="h-8 py-1.5">Message</Table.Head>+ <Table.Head class="h-8 w-[160px] py-1.5">Service</Table.Head>+ <Table.Head class="h-8 w-[130px] py-1.5 pr-6">Trace</Table.Head>+ </Table.Row>+ </Table.Header>+ <Table.Body>+ {#each distributedLogs as log (log.id)}+ <Table.Row+ class="h-8 cursor-pointer hover:bg-muted/50"+ onclick={() => toggleExpanded(log.id)}+ >+ <Table.Cell class="py-1.5 pl-6 text-xs text-muted-foreground tabular-nums">+ {formatDateTime(log.timestamp, { timezone })}+ </Table.Cell>+ <Table.Cell class="py-1.5">+ <SeverityBadge+ severityText={log.severityText}+ severityNumber={log.severityNumber}+ />+ </Table.Cell>+ <Table.Cell class="max-w-[500px] truncate py-1.5 font-mono text-xs">+ {firstLine(log.body)}+ </Table.Cell>+ <Table.Cell class="py-1.5 text-xs text-muted-foreground">+ {log.serviceName || '—'}+ </Table.Cell>+ <Table.Cell class="py-1.5 pr-6 font-mono text-xs">+ {#if log.traceId}+ <span class="text-muted-foreground" title={log.traceId}>+ {log.traceId.slice(0, 8)}…+ </span>+ {:else}+ <span class="text-muted-foreground">—</span>+ {/if}+ </Table.Cell>+ </Table.Row>+ {#if expandedId === log.id}+ <ExpandedLogRow {log} colspan={5} />+ {/if}+ {/each}+ </Table.Body>+ </Table.Root>+ {/if}+ </Tabs.Content>+ {/if}+ </Tabs.Root>+ </Card.Content>+</Card.Root>diff --git a/frontend/src/lib/components/ui/search-bar/search-bar.svelte b/frontend/src/lib/components/ui/search-bar/search-bar.svelteindex 2a88dec5..abb07618 100644--- a/frontend/src/lib/components/ui/search-bar/search-bar.svelte+++ b/frontend/src/lib/components/ui/search-bar/search-bar.svelte@@ -1,4 +1,5 @@<script lang="ts">+ import type { Snippet } from 'svelte';import { Input } from '$lib/components/ui/input';import { Button } from '$lib/components/ui/button';import * as Select from '$lib/components/ui/select';@@ -15,6 +16,14 @@typeOptions?: TypeOption[];onSearch: () => void;disabled?: boolean;+ /**+ * Optional slot rendered between the type select and the Go button.+ * Consumers can drop additional selects in here (e.g. a severity filter)+ * so they visually belong to the same compound control. Your content is+ * responsible for matching the 9-unit height and using rounded-none ++ * border-r-0 to keep the joined look.+ */+ children?: Snippet;};let {@@ -23,7 +32,8 @@typeValue = $bindable(''),typeOptions = [],onSearch,- disabled = false+ disabled = false,+ children}: Props = $props();const typeLabel = $derived(typeOptions.find((o) => o.value === typeValue)?.label ?? '');@@ -54,6 +64,8 @@</Select.Root>{/if}+ {@render children?.()}+<Button variant="outline" class="h-9 rounded-l-none shadow-none" onclick={onSearch} {disabled}>Go</Button>diff --git a/frontend/src/lib/components/ui/severity-badge/index.ts b/frontend/src/lib/components/ui/severity-badge/index.tsnew file mode 100644index 00000000..7fb28a39--- /dev/null+++ b/frontend/src/lib/components/ui/severity-badge/index.ts@@ -0,0 +1 @@+export { default as SeverityBadge, severityFromNumber, type SeverityLevel } from './severity-badge.svelte';diff --git a/frontend/src/lib/components/ui/severity-badge/severity-badge.svelte b/frontend/src/lib/components/ui/severity-badge/severity-badge.sveltenew file mode 100644index 00000000..5161ee49--- /dev/null+++ b/frontend/src/lib/components/ui/severity-badge/severity-badge.svelte@@ -0,0 +1,92 @@+<script lang="ts" module>+ export type SeverityLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL' | '';++ export function severityFromNumber(n: number | undefined | null): SeverityLevel {+ if (!n || n <= 0) return '';+ if (n <= 4) return 'TRACE';+ if (n <= 8) return 'DEBUG';+ if (n <= 12) return 'INFO';+ if (n <= 16) return 'WARN';+ if (n <= 20) return 'ERROR';+ return 'FATAL';+ }++ export function severityFromText(text: string | undefined | null): SeverityLevel {+ const raw = (text ?? '').toUpperCase();+ if (+ raw === 'TRACE' ||+ raw === 'DEBUG' ||+ raw === 'INFO' ||+ raw === 'WARN' ||+ raw === 'ERROR' ||+ raw === 'FATAL'+ ) {+ return raw;+ }+ if (raw === 'WARNING') return 'WARN';+ if (raw === 'CRITICAL') return 'FATAL';+ return '';+ }+</script>++<script lang="ts">+ let {+ severityText,+ severityNumber+ }: {+ severityText?: string;+ severityNumber?: number;+ } = $props();++ const level = $derived<SeverityLevel>(+ severityFromText(severityText) || severityFromNumber(severityNumber)+ );++ const config = $derived(() => {+ switch (level) {+ case 'TRACE':+ return { bg: 'bg-muted', text: 'text-muted-foreground', label: 'TRACE' };+ case 'DEBUG':+ return {+ bg: 'bg-blue-500/15',+ text: 'text-blue-600 dark:text-blue-400',+ label: 'DEBUG'+ };+ case 'INFO':+ return {+ bg: 'bg-slate-500/15',+ text: 'text-slate-600 dark:text-slate-300',+ label: 'INFO'+ };+ case 'WARN':+ return {+ bg: 'bg-yellow-500/15',+ text: 'text-yellow-700 dark:text-yellow-400',+ label: 'WARN'+ };+ case 'ERROR':+ return {+ bg: 'bg-red-500/15',+ text: 'text-red-600 dark:text-red-400',+ label: 'ERROR'+ };+ case 'FATAL':+ return {+ bg: 'bg-red-700/25',+ text: 'text-red-700 dark:text-red-300 font-semibold',+ label: 'FATAL'+ };+ default:+ return null;+ }+ });+</script>++{#if config()}+ <span+ class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium uppercase tracking-wide {config()+ ?.bg} {config()?.text}"+ >+ {config()?.label}+ </span>+{/if}diff --git a/frontend/src/lib/types/spans.ts b/frontend/src/lib/types/spans.tsindex d2b24280..c30142ec 100644--- a/frontend/src/lib/types/spans.ts+++ b/frontend/src/lib/types/spans.ts@@ -21,6 +21,7 @@ export type TraceDetail = {appVersion: string;serverName: string;distributedTraceId?: string;+ spanId?: string;};export type ExceptionInfo = {diff --git a/frontend/src/lib/utils/span-id.ts b/frontend/src/lib/utils/span-id.tsnew file mode 100644index 00000000..3922968f--- /dev/null+++ b/frontend/src/lib/utils/span-id.ts@@ -0,0 +1,9 @@+export function spanIdUuidToHex(spanUuid: string | null | undefined): string {+ if (!spanUuid) return '';+ return spanUuid.replace(/-/g, '').slice(-16).toLowerCase();+}++export function traceIdUuidToHex(traceUuid: string | null | undefined): string {+ if (!traceUuid) return '';+ return traceUuid.replace(/-/g, '').toLowerCase();+}diff --git a/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte b/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelteindex e93f416f..ffaf70e2 100644--- a/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte+++ b/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte@@ -20,6 +20,8 @@import { createSmartBackHandler } from '$lib/utils/back-navigation';import { resolve } from '$app/paths';import DistributedTraceCard from '$lib/components/distributed-trace/distributed-trace-card.svelte';+ import TraceLogsPanel from '$lib/components/trace-logs/trace-logs-panel.svelte';+ import { traceIdUuidToHex } from '$lib/utils/span-id';let { data } = $props();@@ -245,16 +247,14 @@<!-- Spans Section --><Card.Root>- <Card.Header>- <Card.Title>Spans</Card.Title>- <Card.Description>- {#if response.hasSpans}+ {#if response.hasSpans}+ <Card.Header>+ <Card.Title>Spans</Card.Title>+ <Card.Description>Timing breakdown of operations within this endpoint request- {:else}- No spans recorded for this endpoint request- {/if}- </Card.Description>- </Card.Header>+ </Card.Description>+ </Card.Header>+ {/if}<Card.Content>{#if response.hasSpans}<SpanWaterfall@@ -268,6 +268,18 @@</Card.Content></Card.Root>+ <TraceLogsPanel+ projectId={projectsState.currentProjectId ?? ''}+ traceId={traceIdUuidToHex(response.endpoint.id)}+ distributedTraceId={response.endpoint.distributedTraceId ?? null}+ spans={response.spans}+ rootSpan={{+ id: response.endpoint.spanId ?? response.endpoint.id,+ name: response.endpoint.endpoint+ }}+ traceRecordedAt={response.endpoint.recordedAt}+ />+{#if response.endpoint.distributedTraceId}<DistributedTraceCard distributedTraceId={response.endpoint.distributedTraceId} />{/if}diff --git a/frontend/src/routes/logs/+page.svelte b/frontend/src/routes/logs/+page.sveltenew file mode 100644index 00000000..8204031b--- /dev/null+++ b/frontend/src/routes/logs/+page.svelte@@ -0,0 +1,604 @@+<script lang="ts">+ import { onMount, onDestroy } from 'svelte';+ import { browser } from '$app/environment';+ import { goto } from '$app/navigation';+ import { api } from '$lib/api';+ import * as Table from '$lib/components/ui/table';+ import { SearchBar } from '$lib/components/ui/search-bar';+ import { LoadingCircle } from '$lib/components/ui/loading-circle';+ import { projectsState } from '$lib/state/projects.svelte';+ import { getTimezone } from '$lib/state/timezone.svelte';+ import { TracewayTableHeader } from '$lib/components/ui/traceway-table-header';+ import { TableEmptyState } from '$lib/components/ui/table-empty-state';+ import { PaginationFooter } from '$lib/components/ui/pagination-footer';+ import { TimeRangePicker } from '$lib/components/ui/time-range-picker';+ import { SeverityBadge } from '$lib/components/ui/severity-badge';+ import * as Select from '$lib/components/ui/select';+ import { Input } from '$lib/components/ui/input';+ import { Button } from '$lib/components/ui/button';+ import * as AlertDialog from '$lib/components/ui/alert-dialog';+ import ExpandedLogRow from '$lib/components/trace-logs/expanded-log-row.svelte';+ import { Plus, X } from '@lucide/svelte';+ import { CalendarDate } from '@internationalized/date';+ import {+ parseTimeRangeFromUrl,+ getResolvedTimeRange,+ getTimeRangeFromPreset,+ dateToCalendarDate,+ dateToTimeString+ } from '$lib/utils/url-params';+ import { calendarDateTimeToLuxon, toUTCISO, formatDateTime } from '$lib/utils/formatters';+ import {+ getSortState,+ setSortState,+ handleSortClick,+ type SortDirection+ } from '$lib/utils/sort-storage';++ const timezone = $derived(getTimezone());++ const SORT_STORAGE_KEY = 'logs';+ const initialSort = getSortState(SORT_STORAGE_KEY, { field: 'timestamp', direction: 'desc' });+ let sortField = $state(initialSort.field);+ let sortDirection = $state<SortDirection>(initialSort.direction);++ type LogRecord = {+ id: string;+ projectId: string;+ timestamp: string;+ traceId: string;+ spanId: string;+ traceFlags: number;+ severityText: string;+ severityNumber: number;+ serviceName: string;+ body: string;+ resourceSchemaUrl: string;+ resourceAttributes: Record<string, string> | null;+ scopeSchemaUrl: string;+ scopeName: string;+ scopeVersion: string;+ scopeAttributes: Record<string, string> | null;+ logAttributes: Record<string, string> | null;+ };++ let logs = $state<LogRecord[]>([]);+ let loading = $state(true);+ let error = $state('');+ let expandedId = $state<string | null>(null);++ let page = $state(1);+ let pageSize = $state(50);+ let total = $state(0);+ let totalPages = $state(0);++ type AttributeFilter = {+ scope: 'resource' | 'scope' | 'log';+ key: string;+ value: string;+ };++ // Parse `resource.service.name=backend-service` (or scope.*/log.*) into a+ // structured filter. Returns null if the input doesn't match the shape.+ function parseAttributeFilter(input: string): AttributeFilter | null {+ const trimmed = input.trim();+ const m = trimmed.match(/^(resource|scope|log)\.([^=]+)=(.*)$/);+ if (!m) return null;+ const key = m[2].trim();+ if (!key) return null;+ return { scope: m[1] as AttributeFilter['scope'], key, value: m[3] };+ }++ function formatAttributeFilter(f: AttributeFilter): string {+ return `${f.scope}.${f.key}=${f.value}`;+ }++ function parseLogsUrlParams() {+ if (!browser) {+ return {+ preset: '24h',+ from: null,+ to: null,+ search: '',+ searchType: 'body',+ minSeverity: 0,+ serviceName: '',+ traceId: '',+ attributeFilters: [] as AttributeFilter[]+ };+ }+ const params = new URLSearchParams(window.location.search);+ const timeParams = parseTimeRangeFromUrl(timezone, '24h');+ const minSev = Number(params.get('minSeverity') || '0');+ const attrs: AttributeFilter[] = [];+ for (const raw of params.getAll('attr')) {+ const parsed = parseAttributeFilter(raw);+ if (parsed) attrs.push(parsed);+ }+ return {+ ...timeParams,+ search: params.get('search') || '',+ searchType: params.get('searchType') || 'body',+ minSeverity: Number.isFinite(minSev) ? minSev : 0,+ serviceName: params.get('service') || '',+ traceId: params.get('traceId') || '',+ attributeFilters: attrs+ };+ }++ const initialUrlParams = parseLogsUrlParams();+ const initialRange = getResolvedTimeRange(initialUrlParams, timezone);++ let selectedPreset = $state<string | null>(initialUrlParams.preset);+ let fromDate = $state<CalendarDate>(dateToCalendarDate(initialRange.from, timezone));+ let toDate = $state<CalendarDate>(dateToCalendarDate(initialRange.to, timezone));+ let fromTime = $state(dateToTimeString(initialRange.from, timezone));+ let toTime = $state(dateToTimeString(initialRange.to, timezone));++ let searchQuery = $state(initialUrlParams.search);+ let searchType = $state(initialUrlParams.searchType);+ let minSeverity = $state<number>(initialUrlParams.minSeverity);+ let serviceName = $state(initialUrlParams.serviceName);+ let traceIdFilter = $state(initialUrlParams.traceId);+ let attributeFilters = $state<AttributeFilter[]>(initialUrlParams.attributeFilters);++ // Add-filter dialog+ let addFilterOpen = $state(false);+ let dialogKey = $state('');+ let dialogValue = $state('');+ let dialogError = $state('');++ function openAddFilterDialog() {+ dialogKey = '';+ dialogValue = '';+ dialogError = '';+ addFilterOpen = true;+ }++ function submitDialogFilter() {+ const composed = `${dialogKey.trim()}=${dialogValue}`;+ const parsed = parseAttributeFilter(composed);+ if (!parsed) {+ dialogError = 'Key must start with resource., scope., or log.';+ return;+ }+ const dup = attributeFilters.some(+ (f) => f.scope === parsed.scope && f.key === parsed.key && f.value === parsed.value+ );+ if (!dup) {+ attributeFilters = [...attributeFilters, parsed];+ }+ addFilterOpen = false;+ page = 1;+ loadData(true);+ }++ function handleDialogKeydown(e: KeyboardEvent) {+ if (e.key === 'Enter') {+ e.preventDefault();+ submitDialogFilter();+ }+ }++ const searchTypeOptions = [+ { value: 'body', label: 'Message' },+ { value: 'service', label: 'Service' },+ { value: 'trace', label: 'Trace ID' }+ ];++ const severityOptions = [+ { value: '0', label: 'All levels' },+ { value: '1', label: 'TRACE+' },+ { value: '5', label: 'DEBUG+' },+ { value: '9', label: 'INFO+' },+ { value: '13', label: 'WARN+' },+ { value: '17', label: 'ERROR+' },+ { value: '21', label: 'FATAL' }+ ];++ const severityTriggerLabel = $derived(+ severityOptions.find((o) => Number(o.value) === minSeverity)?.label ?? 'All levels'+ );++ function getFromDateTimeUTC(): string {+ const [hour, minute] = fromTime.split(':').map(Number);+ const luxonDt = calendarDateTimeToLuxon(+ { year: fromDate.year, month: fromDate.month, day: fromDate.day, hour, minute },+ timezone+ );+ return toUTCISO(luxonDt);+ }++ function getToDateTimeUTC(): string {+ const [hour, minute] = toTime.split(':').map(Number);+ const luxonDt = calendarDateTimeToLuxon(+ { year: toDate.year, month: toDate.month, day: toDate.day, hour, minute },+ timezone+ ).endOf('minute');+ return toUTCISO(luxonDt);+ }++ function updateLogsUrl(pushToHistory = true) {+ if (!browser) return;+ const urlParams = new URLSearchParams();+ if (selectedPreset) {+ urlParams.set('preset', selectedPreset);+ } else {+ urlParams.set('from', getFromDateTimeUTC());+ urlParams.set('to', getToDateTimeUTC());+ }+ if (searchQuery.trim()) urlParams.set('search', searchQuery.trim());+ if (searchType !== 'body') urlParams.set('searchType', searchType);+ if (minSeverity > 0) urlParams.set('minSeverity', String(minSeverity));+ if (serviceName.trim()) urlParams.set('service', serviceName.trim());+ if (traceIdFilter.trim()) urlParams.set('traceId', traceIdFilter.trim());+ for (const f of attributeFilters) {+ urlParams.append('attr', formatAttributeFilter(f));+ }+ const newUrl = `${window.location.pathname}?${urlParams.toString()}`;+ // eslint-disable-next-line svelte/no-navigation-without-resolve+ goto(newUrl, { replaceState: !pushToHistory, noScroll: true, keepFocus: true });+ }++ function removeAttributeFilter(index: number) {+ attributeFilters = attributeFilters.filter((_, i) => i !== index);+ page = 1;+ loadData(true);+ }++ async function loadData(pushToHistory = true) {+ loading = true;+ error = '';++ if (selectedPreset) {+ const range = getTimeRangeFromPreset(selectedPreset, timezone);+ fromDate = dateToCalendarDate(range.from, timezone);+ toDate = dateToCalendarDate(range.to, timezone);+ fromTime = dateToTimeString(range.from, timezone);+ toTime = dateToTimeString(range.to, timezone);+ }++ updateLogsUrl(pushToHistory);++ try {+ const requestBody = {+ fromDate: getFromDateTimeUTC(),+ toDate: getToDateTimeUTC(),+ orderBy: sortField,+ sortDirection,+ pagination: { page, pageSize },+ search: searchQuery.trim(),+ searchType,+ minSeverity,+ serviceName: serviceName.trim(),+ traceId: traceIdFilter.trim(),+ attributeFilters+ };++ const response = (await api.post('/logs', requestBody, {+ projectId: projectsState.currentProjectId ?? undefined+ })) as { data: LogRecord[]; pagination: { total: number; totalPages: number } };++ logs = response.data || [];+ total = response.pagination.total;+ totalPages = response.pagination.totalPages;+ } catch (e: any) {+ console.error(e);+ error = e.message || 'Failed to load logs';+ } finally {+ loading = false;+ }+ }++ function handlePageChange(newPage: number) {+ if (newPage >= 1 && newPage <= totalPages) {+ page = newPage;+ loadData(true);+ }+ }++ function handlePageSizeChange(newPageSize: number) {+ pageSize = newPageSize;+ page = 1;+ loadData(true);+ }++ function handleTimeRangeChange(+ from: { date: CalendarDate; time: string },+ to: { date: CalendarDate; time: string },+ preset: string | null+ ) {+ fromDate = from.date;+ toDate = to.date;+ fromTime = from.time;+ toTime = to.time;+ selectedPreset = preset;+ page = 1;+ loadData(true);+ }++ function handleSearch() {+ page = 1;+ loadData(true);+ }++ function handleSeverityChange(value: string) {+ // Keep severity as pending query state — applied on the next Go press,+ // same as the search input. Avoids triggering a re-fetch on every+ // dropdown change.+ minSeverity = Number(value) || 0;+ }++ function handleSort(field: string) {+ const newSort = handleSortClick(field, sortField, sortDirection);+ sortField = newSort.field;+ sortDirection = newSort.direction;+ setSortState(SORT_STORAGE_KEY, newSort);+ page = 1;+ loadData(true);+ }++ function handlePopState() {+ const urlParams = parseLogsUrlParams();+ const range = getResolvedTimeRange(urlParams, timezone);+ selectedPreset = urlParams.preset;+ fromDate = dateToCalendarDate(range.from, timezone);+ toDate = dateToCalendarDate(range.to, timezone);+ fromTime = dateToTimeString(range.from, timezone);+ toTime = dateToTimeString(range.to, timezone);+ searchQuery = urlParams.search;+ searchType = urlParams.searchType;+ minSeverity = urlParams.minSeverity;+ serviceName = urlParams.serviceName;+ traceIdFilter = urlParams.traceId;+ attributeFilters = urlParams.attributeFilters;+ page = 1;+ loadData(false);+ }++ function toggleExpanded(id: string) {+ expandedId = expandedId === id ? null : id;+ }++ function firstLine(body: string): string {+ if (!body) return '';+ const nl = body.indexOf('\n');+ return nl === -1 ? body : body.slice(0, nl);+ }++ onMount(() => {+ window.addEventListener('popstate', handlePopState);+ loadData(false);+ });++ onDestroy(() => {+ if (typeof window !== 'undefined') {+ window.removeEventListener('popstate', handlePopState);+ }+ });+</script>++<div class="space-y-4">+ <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">+ <h2 class="text-2xl font-bold tracking-tight">Logs</h2>+ <div class="w-full sm:w-auto">+ <TimeRangePicker+ bind:fromDate+ bind:toDate+ bind:fromTime+ bind:toTime+ bind:preset={selectedPreset}+ onApply={handleTimeRangeChange}+ />+ </div>+ </div>++ <div class="flex flex-col gap-3 sm:flex-row sm:items-start">+ <div class="flex-1">+ <SearchBar+ placeholder="Search logs..."+ bind:value={searchQuery}+ bind:typeValue={searchType}+ typeOptions={searchTypeOptions}+ onSearch={handleSearch}+ disabled={loading}+ >+ <Select.Root+ type="single"+ value={String(minSeverity)}+ onValueChange={handleSeverityChange}+ >+ <Select.Trigger class="h-9 w-[130px] rounded-none border-r-0 shadow-none">+ {severityTriggerLabel}+ </Select.Trigger>+ <Select.Content>+ {#each severityOptions as opt (opt.value)}+ <Select.Item value={opt.value} label={opt.label}>{opt.label}</Select.Item>+ {/each}+ </Select.Content>+ </Select.Root>+ </SearchBar>+ </div>+ </div>++ <div class="flex flex-wrap items-center gap-2">+ <button+ type="button"+ class="inline-flex items-center gap-1 rounded-full border border-dashed px-3 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground"+ onclick={openAddFilterDialog}+ disabled={loading}+ >+ <Plus class="h-3 w-3" />+ Add filter+ </button>+ {#each attributeFilters as f, i (i)}+ <span+ class="inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-mono"+ >+ <span class="text-muted-foreground">{f.scope}.{f.key}</span>+ <span>=</span>+ <span>{f.value}</span>+ <button+ type="button"+ aria-label="Remove filter"+ class="ml-1 text-muted-foreground hover:text-foreground"+ onclick={() => removeAttributeFilter(i)}+ >+ <X class="h-3 w-3" />+ </button>+ </span>+ {/each}+ </div>++ <AlertDialog.Root open={addFilterOpen} onOpenChange={(open) => (addFilterOpen = open)}>+ <AlertDialog.Content>+ <AlertDialog.Header>+ <AlertDialog.Title>Add attribute filter</AlertDialog.Title>+ <AlertDialog.Description>+ Attribute keys must start with <code class="font-mono">resource.</code>,+ <code class="font-mono">scope.</code>, or <code class="font-mono">log.</code>.+ </AlertDialog.Description>+ </AlertDialog.Header>+ <div class="flex flex-col gap-3">+ <label class="flex flex-col gap-1 text-sm">+ <span class="font-medium">Attribute key</span>+ <Input+ placeholder="resource.service.name"+ bind:value={dialogKey}+ onkeydown={handleDialogKeydown}+ />+ </label>+ <label class="flex flex-col gap-1 text-sm">+ <span class="font-medium">Value</span>+ <Input+ placeholder="backend-service"+ bind:value={dialogValue}+ onkeydown={handleDialogKeydown}+ />+ </label>+ {#if dialogError}+ <p class="text-xs text-red-500">{dialogError}</p>+ {/if}+ </div>+ <AlertDialog.Footer>+ <Button variant="outline" onclick={() => (addFilterOpen = false)}>Cancel</Button>+ <Button onclick={submitDialogFilter}>+ <Plus class="h-4 w-4" /> Add filter+ </Button>+ </AlertDialog.Footer>+ </AlertDialog.Content>+ </AlertDialog.Root>++ <div class="overflow-hidden rounded-md border">+ <Table.Root>+ {#if loading}+ <Table.Body>+ <Table.Row>+ <Table.Cell colspan={5} class="h-48">+ <div class="flex h-full items-center justify-center">+ <LoadingCircle size="xlg" />+ </div>+ </Table.Cell>+ </Table.Row>+ </Table.Body>+ {:else if error}+ <Table.Body>+ <Table.Row>+ <Table.Cell colspan={5} class="h-24 text-center text-red-500">+ {error}+ </Table.Cell>+ </Table.Row>+ </Table.Body>+ {:else if logs.length === 0}+ <Table.Body>+ <TableEmptyState colspan={5} message="No logs found." />+ </Table.Body>+ {:else}+ <Table.Header>+ <Table.Row>+ <TracewayTableHeader+ label="Timestamp"+ tooltip="Log event time"+ class="w-[180px]"+ sortField="timestamp"+ currentSortField={sortField}+ {sortDirection}+ onSort={handleSort}+ />+ <TracewayTableHeader+ label="Level"+ tooltip="Log severity"+ class="w-[90px]"+ sortField="severity_number"+ currentSortField={sortField}+ {sortDirection}+ onSort={handleSort}+ />+ <TracewayTableHeader label="Message" tooltip="Log body (click row to expand)" />+ <TracewayTableHeader+ label="Service"+ tooltip="Emitting service"+ class="w-[160px]"+ sortField="service_name"+ currentSortField={sortField}+ {sortDirection}+ onSort={handleSort}+ />+ <TracewayTableHeader+ label="Trace"+ tooltip="Linked trace ID (if present)"+ class="w-[110px]"+ />+ </Table.Row>+ </Table.Header>+ <Table.Body>+ {#each logs as log (log.id)}+ <Table.Row+ class="group cursor-pointer hover:bg-muted/50"+ onclick={() => toggleExpanded(log.id)}+ >+ <Table.Cell class="text-muted-foreground tabular-nums">+ {formatDateTime(log.timestamp, { timezone })}+ </Table.Cell>+ <Table.Cell>+ <SeverityBadge+ severityText={log.severityText}+ severityNumber={log.severityNumber}+ />+ </Table.Cell>+ <Table.Cell class="max-w-[600px] truncate font-mono text-sm">+ {firstLine(log.body)}+ </Table.Cell>+ <Table.Cell class="truncate text-muted-foreground">+ {log.serviceName || '—'}+ </Table.Cell>+ <Table.Cell class="font-mono text-xs">+ {#if log.traceId}+ <span class="text-muted-foreground" title={log.traceId}>+ {log.traceId.slice(0, 8)}…+ </span>+ {:else}+ <span class="text-muted-foreground">—</span>+ {/if}+ </Table.Cell>+ </Table.Row>+ {#if expandedId === log.id}+ <ExpandedLogRow {log} colspan={5} />+ {/if}+ {/each}+ </Table.Body>+ {/if}+ </Table.Root>+ </div>++ <PaginationFooter+ currentPage={page}+ {totalPages}+ {pageSize}+ totalItems={total}+ onPageChange={handlePageChange}+ onPageSizeChange={handlePageSizeChange}+ {loading}+ itemLabel="log"+ />+</div>