Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ import (

"github.com/Arkiv-Network/query-api/sqlstore"
"github.com/Arkiv-Network/sqlite-store/query"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

var queryDuration = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "arkiv_query_api_query_duration_seconds",
Help: "Duration of database queries in seconds",
Buckets: prometheus.DefBuckets, // Default: .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10
})

type arkivAPI struct {
store *sqlstore.SQLStore
log *slog.Logger
Expand Down
9 changes: 9 additions & 0 deletions sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ import (

"github.com/Arkiv-Network/sqlite-store/query"
"github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

var ErrStopIteration = errors.New("stop iteration")

var queryDuration = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "arkiv_query_api_query_duration_seconds",
Help: "Duration of database queries in seconds",
Buckets: prometheus.DefBuckets, // Default: .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10
})

type SQLStore struct {
log *slog.Logger

Expand Down Expand Up @@ -194,6 +202,7 @@ func (s *SQLStore) QueryEntitiesInternalIterator(
startTime := time.Now()
defer func() {
elapsed := time.Since(startTime)
queryDuration.Observe(elapsed.Seconds())
s.log.Info("query execution time", "seconds", elapsed.Seconds(), "query", originalQuery)
}()

Expand Down