Compare commits

..

1 Commits

Author SHA1 Message Date
Nikhil Soni
4e0beac9b7 fix: correct check for flux interval in tracedetail apis 2026-04-16 10:39:04 +05:30
5 changed files with 2 additions and 94 deletions

View File

@@ -4,5 +4,4 @@ export const USER_PREFERENCES = {
LAST_SEEN_CHANGELOG_VERSION: 'last_seen_changelog_version',
SPAN_DETAILS_PINNED_ATTRIBUTES: 'span_details_pinned_attributes',
SPAN_PERCENTILE_RESOURCE_ATTRIBUTES: 'span_percentile_resource_attributes',
DASHBOARD_PREFERENCES: 'dashboard_preferences',
};

View File

@@ -905,7 +905,7 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadataCache(ctx contex
return nil, err
}
if time.Since(time.UnixMilli(int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {
if time.Since(time.Unix(0, int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {
r.logger.Info("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache", "traceID", traceID)
return nil, errors.Errorf("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache, traceID: %s", traceID)
}
@@ -1138,7 +1138,7 @@ func (r *ClickHouseReader) GetFlamegraphSpansForTraceCache(ctx context.Context,
return nil, err
}
if time.Since(time.UnixMilli(int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {
if time.Since(time.Unix(0, int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {
r.logger.Info("the trace end time falls under the flux interval, skipping getFlamegraphSpansForTrace cache", "traceID", traceID)
return nil, errors.Errorf("the trace end time falls under the flux interval, skipping getFlamegraphSpansForTrace cache, traceID: %s", traceID)
}

View File

@@ -1,80 +0,0 @@
package preferencetypes
import (
"encoding/json"
"slices"
"github.com/SigNoz/signoz/pkg/errors"
)
// CursorSyncMode controls how chart cursors are synchronised across panels in a dashboard.
type CursorSyncMode string
const (
CursorSyncModeCrosshair CursorSyncMode = "crosshair"
CursorSyncModeTooltip CursorSyncMode = "tooltip"
CursorSyncModeNone CursorSyncMode = "none"
)
var allowedCursorSyncModes = []CursorSyncMode{
CursorSyncModeCrosshair,
CursorSyncModeTooltip,
CursorSyncModeNone,
}
// DashboardPreference holds user-specific overrides for a single dashboard.
type DashboardPreference struct {
CursorSyncMode CursorSyncMode `json:"cursorSyncMode"`
}
func (p DashboardPreference) Validate() error {
if !slices.Contains(allowedCursorSyncModes, p.CursorSyncMode) {
return errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput,
"invalid cursorSyncMode %q: must be one of crosshair, tooltip, none", p.CursorSyncMode)
}
return nil
}
// DashboardPreferences maps dashboard IDs to their per-dashboard user overrides.
// The key is the dashboard UUID string.
type DashboardPreferences map[string]DashboardPreference
func (p DashboardPreferences) Validate() error {
for id, pref := range p {
if err := pref.Validate(); err != nil {
return errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput,
"invalid preference for dashboard %s: %s", id, err.Error())
}
}
return nil
}
// NewDashboardPreferencesValue validates prefs and wraps it in a Value suitable
// for storage as the dashboard_preferences user preference.
func NewDashboardPreferencesValue(prefs DashboardPreferences) (Value, error) {
if err := prefs.Validate(); err != nil {
return Value{}, err
}
// DashboardPreferences is map[string]DashboardPreference — a map kind — so
// NewValue's ValueTypeObject check passes without any reflection gymnastics.
return NewValue(prefs, ValueTypeObject)
}
// DashboardPreferencesFromValue decodes a Value that was stored as
// dashboard_preferences back into the strongly-typed DashboardPreferences map.
func DashboardPreferencesFromValue(v Value) (DashboardPreferences, error) {
// MarshalJSON returns the raw JSON string stored inside Value.
jsonBytes, err := json.Marshal(v)
if err != nil {
return nil, errors.WrapInvalidInputf(err, errors.CodeInvalidInput,
"cannot marshal dashboard preferences value")
}
var prefs DashboardPreferences
if err := json.Unmarshal(jsonBytes, &prefs); err != nil {
return nil, errors.WrapInvalidInputf(err, errors.CodeInvalidInput,
"cannot decode dashboard preferences")
}
return prefs, nil
}

View File

@@ -21,7 +21,6 @@ var (
NameLastSeenChangelogVersion = Name{valuer.NewString("last_seen_changelog_version")}
NameSpanDetailsPinnedAttributes = Name{valuer.NewString("span_details_pinned_attributes")}
NameSpanPercentileResourceAttributes = Name{valuer.NewString("span_percentile_resource_attributes")}
NameDashboardPreferences = Name{valuer.NewString("dashboard_preferences")}
)
type Name struct{ valuer.String }
@@ -42,7 +41,6 @@ func NewName(name string) (Name, error) {
NameLastSeenChangelogVersion.StringValue(),
NameSpanDetailsPinnedAttributes.StringValue(),
NameSpanPercentileResourceAttributes.StringValue(),
NameDashboardPreferences.StringValue(),
},
name,
)

View File

@@ -172,15 +172,6 @@ func NewAvailablePreference() map[Name]Preference {
AllowedValues: []string{},
Value: MustNewValue([]any{}, ValueTypeArray),
},
NameDashboardPreferences: {
Name: NameDashboardPreferences,
Description: "User preferences for dashboards, such as cursor sync behaviour. Keyed by dashboard ID.",
ValueType: ValueTypeObject,
DefaultValue: MustNewValue(DashboardPreferences{}, ValueTypeObject),
AllowedScopes: []Scope{ScopeUser},
AllowedValues: []string{},
Value: MustNewValue(DashboardPreferences{}, ValueTypeObject),
},
}
}