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
fix: ts issue fixed with live tail (#3397)
Nityananda Gohain2df5a9d72db8
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 1224e2838a..1d02035719 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -4600,6 +4600,8 @@ func (r *ClickHouseReader) GetSpanAttributeKeys(ctx context.Context) (map[stringfunc (r *ClickHouseReader) LiveTailLogsV3(ctx context.Context, query string, timestampStart uint64, idStart string, client *v3.LogsLiveTailClient) {if timestampStart == 0 {timestampStart = uint64(time.Now().UnixNano())+ } else {+ timestampStart = uint64(utils.GetEpochNanoSecs(int64(timestampStart)))}ticker := time.NewTicker(time.Duration(r.liveTailRefreshSeconds) * time.Second)diff --git a/pkg/query-service/app/logs/v3/query_builder.go b/pkg/query-service/app/logs/v3/query_builder.goindex 8f00f5fbcd..48265745b4 100644--- a/pkg/query-service/app/logs/v3/query_builder.go+++ b/pkg/query-service/app/logs/v3/query_builder.go@@ -2,7 +2,6 @@ package v3import ("fmt"- "math""strings""go.signoz.io/signoz/pkg/query-service/constants"@@ -165,20 +164,6 @@ func buildLogsTimeSeriesFilterQuery(fs *v3.FilterSet, groupBy []v3.AttributeKey)return queryString, nil}-// getZerosForEpochNano returns the number of zeros to be appended to the epoch time for converting it to nanoseconds-func getZerosForEpochNano(epoch int64) int64 {- count := 0- if epoch == 0 {- count = 1- } else {- for epoch != 0 {- epoch /= 10- count++- }- }- return int64(math.Pow(10, float64(19-count)))-}-func buildLogsQuery(panelType v3.PanelType, start, end, step int64, mq *v3.BuilderQuery, graphLimitQtype string, preferRPM bool) (string, error) {filterSubQuery, err := buildLogsTimeSeriesFilterQuery(mq.Filters, mq.GroupBy)@@ -187,7 +172,7 @@ func buildLogsQuery(panelType v3.PanelType, start, end, step int64, mq *v3.Build}// timerange will be sent in epoch millisecond- timeFilter := fmt.Sprintf("(timestamp >= %d AND timestamp <= %d)", start*getZerosForEpochNano(start), end*getZerosForEpochNano(end))+ timeFilter := fmt.Sprintf("(timestamp >= %d AND timestamp <= %d)", utils.GetEpochNanoSecs(start), utils.GetEpochNanoSecs(end))selectLabels := getSelectLabels(mq.AggregateOperator, mq.GroupBy)diff --git a/pkg/query-service/app/logs/v3/query_builder_test.go b/pkg/query-service/app/logs/v3/query_builder_test.goindex bf36b559d0..ebc62ec5e5 100644--- a/pkg/query-service/app/logs/v3/query_builder_test.go+++ b/pkg/query-service/app/logs/v3/query_builder_test.go@@ -828,36 +828,6 @@ func TestBuildLogsQuery(t *testing.T) {}}-var testGetZerosForEpochNanoData = []struct {- Name string- Epoch int64- Multiplier int64- Result int64-}{- {- Name: "Test 1",- Epoch: 1680712080000,- Multiplier: 1000000,- Result: 1680712080000000000,- },- {- Name: "Test 1",- Epoch: 1680712080000000000,- Multiplier: 1,- Result: 1680712080000000000,- },-}--func TestGetZerosForEpochNano(t *testing.T) {- for _, tt := range testGetZerosForEpochNanoData {- Convey("testGetZerosForEpochNanoData", t, func() {- multiplier := getZerosForEpochNano(tt.Epoch)- So(multiplier, ShouldEqual, tt.Multiplier)- So(tt.Epoch*multiplier, ShouldEqual, tt.Result)- })- }-}-var testOrderBy = []struct {Name stringPanelType v3.PanelTypediff --git a/pkg/query-service/utils/format.go b/pkg/query-service/utils/format.goindex 5d2ef618d4..1bfccd6858 100644--- a/pkg/query-service/utils/format.go+++ b/pkg/query-service/utils/format.go@@ -2,6 +2,7 @@ package utilsimport ("fmt"+ "math""reflect""strconv""strings"@@ -228,3 +229,18 @@ func getPointerValue(v interface{}) interface{} {return v}}++// GetEpochNanoSecs takes epoch and returns it in ns+func GetEpochNanoSecs(epoch int64) int64 {+ temp := epoch+ count := 0+ if epoch == 0 {+ count = 1+ } else {+ for epoch != 0 {+ epoch /= 10+ count+++ }+ }+ return temp * int64(math.Pow(10, float64(19-count)))+}diff --git a/pkg/query-service/utils/format_test.go b/pkg/query-service/utils/format_test.goindex 594e544ce1..bd3c0eaf35 100644--- a/pkg/query-service/utils/format_test.go+++ b/pkg/query-service/utils/format_test.go@@ -387,3 +387,32 @@ func TestClickHouseFormattedValue(t *testing.T) {})}}++var testGetEpochNanoSecsData = []struct {+ Name string+ Epoch int64+ Multiplier int64+ Result int64+}{+ {+ Name: "Test 1",+ Epoch: 1680712080000,+ Result: 1680712080000000000,+ },+ {+ Name: "Test 1",+ Epoch: 1680712080000000000,+ Result: 1680712080000000000,+ },+}++func TestGetEpochNanoSecs(t *testing.T) {+ for _, tt := range testGetEpochNanoSecsData {+ t.Run(tt.Name, func(t *testing.T) {+ got := GetEpochNanoSecs(tt.Epoch)+ if !reflect.DeepEqual(got, tt.Result) {+ t.Errorf("ClickHouseFormattedValue() = %v, want %v", got, tt.Result)+ }+ })+ }+}