Skip to content

Commit

Permalink
s/reads/writes/
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Oct 8, 2024
1 parent 9d7cd51 commit 9023951
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pkg/dash/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,37 @@ type DashboardLoader struct {

// individual dashboards, pre-rendered at initialization and
// accessed by http handlers via corresponding CamelCase methods
reads []byte
writes []byte
}

func NewDashboardLoader(server *server.Metrics) (*DashboardLoader, error) {

reads, err := ReadsDashboard(server.RequestDuration)
writes, err := WritesDashboard(server.RequestDuration)
if err != nil {
return nil, err
}

dashboardJson, err := json.MarshalIndent(reads, "", " ")
dashboardJson, err := json.MarshalIndent(writes, "", " ")

Check warning on line 34 in pkg/dash/dash.go

View workflow job for this annotation

GitHub Actions / check / golangciLint

var-naming: var dashboardJson should be dashboardJSON (revive)
if err != nil {
return nil, err
}

return &DashboardLoader{
server: server,

reads: dashboardJson,
writes: dashboardJson,
}, nil
}

func (l *DashboardLoader) Reads() http.HandlerFunc {
func (l *DashboardLoader) Writes() http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Check warning on line 47 in pkg/dash/dash.go

View workflow job for this annotation

GitHub Actions / check / golangciLint

unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
// TODO(owen-d): versioning
w.Header().Set("Content-Type", "application/json")
w.Write(l.reads)
w.Write(l.writes)

Check failure on line 50 in pkg/dash/dash.go

View workflow job for this annotation

GitHub Actions / check / golangciLint

Error return value of `w.Write` is not checked (errcheck)
})
}

func ReadsDashboard(requestDuration *prom.HistogramVec) (dashboard.Dashboard, error) {
func WritesDashboard(requestDuration *prom.HistogramVec) (dashboard.Dashboard, error) {
var statusMap map[string]string = nil

Check warning on line 55 in pkg/dash/dash.go

View workflow job for this annotation

GitHub Actions / check / golangciLint

var-declaration: should drop = nil from declaration of var statusMap; it is the zero value (revive)

// TODO: parameterize so caller can pass it's own scheme
Expand All @@ -76,7 +76,7 @@ func ReadsDashboard(requestDuration *prom.HistogramVec) (dashboard.Dashboard, er
"pod",
)

builder := dashboard.NewDashboardBuilder("Loki Reads (generated)").
builder := dashboard.NewDashboardBuilder("Loki Writes (generated)").
Tags([]string{"generated", "from", "go"}).
Refresh("1m").
Time("now-30m", "now").
Expand Down
2 changes: 1 addition & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ func (t *Loki) initDashboards() (services.Service, error) {
if err != nil {
return nil, err
}
t.Server.HTTP.Path("/grafana/dashboards/reads").Methods("GET").Handler(loader.Reads())
t.Server.HTTP.Path("/grafana/dashboards/writes").Methods("GET").Handler(loader.Writes())
return services.NewBasicService(nil, func(serviceContext context.Context) error {
<-serviceContext.Done()
return nil
Expand Down

0 comments on commit 9023951

Please sign in to comment.