Skip to content

Commit

Permalink
Merge pull request #322 from matrix-org/kegan/rm-high-card-metric
Browse files Browse the repository at this point in the history
Remove temporary metric
  • Loading branch information
kegsay committed Oct 2, 2023
2 parents 0d11027 + aae5b05 commit 18b6341
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
23 changes: 7 additions & 16 deletions state/accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"database/sql"
"encoding/json"
"fmt"

"github.com/matrix-org/sliding-sync/internal"
"github.com/matrix-org/sliding-sync/sync2"
"github.com/prometheus/client_golang/prometheus"

"github.com/getsentry/sentry-go"

Expand All @@ -23,13 +23,12 @@ import (
// Accumulate function for timeline events. v2 sync must be called with a large enough timeline.limit
// for this to work!
type Accumulator struct {
db *sqlx.DB
roomsTable *RoomsTable
eventsTable *EventTable
snapshotTable *SnapshotTable
spacesTable *SpacesTable
entityName string
snapshotMemberCountVec *prometheus.HistogramVec // TODO: Remove, this is temporary to get a feeling how often a new snapshot is created
db *sqlx.DB
roomsTable *RoomsTable
eventsTable *EventTable
snapshotTable *SnapshotTable
spacesTable *SpacesTable
entityName string
}

func NewAccumulator(db *sqlx.DB) *Accumulator {
Expand Down Expand Up @@ -283,10 +282,6 @@ func (a *Accumulator) Initialise(roomID string, state []json.RawMessage) (Initia
if err != nil {
return fmt.Errorf("failed to insert snapshot: %w", err)
}
if a.snapshotMemberCountVec != nil {
logger.Trace().Str("room_id", roomID).Int("members", len(memberNIDs)).Msg("Inserted new snapshot")
a.snapshotMemberCountVec.WithLabelValues(roomID).Observe(float64(len(memberNIDs)))
}
res.AddedEvents = true
latestNID := int64(0)
for _, nid := range otherNIDs {
Expand Down Expand Up @@ -519,10 +514,6 @@ func (a *Accumulator) Accumulate(txn *sqlx.Tx, userID, roomID string, timeline s
if err = a.snapshotTable.Insert(txn, newSnapshot); err != nil {
return AccumulateResult{}, fmt.Errorf("failed to insert new snapshot: %w", err)
}
if a.snapshotMemberCountVec != nil {
logger.Trace().Str("room_id", roomID).Int("members", len(memNIDs)).Msg("Inserted new snapshot")
a.snapshotMemberCountVec.WithLabelValues(roomID).Observe(float64(len(memNIDs)))
}
snapID = newSnapshot.SnapshotID
}
if err := a.eventsTable.UpdateBeforeSnapshotID(txn, ev.NID, beforeSnapID, replacesNID); err != nil {
Expand Down
18 changes: 2 additions & 16 deletions state/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/matrix-org/sliding-sync/sync2"
"os"
"strings"

"github.com/matrix-org/sliding-sync/sync2"

"github.com/getsentry/sentry-go"
"github.com/lib/pq"
"github.com/prometheus/client_golang/prometheus"

"github.com/jmoiron/sqlx"
"github.com/matrix-org/sliding-sync/internal"
Expand Down Expand Up @@ -88,17 +88,6 @@ func NewStorageWithDB(db *sqlx.DB, addPrometheusMetrics bool) *Storage {
entityName: "server",
}

if addPrometheusMetrics {
acc.snapshotMemberCountVec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "sliding_sync",
Subsystem: "poller",
Name: "snapshot_size",
Help: "Number of membership events in a snapshot",
Buckets: []float64{100.0, 500.0, 1000.0, 5000.0, 10000.0, 20000.0, 50000.0, 100000.0, 150000.0},
}, []string{"room_id"})
prometheus.MustRegister(acc.snapshotMemberCountVec)
}

return &Storage{
Accumulator: acc,
ToDeviceTable: NewToDeviceTable(db),
Expand Down Expand Up @@ -1047,9 +1036,6 @@ func (s *Storage) Teardown() {
if err != nil {
panic("Storage.Teardown: " + err.Error())
}
if s.Accumulator.snapshotMemberCountVec != nil {
prometheus.Unregister(s.Accumulator.snapshotMemberCountVec)
}
}

// circularSlice is a slice which can be appended to which will wraparound at `max`.
Expand Down

0 comments on commit 18b6341

Please sign in to comment.