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
added interface for spanAggregates API
Ankit Anand1e7b68203f36
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 78003d02f2..84c5e6e079 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -609,3 +609,11 @@ func (r *ClickHouseReader) GetServiceMapDependencies(ctx context.Context, queryPreturn &retMe, nil}++func (r *ClickHouseReader) SearchSpansAggregate(ctx context.Context, queryParams *model.SpanSearchAggregatesParams) ([]model.SpanSearchAggregatesResponseItem, error) {++ spanSearchAggregatesResponseItems := []model.SpanSearchAggregatesResponseItem{}++ return spanSearchAggregatesResponseItems, nil++}diff --git a/pkg/query-service/app/druidReader/reader.go b/pkg/query-service/app/druidReader/reader.goindex 6d5e8d6bb0..e7124e9f48 100644--- a/pkg/query-service/app/druidReader/reader.go+++ b/pkg/query-service/app/druidReader/reader.go@@ -94,3 +94,6 @@ func (druid *DruidReader) SearchTraces(ctx context.Context, traceId string) (*[]func (druid *DruidReader) GetServiceMapDependencies(ctx context.Context, query *model.GetServicesParams) (*[]model.ServiceMapDependencyResponseItem, error) {return druidQuery.GetServiceMapDependencies(druid.SqlClient, query)}+func (druid *DruidReader) SearchSpansAggregate(ctx context.Context, queryParams *model.SpanSearchAggregatesParams) ([]model.SpanSearchAggregatesResponseItem, error) {+ return druidQuery.SearchSpansAggregate(druid.Client, queryParams)+}diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.goindex 27bc583319..7d0ec7bbbc 100644--- a/pkg/query-service/app/http_handler.go+++ b/pkg/query-service/app/http_handler.go@@ -67,7 +67,7 @@ func (aH *APIHandler) RegisterRoutes(router *mux.Router) {router.HandleFunc("/api/v1/service/{service}/operations", aH.getOperations).Methods(http.MethodGet)router.HandleFunc("/api/v1/service/top_endpoints", aH.getTopEndpoints).Methods(http.MethodGet)router.HandleFunc("/api/v1/spans", aH.searchSpans).Methods(http.MethodGet)- // router.HandleFunc("/api/v1/spans/aggregates", aH.searchSpansAggregates).Methods(http.MethodGet)+ router.HandleFunc("/api/v1/spans/aggregates", aH.searchSpansAggregates).Methods(http.MethodGet)router.HandleFunc("/api/v1/tags", aH.searchTags).Methods(http.MethodGet)router.HandleFunc("/api/v1/traces/{traceId}", aH.searchTraces).Methods(http.MethodGet)router.HandleFunc("/api/v1/usage", aH.getUsage).Methods(http.MethodGet)@@ -310,20 +310,20 @@ func (aH *APIHandler) searchTraces(w http.ResponseWriter, r *http.Request) {}-// func (aH *APIHandler) searchSpansAggregates(w http.ResponseWriter, r *http.Request) {+func (aH *APIHandler) searchSpansAggregates(w http.ResponseWriter, r *http.Request) {-// query, err := parseSearchSpanAggregatesRequest(r)-// if aH.handleError(w, err, http.StatusBadRequest) {-// return-// }+ query, err := parseSearchSpanAggregatesRequest(r)+ if aH.handleError(w, err, http.StatusBadRequest) {+ return+ }-// result, err := druidQuery.SearchSpansAggregate(aH.client, query)-// if aH.handleError(w, err, http.StatusBadRequest) {-// return-// }+ result, err := (*aH.reader).SearchSpansAggregate(context.Background(), query)+ if aH.handleError(w, err, http.StatusBadRequest) {+ return+ }-// aH.writeJSON(w, r, result)-// }+ aH.writeJSON(w, r, result)+}func (aH *APIHandler) searchSpans(w http.ResponseWriter, r *http.Request) {diff --git a/pkg/query-service/app/interface.go b/pkg/query-service/app/interface.goindex 107ade68c7..8f00bfef71 100644--- a/pkg/query-service/app/interface.go+++ b/pkg/query-service/app/interface.go@@ -22,4 +22,5 @@ type Reader interface {GetServicesList(ctx context.Context) (*[]string, error)SearchTraces(ctx context.Context, traceID string) (*[]model.SearchSpansResult, error)GetServiceMapDependencies(ctx context.Context, query *model.GetServicesParams) (*[]model.ServiceMapDependencyResponseItem, error)+ SearchSpansAggregate(ctx context.Context, queryParams *model.SpanSearchAggregatesParams) ([]model.SpanSearchAggregatesResponseItem, error)}diff --git a/pkg/query-service/druidQuery/query.go b/pkg/query-service/druidQuery/query.goindex 5a2be97943..b618b5ce1d 100644--- a/pkg/query-service/druidQuery/query.go+++ b/pkg/query-service/druidQuery/query.go@@ -27,11 +27,6 @@ type SpanSearchAggregatesDuratonReceivedItem struct {Result DurationItem `json:"result"`}-type SpanSearchAggregatesResponseItem struct {- Timestamp int64 `json:"timestamp"`- Value float32 `json:"value"`-}-func buildFilters(queryParams *model.SpanSearchParams) (*godruid.Filter, error) {var filter *godruid.Filter@@ -219,7 +214,7 @@ func SearchTraces(client *godruid.Client, traceId string) (*[]model.SearchSpansR}-func SearchSpansAggregate(client *godruid.Client, queryParams *model.SpanSearchAggregatesParams) ([]SpanSearchAggregatesResponseItem, error) {+func SearchSpansAggregate(client *godruid.Client, queryParams *model.SpanSearchAggregatesParams) ([]model.SpanSearchAggregatesResponseItem, error) {filter, err := buildFiltersForSpansAggregates(queryParams)var needsPostAggregation bool = true@@ -303,7 +298,7 @@ func SearchSpansAggregate(client *godruid.Client, queryParams *model.SpanSearchAreturn nil, fmt.Errorf("Error in unmarshalling response from druid")}- var response []SpanSearchAggregatesResponseItem+ var response []model.SpanSearchAggregatesResponseItemfor _, elem := range *receivedResponse {@@ -314,7 +309,7 @@ func SearchSpansAggregate(client *godruid.Client, queryParams *model.SpanSearchAif queryParams.AggregationOption == "rate_per_sec" {value = elem.Result.Value * 1.0 / float32(queryParams.StepSeconds)}- response = append(response, SpanSearchAggregatesResponseItem{+ response = append(response, model.SpanSearchAggregatesResponseItem{Timestamp: timestamp,Value: value,})diff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.goindex fdd86eb880..841a8eb86c 100644--- a/pkg/query-service/model/response.go+++ b/pkg/query-service/model/response.go@@ -162,3 +162,8 @@ type ServiceMapDependencyResponseItem struct {Child string `json:"child,omitempty" db:"child,omitempty"`CallCount int `json:"callCount,omitempty" db:"callCount,omitempty"`}++type SpanSearchAggregatesResponseItem struct {+ Timestamp int64 `json:"timestamp"`+ Value float32 `json:"value"`+}