Skip to content

Commit

Permalink
feat(observability-lib): add interval to panel option
Browse files Browse the repository at this point in the history
  • Loading branch information
Atrax1 committed Feb 6, 2025
1 parent 8f50d72 commit d0289c0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions observability-lib/grafana/panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ type PanelOptions struct {
Threshold *ThresholdOptions
Transform *TransformOptions
ColorScheme dashboard.FieldColorModeId
Interval string
}

type Panel struct {
Expand Down Expand Up @@ -220,6 +221,10 @@ func NewStatPanel(options *StatPanelOptions) *Panel {
Mappings(options.Mappings).
ReduceOptions(common.NewReduceDataOptionsBuilder().Calcs([]string{"last"}))

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -326,6 +331,10 @@ func NewTimeSeriesPanel(options *TimeSeriesPanelOptions) *Panel {
Mode(options.StackingMode),
)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -407,6 +416,10 @@ func NewBarGaugePanel(options *BarGaugePanelOptions) *Panel {
Calcs([]string{"lastNotNull"}).Values(false),
)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.ShowUnfilled {
newPanel.ShowUnfilled(options.ShowUnfilled)
}
Expand Down Expand Up @@ -468,6 +481,10 @@ func NewGaugePanel(options *GaugePanelOptions) *Panel {
Calcs([]string{"lastNotNull"}).Values(false),
)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -518,6 +535,10 @@ func NewTablePanel(options *TablePanelOptions) *Panel {
Unit(options.Unit).
NoValue(options.NoValue)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -593,6 +614,10 @@ func NewLogPanel(options *LogPanelOptions) *Panel {
DedupStrategy(options.DedupStrategy).
SortOrder(options.SortOrder)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -647,6 +672,10 @@ func NewHeatmapPanel(options *HeatmapPanelOptions) *Panel {
Unit(options.Unit).
NoValue(options.NoValue)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

if options.Decimals != nil {
newPanel.Decimals(*options.Decimals)
}
Expand Down Expand Up @@ -703,6 +732,10 @@ func NewTextPanel(options *TextPanelOptions) *Panel {
Mode(options.Mode).
Content(options.Content)

if options.Interval != "" {
newPanel.Interval(options.Interval)
}

return &Panel{
textPanelBuilder: newPanel,
}
Expand Down

0 comments on commit d0289c0

Please sign in to comment.