SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
Trace static fields and structs for trace v4. (#6469)
Nityananda Gohain57c2326908d9
diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.goindex bc0cbb17ec..7072f13173 100644--- a/pkg/query-service/constants/constants.go+++ b/pkg/query-service/constants/constants.go@@ -1,6 +1,7 @@package constantsimport (+ "maps""os""strconv""testing"@@ -238,8 +239,8 @@ const (SIGNOZ_EXP_HISTOGRAM_TABLENAME = "distributed_exp_hist"SIGNOZ_TRACE_DBNAME = "signoz_traces"SIGNOZ_SPAN_INDEX_TABLENAME = "distributed_signoz_index_v2"- SIGNOZ_SPAN_INDEX_LOCAL_TABLENAME = "signoz_index_v2"SIGNOZ_SPAN_INDEX_V3 = "distributed_signoz_index_v3"+ SIGNOZ_SPAN_INDEX_LOCAL_TABLENAME = "signoz_index_v2"SIGNOZ_SPAN_INDEX_V3_LOCAL_TABLENAME = "signoz_index_v3"SIGNOZ_TIMESERIES_v4_LOCAL_TABLENAME = "time_series_v4"SIGNOZ_TIMESERIES_v4_6HRS_LOCAL_TABLENAME = "time_series_v4_6hrs"@@ -447,30 +448,35 @@ const MaxFilterSuggestionsExamplesLimit = 10var SpanRenderLimitStr = GetOrDefaultEnv("SPAN_RENDER_LIMIT", "2500")var MaxSpansInTraceStr = GetOrDefaultEnv("MAX_SPANS_IN_TRACE", "250000")-var StaticFieldsTraces = map[string]v3.AttributeKey{+var NewStaticFieldsTraces = map[string]v3.AttributeKey{"timestamp": {},- "traceID": {- Key: "traceID",+ "trace_id": {+ Key: "trace_id",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "spanID": {- Key: "spanID",+ "span_id": {+ Key: "span_id",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "parentSpanID": {- Key: "parentSpanID",+ "trace_state": {+ Key: "trace_state",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "name": {- Key: "name",+ "parent_span_id": {+ Key: "parent_span_id",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "serviceName": {- Key: "serviceName",+ "flags": {+ Key: "flags",+ DataType: v3.AttributeKeyDataTypeInt64,+ IsColumn: true,+ },+ "name": {+ Key: "name",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},@@ -479,170 +485,236 @@ var StaticFieldsTraces = map[string]v3.AttributeKey{DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "spanKind": {- Key: "spanKind",+ "kind_string": {+ Key: "kind_string",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "durationNano": {- Key: "durationNano",+ "duration_nano": {+ Key: "duration_nano",DataType: v3.AttributeKeyDataTypeFloat64,IsColumn: true,},- "statusCode": {- Key: "statusCode",+ "status_code": {+ Key: "status_code",DataType: v3.AttributeKeyDataTypeFloat64,IsColumn: true,},- "hasError": {- Key: "hasError",- DataType: v3.AttributeKeyDataTypeBool,+ "status_message": {+ Key: "status_message",+ DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "statusMessage": {- Key: "statusMessage",+ "status_code_string": {+ Key: "status_code_string",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "statusCodeString": {- Key: "statusCodeString",++ // new support for composite attributes+ "response_status_code": {+ Key: "response_status_code",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "externalHttpMethod": {- Key: "externalHttpMethod",+ "external_http_url": {+ Key: "external_http_url",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "externalHttpUrl": {- Key: "externalHttpUrl",+ "http_url": {+ Key: "http_url",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "dbSystem": {- Key: "dbSystem",+ "external_http_method": {+ Key: "external_http_method",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "dbName": {- Key: "dbName",+ "http_method": {+ Key: "http_method",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "dbOperation": {- Key: "dbOperation",+ "http_host": {+ Key: "http_host",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "peerService": {- Key: "peerService",+ "db_name": {+ Key: "db_name",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "httpMethod": {- Key: "httpMethod",+ "db_operation": {+ Key: "db_operation",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "httpUrl": {- Key: "httpUrl",- DataType: v3.AttributeKeyDataTypeString,+ "has_error": {+ Key: "has_error",+ DataType: v3.AttributeKeyDataTypeBool,IsColumn: true,},- "httpRoute": {- Key: "httpRoute",+ "is_remote": {+ Key: "is_remote",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "httpHost": {- Key: "httpHost",+ // the simple attributes are not present here as+ // they are taken care by new format <attribute_type>_<attribute_datatype>_'<attribute_key>'+}++var DeprecatedStaticFieldsTraces = map[string]v3.AttributeKey{+ "traceID": {+ Key: "traceID",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "msgSystem": {- Key: "msgSystem",+ "spanID": {+ Key: "spanID",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "msgOperation": {- Key: "msgOperation",+ "parentSpanID": {+ Key: "parentSpanID",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "rpcSystem": {- Key: "rpcSystem",+ "spanKind": {+ Key: "spanKind",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "rpcService": {- Key: "rpcService",+ "durationNano": {+ Key: "durationNano",+ DataType: v3.AttributeKeyDataTypeFloat64,+ IsColumn: true,+ },+ "statusCode": {+ Key: "statusCode",+ DataType: v3.AttributeKeyDataTypeFloat64,+ IsColumn: true,+ },+ "statusMessage": {+ Key: "statusMessage",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "rpcMethod": {- Key: "rpcMethod",+ "statusCodeString": {+ Key: "statusCodeString",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},++ // old support for composite attributes"responseStatusCode": {Key: "responseStatusCode",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},-- // new support- "response_status_code": {- Key: "response_status_code",+ "externalHttpUrl": {+ Key: "externalHttpUrl",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "external_http_url": {- Key: "external_http_url",+ "httpUrl": {+ Key: "httpUrl",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "http_url": {- Key: "http_url",+ "externalHttpMethod": {+ Key: "externalHttpMethod",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "external_http_method": {- Key: "external_http_method",+ "httpMethod": {+ Key: "httpMethod",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "http_method": {- Key: "http_method",+ "httpHost": {+ Key: "httpHost",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "http_host": {- Key: "http_host",+ "dbName": {+ Key: "dbName",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "db_name": {- Key: "db_name",+ "dbOperation": {+ Key: "dbOperation",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "db_operation": {- Key: "db_operation",+ "hasError": {+ Key: "hasError",+ DataType: v3.AttributeKeyDataTypeBool,+ IsColumn: true,+ },+ "isRemote": {+ Key: "isRemote",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "has_error": {- Key: "has_error",- DataType: v3.AttributeKeyDataTypeBool,++ // old support for resource attributes+ "serviceName": {+ Key: "serviceName",+ DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- "is_remote": {- Key: "is_remote",++ // old support for simple attributes+ "httpRoute": {+ Key: "httpRoute",DataType: v3.AttributeKeyDataTypeString,IsColumn: true,},- // the simple attributes are not present here as- // they are taken care by new format <attribute_type>_<attribute_datatype>_'<attribute_key>'+ "msgSystem": {+ Key: "msgSystem",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "msgOperation": {+ Key: "msgOperation",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "dbSystem": {+ Key: "dbSystem",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "rpcSystem": {+ Key: "rpcSystem",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "rpcService": {+ Key: "rpcService",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "rpcMethod": {+ Key: "rpcMethod",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+ "peerService": {+ Key: "peerService",+ DataType: v3.AttributeKeyDataTypeString,+ IsColumn: true,+ },+}++var StaticFieldsTraces = map[string]v3.AttributeKey{}++func init() {+ StaticFieldsTraces = maps.Clone(NewStaticFieldsTraces)+ maps.Copy(StaticFieldsTraces, DeprecatedStaticFieldsTraces)}const TRACE_V4_MAX_PAGINATION_LIMIT = 10000diff --git a/pkg/query-service/model/trace.go b/pkg/query-service/model/trace.gonew file mode 100644index 0000000000..d334e1cfe7--- /dev/null+++ b/pkg/query-service/model/trace.go@@ -0,0 +1,29 @@+package model++import "time"++type SpanItemV2 struct {+ TimeUnixNano time.Time `ch:"timestamp"`+ DurationNano uint64 `ch:"duration_nano"`+ SpanID string `ch:"span_id"`+ TraceID string `ch:"trace_id"`+ HasError bool `ch:"has_error"`+ Kind int8 `ch:"kind"`+ ServiceName string `ch:"resource_string_service$$name"`+ Name string `ch:"name"`+ References string `ch:"references"`+ Attributes_string map[string]string `ch:"attributes_string"`+ Attributes_number map[string]float64 `ch:"attributes_number"`+ Attributes_bool map[string]bool `ch:"attributes_bool"`+ Events []string `ch:"events"`+ StatusMessage string `ch:"status_message"`+ StatusCodeString string `ch:"status_code_string"`+ SpanKind string `ch:"kind_string"`+}++type TraceSummary struct {+ TraceID string `ch:"trace_id"`+ Start time.Time `ch:"start"`+ End time.Time `ch:"end"`+ NumSpans uint64 `ch:"num_spans"`+}