From 3bbeea9053af9910122d8a0b72fd3e945c5b76d8 Mon Sep 17 00:00:00 2001 From: ElectroNafta Date: Wed, 2 Oct 2024 11:27:51 +0200 Subject: [PATCH] feat(BRIDGE-206): refactored; added missing stuff; TODO rebase --- internal/db_impl/sqlite3/client.go | 5 ++++- internal/state/actions.go | 1 - server.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/db_impl/sqlite3/client.go b/internal/db_impl/sqlite3/client.go index 2abc9893..6873b578 100644 --- a/internal/db_impl/sqlite3/client.go +++ b/internal/db_impl/sqlite3/client.go @@ -193,9 +193,12 @@ func (c *Client) wrapTx(ctx context.Context, op func(context.Context, *sql.Tx, * } if err := tx.Commit(); err != nil { + if !errors.Is(err, context.Canceled) { + observability.AddOtherMetric(ctx, metrics.GenerateFailedToCommitDatabaseTransactionMetric()) + } + if c.debug { entry.Debugf("Failed to commit Transaction") - observability.AddOtherMetric(ctx, metrics.GenerateFailedToCommitDatabaseTransactionMetric()) } return fmt.Errorf("%v: %w", err, db.ErrTransactionFailed) diff --git a/internal/state/actions.go b/internal/state/actions.go index 4f877491..03b68706 100644 --- a/internal/state/actions.go +++ b/internal/state/actions.go @@ -113,7 +113,6 @@ func (state *State) actionCreateMessage( } if knownErr == nil { if cameFromDrafts { - // TODO save the data from Sentry observability.AddOtherMetric(ctx, metrics.GenerateAppendToDraftsMustNotReturnExistingRemoteID()) state.log.Errorf("Append to drafts must not return an existing RemoteID (Remote=%v, Internal=%v)", res.ID, knownInternalID) diff --git a/server.go b/server.go index 83534ef1..8abf3782 100644 --- a/server.go +++ b/server.go @@ -124,6 +124,7 @@ func (s *Server) AddUser(ctx context.Context, conn connector.Connector, passphra // LoadUser adds an existing user using a previously crated unique user ID. // It returns true if the user was newly created, false if it already existed. func (s *Server) LoadUser(ctx context.Context, conn connector.Connector, userID string, passphrase []byte) (bool, error) { + ctx = observability.NewContextWithObservabilitySender(ctx, s.observabilitySender) ctx = reporter.NewContextWithReporter(ctx, s.reporter) isNew, err := s.backend.AddUser(ctx, userID, conn, passphrase, s.uidValidityGenerator)