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.

chore: add metric for waterfall monitoring (#11557)

Nikhil Soni4fce33e2b394
diff --git a/conf/example.yaml b/conf/example.yaml
index 2a7166b12b..5aaf6722eb 100644
--- a/conf/example.yaml
+++ b/conf/example.yaml
@@ -432,7 +432,7 @@ cloudintegration:
version: v0.0.8
##################### Trace Detail #####################
-tracedetail:
+traces:
waterfall:
# Number of spans returned per request when the trace is too large to show all at once.
span_page_size: 500
diff --git a/pkg/modules/tracedetail/config.go b/pkg/modules/tracedetail/config.go
index 4c62234751..f90d3b482d 100644
--- a/pkg/modules/tracedetail/config.go
+++ b/pkg/modules/tracedetail/config.go
@@ -19,7 +19,7 @@ type WaterfallConfig struct {
}
func NewConfigFactory() factory.ConfigFactory {
- return factory.NewConfigFactory(factory.MustNewName("tracedetail"), newConfig)
+ return factory.NewConfigFactory(factory.MustNewName("traces"), newConfig)
}
func newConfig() factory.Config {
@@ -34,16 +34,13 @@ func newConfig() factory.Config {
func (c Config) Validate() error {
if c.Waterfall.SpanPageSize <= 0 {
- return errors.NewInvalidInputf(errors.CodeInvalidInput,
- "tracedetail.waterfall.span_limit_per_request must be positive, got %v", c.Waterfall.SpanPageSize)
+ return errors.NewInvalidInputf(errors.CodeInvalidInput, "traces.waterfall.span_limit_per_request must be positive, got %v", c.Waterfall.SpanPageSize)
}
if c.Waterfall.MaxDepthToAutoExpand < 0 {
- return errors.NewInvalidInputf(errors.CodeInvalidInput,
- "tracedetail.waterfall.max_depth_for_selected_children cannot be negative, got %d", c.Waterfall.MaxDepthToAutoExpand)
+ return errors.NewInvalidInputf(errors.CodeInvalidInput, "traces.waterfall.max_depth_for_selected_children cannot be negative, got %d", c.Waterfall.MaxDepthToAutoExpand)
}
if c.Waterfall.MaxLimitToSelectAllSpans == 0 {
- return errors.NewInvalidInputf(errors.CodeInvalidInput,
- "tracedetail.waterfall.max_limit_to_select_all_spans must be positive")
+ return errors.NewInvalidInputf(errors.CodeInvalidInput, "traces.waterfall.max_limit_to_select_all_spans must be positive")
}
return nil
}
diff --git a/pkg/modules/tracedetail/impltracedetail/module.go b/pkg/modules/tracedetail/impltracedetail/module.go
index 435e170939..d636911a00 100644
--- a/pkg/modules/tracedetail/impltracedetail/module.go
+++ b/pkg/modules/tracedetail/impltracedetail/module.go
@@ -7,21 +7,34 @@ import (
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/modules/tracedetail"
"github.com/SigNoz/signoz/pkg/types/spantypes"
+ "go.opentelemetry.io/otel/metric"
)
type module struct {
store spantypes.TraceStore
settings factory.ScopedProviderSettings
config tracedetail.Config
+ metrics *moduleMetrics
}
func NewModule(traceStore spantypes.TraceStore, providerSettings factory.ProviderSettings, cfg tracedetail.Config) *module {
scopedProviderSettings := factory.NewScopedProviderSettings(providerSettings, "github.com/SigNoz/signoz/pkg/modules/tracedetail/impltracedetail")
- return &module{
+
+ metrics, err := newModuleMetrics(scopedProviderSettings.Meter())
+ if err != nil {
+ panic(err)
+ }
+
+ m := &module{
config: cfg,
store: traceStore,
settings: scopedProviderSettings,
+ metrics: metrics,
}
+
+ m.metrics.waterfallSpanLimit.Record(context.Background(), int64(cfg.Waterfall.MaxLimitToSelectAllSpans), metric.WithAttributes(attrResponseType.String(attrResponseTypeWindowed)))
+
+ return m
}
func (m *module) GetWaterfall(ctx context.Context, traceID string, req *spantypes.PostableWaterfall) (*spantypes.GettableWaterfallTrace, error) {
@@ -80,6 +93,9 @@ func (m *module) GetWaterfallV4(ctx context.Context, traceID string, selectedSpa
}
effectiveLimit := min(selectAllLimit, m.config.Waterfall.MaxLimitToSelectAllSpans)
if summary.NumSpans > uint64(effectiveLimit) {
+ attrs := metric.WithAttributes(attrResponseType.String(attrResponseTypeWindowed))
+ m.metrics.waterfallRequestCount.Add(ctx, 1, attrs)
+ m.metrics.waterfallSpanCount.Add(ctx, int64(summary.NumSpans), attrs)
return m.getWindowedWaterfall(ctx, traceID, selectedSpanID, uncollapsedSpans, summary.Start, summary.End)
}
return m.getFullWaterfall(ctx, traceID, summary)
diff --git a/pkg/modules/tracedetail/impltracedetail/telemetry.go b/pkg/modules/tracedetail/impltracedetail/telemetry.go
new file mode 100644
index 0000000000..8bb0da0bc8
--- /dev/null
+++ b/pkg/modules/tracedetail/impltracedetail/telemetry.go
@@ -0,0 +1,55 @@
+package impltracedetail
+
+import (
+ "github.com/SigNoz/signoz/pkg/errors"
+ "go.opentelemetry.io/otel/attribute"
+ "go.opentelemetry.io/otel/metric"
+)
+
+const (
+ attrResponseType = attribute.Key("response_type")
+ attrResponseTypeWindowed = "windowed"
+)
+
+type moduleMetrics struct {
+ waterfallSpanLimit metric.Int64Gauge
+ waterfallRequestCount metric.Int64Counter
+ waterfallSpanCount metric.Int64Counter
+}
+
+func newModuleMetrics(meter metric.Meter) (*moduleMetrics, error) {
+ var errs error
+
+ spanLimit, err := meter.Int64Gauge(
+ "signoz.traces.waterfall.span.limit",
+ metric.WithDescription("The span count limit above which windowed waterfall is returned instead of the full waterfall."),
+ metric.WithUnit("{span}"),
+ )
+ if err != nil {
+ errs = errors.Join(errs, err)
+ }
+
+ requestCount, err := meter.Int64Counter(
+ "signoz.traces.waterfall.request.count",
+ metric.WithDescription("Total number of waterfall requests, by response_type."),
+ metric.WithUnit("{request}"),
+ )
+ if err != nil {
+ errs = errors.Join(errs, err)
+ }
+
+ spanCount, err := meter.Int64Counter(
+ "signoz.traces.waterfall.span.count",
+ metric.WithDescription("Total number of spans across waterfall requests, by response_type."),
+ metric.WithUnit("{span}"),
+ )
+ if err != nil {
+ errs = errors.Join(errs, err)
+ }
+
+ return &moduleMetrics{
+ waterfallSpanLimit: spanLimit,
+ waterfallRequestCount: requestCount,
+ waterfallSpanCount: spanCount,
+ }, errs
+}
diff --git a/pkg/signoz/config.go b/pkg/signoz/config.go
index eccd8284d5..d2954c7578 100644
--- a/pkg/signoz/config.go
+++ b/pkg/signoz/config.go
@@ -143,7 +143,7 @@ type Config struct {
CloudIntegration cloudintegration.Config `mapstructure:"cloudintegration"`
// TraceDetail config
- TraceDetail tracedetail.Config `mapstructure:"tracedetail"`
+ TraceDetail tracedetail.Config `mapstructure:"traces"`
// Authz config
Authz authz.Config `mapstructure:"authz"`