Skip to content

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.

fix: add references in waterfall response (#11536)

Nikhil Sonie43aeb8e249b
diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml
index 6f7fc074a8..33df786a49 100644
--- a/docs/api/openapi.yml
+++ b/docs/api/openapi.yml
@@ -6572,6 +6572,15 @@ components:
nullable: true
type: array
type: object
+ SpantypesOtelSpanRef:
+ properties:
+ refType:
+ type: string
+ spanId:
+ type: string
+ traceId:
+ type: string
+ type: object
SpantypesPostableSpanMapper:
properties:
config:
@@ -6835,6 +6844,10 @@ components:
type: string
parent_span_id:
type: string
+ references:
+ items:
+ $ref: '#/components/schemas/SpantypesOtelSpanRef'
+ type: array
resource:
additionalProperties:
type: string
@@ -6860,6 +6873,8 @@ components:
type: string
trace_state:
type: string
+ required:
+ - references
type: object
TagtypesPostableTag:
properties:
diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts
index f8a8d49063..6158ba19de 100644
--- a/frontend/src/api/generated/services/sigNoz.schemas.ts
+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts
@@ -7768,6 +7768,21 @@ export interface SpantypesGettableTraceAggregationsDTO {
aggregations: SpantypesSpanAggregationResultDTO[];
}
+export interface SpantypesOtelSpanRefDTO {
+ /**
+ * @type string
+ */
+ refType?: string;
+ /**
+ * @type string
+ */
+ spanId?: string;
+ /**
+ * @type string
+ */
+ traceId?: string;
+}
+
export type SpantypesWaterfallSpanDTOAttributesAnyOf = {
[key: string]: unknown;
};
@@ -7862,6 +7877,10 @@ export interface SpantypesWaterfallSpanDTO {
* @type string
*/
parent_span_id?: string;
+ /**
+ * @type array
+ */
+ references: SpantypesOtelSpanRefDTO[];
/**
* @type object,null
*/
diff --git a/pkg/modules/tracedetail/impltracedetail/store.go b/pkg/modules/tracedetail/impltracedetail/store.go
index 0470f684e7..11067defb3 100644
--- a/pkg/modules/tracedetail/impltracedetail/store.go
+++ b/pkg/modules/tracedetail/impltracedetail/store.go
@@ -74,7 +74,7 @@ func (s *traceStore) GetTraceSpans(ctx context.Context, traceID string, summary
events, status_message, status_code_string, kind_string, parent_span_id,
flags, is_remote, trace_state, status_code,
db_name, db_operation, http_method, http_url, http_host,
- external_http_method, external_http_url, response_status_code
+ external_http_method, external_http_url, response_status_code, links as references
FROM %s.%s
WHERE trace_id=? AND ts_bucket_start>=? AND ts_bucket_start<=?
ORDER BY timestamp ASC, name ASC`,
@@ -130,7 +130,7 @@ func (s *traceStore) GetTraceSpansByIDs(ctx context.Context, traceID string, sta
"events", "status_message", "status_code_string", "kind_string", "parent_span_id",
"flags", "is_remote", "trace_state", "status_code",
"db_name", "db_operation", "http_method", "http_url", "http_host",
- "external_http_method", "external_http_url", "response_status_code",
+ "external_http_method", "external_http_url", "response_status_code", "links as references",
)
sb.From(fmt.Sprintf("%s.%s", spantypes.TraceDB, spantypes.TraceTable))
ids := make([]any, len(spanIDs))
diff --git a/pkg/types/spantypes/waterfall_span.go b/pkg/types/spantypes/waterfall_span.go
index 173675e101..7e47276b12 100644
--- a/pkg/types/spantypes/waterfall_span.go
+++ b/pkg/types/spantypes/waterfall_span.go
@@ -54,6 +54,12 @@ type Event struct {
IsError bool `json:"isError,omitempty"`
}
+type OtelSpanRef struct {
+ TraceId string `json:"traceId,omitempty"`
+ SpanId string `json:"spanId,omitempty"`
+ RefType string `json:"refType,omitempty"`
+}
+
// WaterfallSpan represents the span in waterfall response,
// this uses snake_case keys for response as a special case since these
// keys can be directly used to query spans and client need to know the actual fields.
@@ -74,6 +80,7 @@ type WaterfallSpan struct {
TimeUnix uint64 `json:"time_unix"`
TraceID string `json:"trace_id"`
TraceState string `json:"trace_state"`
+ References []OtelSpanRef `json:"references" required:"true" nullable:"false"`
// Calculated fields https://signoz.io/docs/traces-management/guides/derived-fields-spans
DBName string `json:"db_name,omitempty"`
@@ -128,6 +135,7 @@ type StorableSpan struct {
ExternalHTTPMethod string `ch:"external_http_method"`
ExternalHTTPURL string `ch:"external_http_url"`
ResponseStatusCode string `ch:"response_status_code"`
+ References string `ch:"references"`
}
// MinimalSpan with only the fields needed to build the parent-child tree.
@@ -285,6 +293,14 @@ func (item *StorableSpan) UnmarshalledEvents() []Event {
return events
}
+func (item *StorableSpan) UnmarshalledRefs() []OtelSpanRef {
+ refs := []OtelSpanRef{}
+ if err := json.Unmarshal([]byte(item.References), &refs); err != nil {
+ return nil // skip malformed values
+ }
+ return refs
+}
+
func (item *StorableSpan) ToWaterfallSpan(traceID string) *WaterfallSpan {
resources := make(map[string]string)
maps.Copy(resources, item.ResourcesString)
@@ -318,6 +334,7 @@ func (item *StorableSpan) ToWaterfallSpan(traceID string) *WaterfallSpan {
Children: make([]*WaterfallSpan, 0),
TimeUnix: uint64(item.StartTime.UnixNano()),
ServiceName: item.ServiceName,
+ References: item.UnmarshalledRefs(),
}
}