diff --git a/integration/setup/client.go b/integration/setup/client.go index 65a0592c9e72..d20308a7a7a4 100644 --- a/integration/setup/client.go +++ b/integration/setup/client.go @@ -27,7 +27,6 @@ import ( "go.opentelemetry.io/otel" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/testutil" "github.com/FerretDB/FerretDB/internal/util/testutil/testtb" ) @@ -97,8 +96,6 @@ func setupClient(tb testtb.TB, ctx context.Context, uri string, disableOtel bool ctx, span := otel.Tracer("").Start(ctx, "setupClient") defer span.End() - defer observability.FuncCall(ctx)() - client, err := makeClient(ctx, uri, disableOtel) if err != nil { tb.Error(err) diff --git a/integration/setup/listener.go b/integration/setup/listener.go index 3699eb188f2e..2e439c6bb475 100644 --- a/integration/setup/listener.go +++ b/integration/setup/listener.go @@ -28,7 +28,6 @@ import ( "github.com/FerretDB/FerretDB/internal/clientconn" "github.com/FerretDB/FerretDB/internal/handler/registry" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/password" "github.com/FerretDB/FerretDB/internal/util/state" "github.com/FerretDB/FerretDB/internal/util/testutil" @@ -108,8 +107,6 @@ func setupListener(tb testtb.TB, ctx context.Context, logger *zap.Logger, opts * _, span := otel.Tracer("").Start(ctx, "setupListener") defer span.End() - defer observability.FuncCall(ctx)() - require.Empty(tb, *targetURLF, "-target-url must be empty for in-process FerretDB") var handler string diff --git a/integration/setup/setup.go b/integration/setup/setup.go index b15c08a67e2d..3ec16bd448ea 100644 --- a/integration/setup/setup.go +++ b/integration/setup/setup.go @@ -20,7 +20,6 @@ import ( "flag" "fmt" "net/url" - "runtime/trace" "slices" "strings" "time" @@ -33,7 +32,6 @@ import ( "go.uber.org/zap" "github.com/FerretDB/FerretDB/internal/util/iterator" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/testutil" "github.com/FerretDB/FerretDB/internal/util/testutil/testtb" @@ -143,8 +141,6 @@ func SetupWithOpts(tb testtb.TB, opts *SetupOpts) *SetupResult { setupCtx, span := otel.Tracer("").Start(ctx, "SetupWithOpts") defer span.End() - defer trace.StartRegion(setupCtx, "SetupWithOpts").End() - if opts == nil { opts = new(SetupOpts) } @@ -210,8 +206,6 @@ func setupCollection(tb testtb.TB, ctx context.Context, client *mongo.Client, op ctx, span := otel.Tracer("").Start(ctx, "setupCollection") defer span.End() - defer observability.FuncCall(ctx)() - var ownDatabase bool databaseName := opts.DatabaseName if databaseName == "" { @@ -273,7 +267,6 @@ func InsertProviders(tb testtb.TB, ctx context.Context, collection *mongo.Collec for _, provider := range providers { spanName := fmt.Sprintf("insertProviders/%s/%s", collectionName, provider.Name()) provCtx, span := otel.Tracer("").Start(ctx, spanName) - region := trace.StartRegion(provCtx, spanName) docs := shareddata.Docs(provider) require.NotEmpty(tb, docs) @@ -283,7 +276,6 @@ func InsertProviders(tb testtb.TB, ctx context.Context, collection *mongo.Collec require.Len(tb, res.InsertedIDs, len(docs)) inserted = true - region.End() span.End() } @@ -301,7 +293,6 @@ func insertBenchmarkProvider(tb testtb.TB, ctx context.Context, collection *mong spanName := fmt.Sprintf("insertBenchmarkProvider/%s/%s", collectionName, provider.Name()) provCtx, span := otel.Tracer("").Start(ctx, spanName) - region := trace.StartRegion(provCtx, spanName) iter := provider.NewIterator() defer iter.Close() @@ -326,7 +317,6 @@ func insertBenchmarkProvider(tb testtb.TB, ctx context.Context, collection *mong inserted = true } - region.End() span.End() return diff --git a/integration/setup/setup_compat.go b/integration/setup/setup_compat.go index 3b16cdb4db41..65f125ceccc7 100644 --- a/integration/setup/setup_compat.go +++ b/integration/setup/setup_compat.go @@ -17,7 +17,6 @@ package setup import ( "context" "fmt" - "runtime/trace" "strings" "github.com/stretchr/testify/require" @@ -25,7 +24,6 @@ import ( "go.opentelemetry.io/otel" "go.uber.org/zap" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/testutil" "github.com/FerretDB/FerretDB/internal/util/testutil/testtb" @@ -71,8 +69,6 @@ func SetupCompatWithOpts(tb testtb.TB, opts *SetupCompatOpts) *SetupCompatResult setupCtx, span := otel.Tracer("").Start(ctx, "SetupCompatWithOpts") defer span.End() - defer trace.StartRegion(setupCtx, "SetupCompatWithOpts").End() - if opts == nil { opts = new(SetupCompatOpts) } @@ -143,8 +139,6 @@ func setupCompatCollections(tb testtb.TB, ctx context.Context, client *mongo.Cli ctx, span := otel.Tracer("").Start(ctx, "setupCompatCollections") defer span.End() - defer observability.FuncCall(ctx)() - database := client.Database(opts.databaseName) cleanupDatabase(ctx, tb, database, nil) @@ -165,7 +159,6 @@ func setupCompatCollections(tb testtb.TB, ctx context.Context, client *mongo.Cli spanName := fmt.Sprintf("setupCompatCollections/%s", collectionName) collCtx, span := otel.Tracer("").Start(ctx, spanName) - region := trace.StartRegion(collCtx, spanName) collection := database.Collection(collectionName) @@ -192,7 +185,6 @@ func setupCompatCollections(tb testtb.TB, ctx context.Context, client *mongo.Cli collections = append(collections, collection) - region.End() span.End() } diff --git a/internal/backends/backend.go b/internal/backends/backend.go index 79b8250bb020..2ce1d1eb96d3 100644 --- a/internal/backends/backend.go +++ b/internal/backends/backend.go @@ -23,7 +23,6 @@ import ( "github.com/FerretDB/FerretDB/internal/clientconn/conninfo" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -94,8 +93,6 @@ type StatusResult struct { // connection can be established and authenticated. // For that reason, the implementation should not return only cached results. func (bc *backendContract) Status(ctx context.Context, params *StatusParams) (*StatusResult, error) { - defer observability.FuncCall(ctx)() - // to both check that conninfo is present (which is important for that method), // and to render doc.go correctly must.NotBeZero(conninfo.Get(ctx)) @@ -143,8 +140,6 @@ type DatabaseInfo struct { // // Database may not exist; that's not an error. func (bc *backendContract) ListDatabases(ctx context.Context, params *ListDatabasesParams) (*ListDatabasesResult, error) { - defer observability.FuncCall(ctx)() - res, err := bc.b.ListDatabases(ctx, params) checkError(err) @@ -169,8 +164,6 @@ type DropDatabaseParams struct { // DropDatabase drops existing database for given parameters (including valid name). func (bc *backendContract) DropDatabase(ctx context.Context, params *DropDatabaseParams) error { - defer observability.FuncCall(ctx)() - err := validateDatabaseName(params.Name) if err == nil { err = bc.b.DropDatabase(ctx, params) diff --git a/internal/backends/collection.go b/internal/backends/collection.go index a3e3df84ba70..fd0253296b74 100644 --- a/internal/backends/collection.go +++ b/internal/backends/collection.go @@ -22,7 +22,6 @@ import ( "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" ) // DefaultIndexName is a name of the index that is created when a collection is created. @@ -103,8 +102,6 @@ type QueryResult struct { // // Limit, if non-zero, should be applied. func (cc *collectionContract) Query(ctx context.Context, params *QueryParams) (*QueryResult, error) { - defer observability.FuncCall(ctx)() - if params == nil { params = new(QueryParams) } @@ -151,8 +148,6 @@ type ExplainResult struct { // The ExplainResult's SortPushdown field is set to true if the backend could have applied the whole requested sorting. // If it was possible to apply it only partially or not at all, that field should be set to false. func (cc *collectionContract) Explain(ctx context.Context, params *ExplainParams) (*ExplainResult, error) { - defer observability.FuncCall(ctx)() - if params == nil { params = new(ExplainParams) } @@ -191,8 +186,6 @@ type InsertAllResult struct{} // // Both database and collection may or may not exist; they should be created automatically if needed. func (cc *collectionContract) InsertAll(ctx context.Context, params *InsertAllParams) (*InsertAllResult, error) { - defer observability.FuncCall(ctx)() - now := time.Now() for _, doc := range params.Docs { doc.SetRecordID(types.NextTimestamp(now).Signed()) @@ -226,8 +219,6 @@ type UpdateAllResult struct { // // Database or collection may not exist; that's not an error. func (cc *collectionContract) UpdateAll(ctx context.Context, params *UpdateAllParams) (*UpdateAllResult, error) { - defer observability.FuncCall(ctx)() - for _, doc := range params.Docs { doc.Freeze() } @@ -259,8 +250,6 @@ type DeleteAllResult struct { // // Database or collection may not exist; that's not an error. func (cc *collectionContract) DeleteAll(ctx context.Context, params *DeleteAllParams) (*DeleteAllResult, error) { - defer observability.FuncCall(ctx)() - must.BeTrue((params.IDs == nil) != (params.RecordIDs == nil)) res, err := cc.c.DeleteAll(ctx, params) @@ -295,8 +284,6 @@ type IndexSize struct { // // The errors for non-existing database and non-existing collection are the same. func (cc *collectionContract) Stats(ctx context.Context, params *CollectionStatsParams) (*CollectionStatsResult, error) { - defer observability.FuncCall(ctx)() - res, err := cc.c.Stats(ctx, params) checkError(err, ErrorCodeCollectionDoesNotExist) @@ -317,8 +304,6 @@ type CompactResult struct{} // If full is true, the operation should try to reduce the disk space as much as possible, // even if collection or the whole database will be locked for some time. func (cc *collectionContract) Compact(ctx context.Context, params *CompactParams) (*CompactResult, error) { - defer observability.FuncCall(ctx)() - res, err := cc.c.Compact(ctx, params) checkError(err, ErrorCodeDatabaseDoesNotExist, ErrorCodeCollectionDoesNotExist) @@ -350,8 +335,6 @@ type IndexKeyPair struct { // // The errors for non-existing database and non-existing collection are the same. func (cc *collectionContract) ListIndexes(ctx context.Context, params *ListIndexesParams) (*ListIndexesResult, error) { - defer observability.FuncCall(ctx)() - res, err := cc.c.ListIndexes(ctx, params) checkError(err, ErrorCodeCollectionDoesNotExist) @@ -380,8 +363,6 @@ type CreateIndexesResult struct{} // // Database or collection may not exist; that's not an error. func (cc *collectionContract) CreateIndexes(ctx context.Context, params *CreateIndexesParams) (*CreateIndexesResult, error) { - defer observability.FuncCall(ctx)() - res, err := cc.c.CreateIndexes(ctx, params) checkError(err) @@ -404,8 +385,6 @@ type DropIndexesResult struct{} // // Database or collection may not exist; that's not an error. func (cc *collectionContract) DropIndexes(ctx context.Context, params *DropIndexesParams) (*DropIndexesResult, error) { - defer observability.FuncCall(ctx)() - res, err := cc.c.DropIndexes(ctx, params) checkError(err) diff --git a/internal/backends/database.go b/internal/backends/database.go index 4473336c0e9b..13a702efe60c 100644 --- a/internal/backends/database.go +++ b/internal/backends/database.go @@ -20,7 +20,6 @@ import ( "slices" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" ) // Database is a generic interface for all backends for accessing databases. @@ -106,8 +105,6 @@ func (ci *CollectionInfo) Capped() bool { // // Database may not exist; that's not an error. func (dbc *databaseContract) ListCollections(ctx context.Context, params *ListCollectionsParams) (*ListCollectionsResult, error) { - defer observability.FuncCall(ctx)() - res, err := dbc.db.ListCollections(ctx, params) checkError(err) @@ -142,8 +139,6 @@ func (ccp *CreateCollectionParams) Capped() bool { // // Database may or may not exist; it should be created automatically if needed. func (dbc *databaseContract) CreateCollection(ctx context.Context, params *CreateCollectionParams) error { - defer observability.FuncCall(ctx)() - must.BeTrue(params.CappedSize >= 0) must.BeTrue(params.CappedDocuments >= 0) @@ -166,8 +161,6 @@ type DropCollectionParams struct { // // The errors for non-existing database and non-existing collection are the same. func (dbc *databaseContract) DropCollection(ctx context.Context, params *DropCollectionParams) error { - defer observability.FuncCall(ctx)() - err := validateCollectionName(params.Name) if err == nil { err = dbc.db.DropCollection(ctx, params) @@ -189,8 +182,6 @@ type RenameCollectionParams struct { // // The errors for non-existing database and non-existing collection are the same. func (dbc *databaseContract) RenameCollection(ctx context.Context, params *RenameCollectionParams) error { - defer observability.FuncCall(ctx)() - err := validateCollectionName(params.OldName) if err == nil { @@ -222,8 +213,6 @@ type DatabaseStatsResult struct { // Stats returns statistic estimations about the database. // All returned values are not exact, but might be more accurate when Stats is called with `Refresh: true`. func (dbc *databaseContract) Stats(ctx context.Context, params *DatabaseStatsParams) (*DatabaseStatsResult, error) { - defer observability.FuncCall(ctx)() - res, err := dbc.db.Stats(ctx, params) checkError(err, ErrorCodeDatabaseDoesNotExist) diff --git a/internal/backends/decorators/oplog/collection.go b/internal/backends/decorators/oplog/collection.go index ef35fe82feb8..06703d449bb6 100644 --- a/internal/backends/decorators/oplog/collection.go +++ b/internal/backends/decorators/oplog/collection.go @@ -23,7 +23,6 @@ import ( "github.com/FerretDB/FerretDB/internal/backends" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" ) // fixed OpLog database and collection names. @@ -59,8 +58,6 @@ func (c *collection) Query(ctx context.Context, params *backends.QueryParams) (* // InsertAll implements backends.Collection interface. func (c *collection) InsertAll(ctx context.Context, params *backends.InsertAllParams) (*backends.InsertAllResult, error) { - defer observability.FuncCall(ctx)() - res, err := c.origC.InsertAll(ctx, params) if err != nil { return nil, err @@ -99,8 +96,6 @@ func (c *collection) InsertAll(ctx context.Context, params *backends.InsertAllPa // UpdateAll implements backends.Collection interface. func (c *collection) UpdateAll(ctx context.Context, params *backends.UpdateAllParams) (*backends.UpdateAllResult, error) { - defer observability.FuncCall(ctx)() - res, err := c.origC.UpdateAll(ctx, params) if err != nil { return nil, err @@ -143,8 +138,6 @@ func (c *collection) UpdateAll(ctx context.Context, params *backends.UpdateAllPa // DeleteAll implements backends.Collection interface. func (c *collection) DeleteAll(ctx context.Context, params *backends.DeleteAllParams) (*backends.DeleteAllResult, error) { - defer observability.FuncCall(ctx)() - res, err := c.origC.DeleteAll(ctx, params) if err != nil { return nil, err diff --git a/internal/backends/hana/query_iterator.go b/internal/backends/hana/query_iterator.go index edfecf3aff97..f25a83427496 100644 --- a/internal/backends/hana/query_iterator.go +++ b/internal/backends/hana/query_iterator.go @@ -25,7 +25,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/fsql" "github.com/FerretDB/FerretDB/internal/util/iterator" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -51,8 +50,6 @@ func newQueryIterator(ctx context.Context, rows *fsql.Rows) types.DocumentsItera // Next implements iterator.Interface. // Otherwise, the next document is returned. func (iter *queryIterator) Next() (struct{}, *types.Document, error) { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -96,8 +93,6 @@ func (iter *queryIterator) Next() (struct{}, *types.Document, error) { // Close implements iterator.Interface. func (iter *queryIterator) Close() { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -108,8 +103,6 @@ func (iter *queryIterator) Close() { // // This should be called only when the caller already holds the mutex. func (iter *queryIterator) close() { - defer observability.FuncCall(iter.ctx)() - if iter.rows != nil { iter.rows.Close() iter.rows = nil diff --git a/internal/backends/mysql/metadata/registry.go b/internal/backends/mysql/metadata/registry.go index db97ded5f3d9..e3ad2df4ff4d 100644 --- a/internal/backends/mysql/metadata/registry.go +++ b/internal/backends/mysql/metadata/registry.go @@ -36,7 +36,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/fsql" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/state" ) @@ -209,8 +208,6 @@ func (r *Registry) initDBs(ctx context.Context, p *fsql.DB) ([]string, error) { // initCollection loads collection metadata from the database during initialization. func (r *Registry) initCollections(ctx context.Context, dbName string, p *fsql.DB) error { - defer observability.FuncCall(ctx)() - q := fmt.Sprintf( `SELECT %s FROM %s.%s`, DefaultColumn, @@ -247,8 +244,6 @@ func (r *Registry) initCollections(ctx context.Context, dbName string, p *fsql.D // // If the user is not authenticated, it returns an error. func (r *Registry) DatabaseList(ctx context.Context) ([]string, error) { - defer observability.FuncCall(ctx)() - _, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -267,8 +262,6 @@ func (r *Registry) DatabaseList(ctx context.Context) ([]string, error) { // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) (*fsql.DB, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -291,8 +284,6 @@ func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) (*fsq // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*fsql.DB, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -310,8 +301,6 @@ func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*fsq // // It does not hold the lock. func (r *Registry) databaseGetOrCreate(ctx context.Context, p *fsql.DB, dbName string) (*fsql.DB, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db != nil { return p, nil @@ -393,8 +382,6 @@ func (r *Registry) databaseGetOrCreate(ctx context.Context, p *fsql.DB, dbName s // // If user is not authenticated, it returns error. func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -413,8 +400,6 @@ func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) (bool, error // // It does not hold the lock. func (r *Registry) databaseDrop(ctx context.Context, p *fsql.DB, dbName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db == nil { return false, nil @@ -441,8 +426,6 @@ func (r *Registry) databaseDrop(ctx context.Context, p *fsql.DB, dbName string) // // If the user is not authenticated, it returns error. func (r *Registry) CollectionList(ctx context.Context, dbName string) ([]*Collection, error) { - defer observability.FuncCall(ctx)() - if _, err := r.getPool(ctx); err != nil { return nil, lazyerrors.Error(err) } @@ -486,8 +469,6 @@ func (cpp *CollectionCreateParams) Capped() bool { // // If the user is not authenticated, it returns error. func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -507,8 +488,6 @@ func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreat // // It does not hold the lock. func (r *Registry) collectionCreate(ctx context.Context, p *fsql.DB, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - dbName, collectionName := params.DBName, params.Name _, err := r.databaseGetOrCreate(ctx, p, dbName) @@ -604,8 +583,6 @@ func (r *Registry) collectionCreate(ctx context.Context, p *fsql.DB, params *Col // // If the user is not authenticated, it returns error. func (r *Registry) CollectionGet(ctx context.Context, dbName, collectionName string) (*Collection, error) { - defer observability.FuncCall(ctx)() - if _, err := r.getPool(ctx); err != nil { return nil, lazyerrors.Error(err) } @@ -638,8 +615,6 @@ func (r *Registry) collectionGet(dbName, collectionName string) *Collection { // // If the user is not authenticated, it returns error. func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -658,8 +633,6 @@ func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName st // // It does not hold the lock. func (r *Registry) collectionDrop(ctx context.Context, p *fsql.DB, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db == nil { return false, nil @@ -708,8 +681,6 @@ func (r *Registry) collectionDrop(ctx context.Context, p *fsql.DB, dbName, colle // // If the user is not authenticated, it returns error. func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionName, newCollectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -763,8 +734,6 @@ func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionNa // // If the user is not authenticated, it returns error. func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return lazyerrors.Error(err) @@ -781,8 +750,6 @@ func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName str // // It does not hold the lock. func (r *Registry) indexesCreate(ctx context.Context, p *fsql.DB, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - _, err := r.collectionCreate(ctx, p, &CollectionCreateParams{DBName: dbName, Name: collectionName}) if err != nil { return lazyerrors.Error(err) @@ -974,8 +941,6 @@ func (r *Registry) indexesCreate(ctx context.Context, p *fsql.DB, dbName, collec // // If the user is not authenticated, it returns error. func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return lazyerrors.Error(err) @@ -995,8 +960,6 @@ func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName strin // // It does not hold the lock. func (r *Registry) indexesDrop(ctx context.Context, p *fsql.DB, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - // check if the collection exists c := r.collectionGet(dbName, collectionName) if c == nil { diff --git a/internal/backends/mysql/query_iterator.go b/internal/backends/mysql/query_iterator.go index f19938e20aae..48e6a44ac0b2 100644 --- a/internal/backends/mysql/query_iterator.go +++ b/internal/backends/mysql/query_iterator.go @@ -27,7 +27,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/iterator" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -65,8 +64,6 @@ func newQueryIterator(ctx context.Context, rows *fsql.Rows, onlyRecordIDs bool) // Next implements iterator.Interface. func (iter *queryIterator) Next() (struct{}, *types.Document, error) { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -136,8 +133,6 @@ func (iter *queryIterator) Next() (struct{}, *types.Document, error) { // Close implements iterator.Interface. func (iter *queryIterator) Close() { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -148,8 +143,6 @@ func (iter *queryIterator) Close() { // // This should be called only when the caller already holds the mutex. func (iter *queryIterator) close() { - defer observability.FuncCall(iter.ctx)() - if iter.rows != nil { iter.rows.Close() iter.rows = nil diff --git a/internal/backends/postgresql/metadata/pool/transaction.go b/internal/backends/postgresql/metadata/pool/transaction.go index 92ba86129ba3..f52bd7594c7c 100644 --- a/internal/backends/postgresql/metadata/pool/transaction.go +++ b/internal/backends/postgresql/metadata/pool/transaction.go @@ -19,16 +19,12 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" - - "github.com/FerretDB/FerretDB/internal/util/observability" ) // InTransaction uses pool p and wraps the given function f in a transaction. // // If f returns an error or context is canceled, the transaction is rolled back. func InTransaction(ctx context.Context, p *pgxpool.Pool, f func(tx pgx.Tx) error) error { - defer observability.FuncCall(ctx)() - if err := pgx.BeginFunc(ctx, p, f); err != nil { // do not wrap error because the caller of f depends on it in some cases return err diff --git a/internal/backends/postgresql/metadata/registry.go b/internal/backends/postgresql/metadata/registry.go index 84645f9ed50d..946d98b455f0 100644 --- a/internal/backends/postgresql/metadata/registry.go +++ b/internal/backends/postgresql/metadata/registry.go @@ -37,7 +37,6 @@ import ( "github.com/FerretDB/FerretDB/internal/handler/sjson" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/state" ) @@ -220,8 +219,6 @@ func (r *Registry) initDBs(ctx context.Context, p *pgxpool.Pool) ([]string, erro // initCollections loads collections metadata from the database during initialization. func (r *Registry) initCollections(ctx context.Context, dbName string, p *pgxpool.Pool) error { - defer observability.FuncCall(ctx)() - q := fmt.Sprintf( `SELECT %s FROM %s`, DefaultColumn, @@ -258,8 +255,6 @@ func (r *Registry) initCollections(ctx context.Context, dbName string, p *pgxpoo // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseList(ctx context.Context) ([]string, error) { - defer observability.FuncCall(ctx)() - _, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -278,8 +273,6 @@ func (r *Registry) DatabaseList(ctx context.Context) ([]string, error) { // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) (*pgxpool.Pool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -302,8 +295,6 @@ func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) (*pgx // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*pgxpool.Pool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return nil, lazyerrors.Error(err) @@ -321,8 +312,6 @@ func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*pgx // // It does not hold the lock. func (r *Registry) databaseGetOrCreate(ctx context.Context, p *pgxpool.Pool, dbName string) (*pgxpool.Pool, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db != nil { return p, nil @@ -385,8 +374,6 @@ func (r *Registry) databaseGetOrCreate(ctx context.Context, p *pgxpool.Pool, dbN // // If the user is not authenticated, it returns error. func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -405,8 +392,6 @@ func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) (bool, error // // It does not hold the lock. func (r *Registry) databaseDrop(ctx context.Context, p *pgxpool.Pool, dbName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db == nil { return false, nil @@ -432,8 +417,6 @@ func (r *Registry) databaseDrop(ctx context.Context, p *pgxpool.Pool, dbName str // // If the user is not authenticated, it returns error. func (r *Registry) CollectionList(ctx context.Context, dbName string) ([]*Collection, error) { - defer observability.FuncCall(ctx)() - if _, err := r.getPool(ctx); err != nil { return nil, lazyerrors.Error(err) } @@ -478,8 +461,6 @@ func (ccp *CollectionCreateParams) Capped() bool { // // If the user is not authenticated, it returns error. func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -499,8 +480,6 @@ func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreat // // It does not hold the lock. func (r *Registry) collectionCreate(ctx context.Context, p *pgxpool.Pool, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - dbName, collectionName := params.DBName, params.Name _, err := r.databaseGetOrCreate(ctx, p, dbName) @@ -595,8 +574,6 @@ func (r *Registry) collectionCreate(ctx context.Context, p *pgxpool.Pool, params // // If the user is not authenticated, it returns error. func (r *Registry) CollectionGet(ctx context.Context, dbName, collectionName string) (*Collection, error) { - defer observability.FuncCall(ctx)() - if _, err := r.getPool(ctx); err != nil { return nil, lazyerrors.Error(err) } @@ -629,8 +606,6 @@ func (r *Registry) collectionGet(dbName, collectionName string) *Collection { // // If the user is not authenticated, it returns error. func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -649,8 +624,6 @@ func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName st // // It does not hold the lock. func (r *Registry) collectionDrop(ctx context.Context, p *pgxpool.Pool, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.colls[dbName] if db == nil { return false, nil @@ -701,8 +674,6 @@ func (r *Registry) collectionDrop(ctx context.Context, p *pgxpool.Pool, dbName, // // If the user is not authenticated, it returns error. func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionName, newCollectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return false, lazyerrors.Error(err) @@ -756,8 +727,6 @@ func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionNa // // If the user is not authenticated, it returns error. func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return lazyerrors.Error(err) @@ -775,8 +744,6 @@ func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName str // // It does not hold the lock. func (r *Registry) indexesCreate(ctx context.Context, p *pgxpool.Pool, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - _, err := r.collectionCreate(ctx, p, &CollectionCreateParams{DBName: dbName, Name: collectionName}) if err != nil { return lazyerrors.Error(err) @@ -922,8 +889,6 @@ func (r *Registry) indexesCreate(ctx context.Context, p *pgxpool.Pool, dbName, c // // If the user is not authenticated, it returns error. func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - p, err := r.getPool(ctx) if err != nil { return lazyerrors.Error(err) @@ -943,8 +908,6 @@ func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName strin // // It does not hold the lock. func (r *Registry) indexesDrop(ctx context.Context, p *pgxpool.Pool, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - c := r.collectionGet(dbName, collectionName) if c == nil { return nil diff --git a/internal/backends/postgresql/query_iterator.go b/internal/backends/postgresql/query_iterator.go index 36f51487fda5..4bda4b7c8fbc 100644 --- a/internal/backends/postgresql/query_iterator.go +++ b/internal/backends/postgresql/query_iterator.go @@ -28,7 +28,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/iterator" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -66,8 +65,6 @@ func newQueryIterator(ctx context.Context, rows pgx.Rows, onlyRecordIDs bool) ty // Next implements iterator.Interface. func (iter *queryIterator) Next() (struct{}, *types.Document, error) { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -137,8 +134,6 @@ func (iter *queryIterator) Next() (struct{}, *types.Document, error) { // Close implements iterator.Interface. func (iter *queryIterator) Close() { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -149,8 +144,6 @@ func (iter *queryIterator) Close() { // // This should be called only when the caller already holds the mutex. func (iter *queryIterator) close() { - defer observability.FuncCall(iter.ctx)() - if iter.rows != nil { iter.rows.Close() iter.rows = nil diff --git a/internal/backends/sqlite/metadata/pool/pool.go b/internal/backends/sqlite/metadata/pool/pool.go index 97b269b47fac..883e21ad55a2 100644 --- a/internal/backends/sqlite/metadata/pool/pool.go +++ b/internal/backends/sqlite/metadata/pool/pool.go @@ -35,7 +35,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/fsql" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/logging" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" "github.com/FerretDB/FerretDB/internal/util/state" ) @@ -163,8 +162,6 @@ func (p *Pool) Close() { // List returns a sorted list of database names in the pool. func (p *Pool) List(ctx context.Context) []string { - defer observability.FuncCall(ctx)() - p.rw.RLock() defer p.rw.RUnlock() @@ -176,8 +173,6 @@ func (p *Pool) List(ctx context.Context) []string { // GetExisting returns an existing database by valid name, or nil. func (p *Pool) GetExisting(ctx context.Context, name string) *fsql.DB { - defer observability.FuncCall(ctx)() - p.rw.RLock() defer p.rw.RUnlock() @@ -188,8 +183,6 @@ func (p *Pool) GetExisting(ctx context.Context, name string) *fsql.DB { // // Returned boolean value indicates whether the database was created. func (p *Pool) GetOrCreate(ctx context.Context, name string) (*fsql.DB, bool, error) { - defer observability.FuncCall(ctx)() - db := p.GetExisting(ctx, name) if db != nil { return db, false, nil @@ -222,8 +215,6 @@ func (p *Pool) GetOrCreate(ctx context.Context, name string) (*fsql.DB, bool, er // // Returned boolean value indicates whether the database was removed. func (p *Pool) Drop(ctx context.Context, name string) bool { - defer observability.FuncCall(ctx)() - p.rw.Lock() defer p.rw.Unlock() diff --git a/internal/backends/sqlite/metadata/registry.go b/internal/backends/sqlite/metadata/registry.go index a77e777bfc57..288c13dc96ed 100644 --- a/internal/backends/sqlite/metadata/registry.go +++ b/internal/backends/sqlite/metadata/registry.go @@ -33,7 +33,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/fsql" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/state" ) @@ -100,8 +99,6 @@ func (r *Registry) Close() { // initCollections loads collections metadata from the database during initialization. func (r *Registry) initCollections(ctx context.Context, dbName string, db *fsql.DB) error { - defer observability.FuncCall(ctx)() - rows, err := db.QueryContext(ctx, fmt.Sprintf("SELECT name, table_name, settings FROM %q", metadataTableName)) if err != nil { return lazyerrors.Error(err) @@ -130,22 +127,16 @@ func (r *Registry) initCollections(ctx context.Context, dbName string, db *fsql. // DatabaseList returns a sorted list of existing databases. func (r *Registry) DatabaseList(ctx context.Context) []string { - defer observability.FuncCall(ctx)() - return r.p.List(ctx) } // DatabaseGetExisting returns a connection to existing database or nil if it doesn't exist. func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) *fsql.DB { - defer observability.FuncCall(ctx)() - return r.p.GetExisting(ctx, dbName) } // DatabaseGetOrCreate returns a connection to existing database or newly created database. func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*fsql.DB, error) { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -156,8 +147,6 @@ func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*fsq // // It does not hold the lock. func (r *Registry) databaseGetOrCreate(ctx context.Context, dbName string) (*fsql.DB, error) { - defer observability.FuncCall(ctx)() - db, created, err := r.p.GetOrCreate(ctx, dbName) if err != nil { return nil, lazyerrors.Error(err) @@ -187,8 +176,6 @@ func (r *Registry) databaseGetOrCreate(ctx context.Context, dbName string) (*fsq // // Returned boolean value indicates whether the database was dropped. func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) bool { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -201,8 +188,6 @@ func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) bool { // // It does not hold the lock. func (r *Registry) databaseDrop(ctx context.Context, dbName string) bool { - defer observability.FuncCall(ctx)() - delete(r.colls, dbName) return r.p.Drop(ctx, dbName) @@ -212,8 +197,6 @@ func (r *Registry) databaseDrop(ctx context.Context, dbName string) bool { // // If database does not exist, no error is returned. func (r *Registry) CollectionList(ctx context.Context, dbName string) ([]*Collection, error) { - defer observability.FuncCall(ctx)() - db := r.DatabaseGetExisting(ctx, dbName) if db == nil { return nil, nil @@ -252,8 +235,6 @@ func (ccp *CollectionCreateParams) Capped() bool { // Returned boolean value indicates whether the collection was created. // If collection already exists, (false, nil) is returned. func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -268,8 +249,6 @@ func (r *Registry) CollectionCreate(ctx context.Context, params *CollectionCreat // // It does not hold the lock. func (r *Registry) collectionCreate(ctx context.Context, params *CollectionCreateParams) (bool, error) { - defer observability.FuncCall(ctx)() - dbName, collectionName := params.DBName, params.Name db, err := r.databaseGetOrCreate(ctx, dbName) @@ -352,8 +331,6 @@ func (r *Registry) collectionCreate(ctx context.Context, params *CollectionCreat // // If database or collection does not exist, nil is returned. func (r *Registry) CollectionGet(ctx context.Context, dbName, collectionName string) *Collection { - defer observability.FuncCall(ctx)() - r.rw.RLock() defer r.rw.RUnlock() @@ -380,8 +357,6 @@ func (r *Registry) collectionGet(dbName, collectionName string) *Collection { // Returned boolean value indicates whether the collection was dropped. // If database or collection did not exist, (false, nil) is returned. func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -395,8 +370,6 @@ func (r *Registry) CollectionDrop(ctx context.Context, dbName, collectionName st // // It does not hold the lock. func (r *Registry) collectionDrop(ctx context.Context, dbName, collectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.DatabaseGetExisting(ctx, dbName) if db == nil { return false, nil @@ -429,8 +402,6 @@ func (r *Registry) collectionDrop(ctx context.Context, dbName, collectionName st // Returned boolean value indicates whether the collection was renamed. // If database or collection did not exist, (false, nil) is returned. func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionName, newCollectionName string) (bool, error) { - defer observability.FuncCall(ctx)() - db := r.DatabaseGetExisting(ctx, dbName) if db == nil { return false, nil @@ -460,8 +431,6 @@ func (r *Registry) CollectionRename(ctx context.Context, dbName, oldCollectionNa // // Existing indexes with given names are ignored. func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -474,8 +443,6 @@ func (r *Registry) IndexesCreate(ctx context.Context, dbName, collectionName str // // It does not hold the lock. func (r *Registry) indexesCreate(ctx context.Context, dbName, collectionName string, indexes []IndexInfo) error { - defer observability.FuncCall(ctx)() - _, err := r.collectionCreate(ctx, &CollectionCreateParams{DBName: dbName, Name: collectionName}) if err != nil { return lazyerrors.Error(err) @@ -552,8 +519,6 @@ func (r *Registry) indexesCreate(ctx context.Context, dbName, collectionName str // // If database or collection does not exist, nil is returned. func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - r.rw.Lock() defer r.rw.Unlock() @@ -568,8 +533,6 @@ func (r *Registry) IndexesDrop(ctx context.Context, dbName, collectionName strin // // It does not hold the lock. func (r *Registry) indexesDrop(ctx context.Context, dbName, collectionName string, indexNames []string) error { - defer observability.FuncCall(ctx)() - c := r.collectionGet(dbName, collectionName) if c == nil { return nil diff --git a/internal/backends/sqlite/query_iterator.go b/internal/backends/sqlite/query_iterator.go index 3b2646b7c90b..4fc8a1734b48 100644 --- a/internal/backends/sqlite/query_iterator.go +++ b/internal/backends/sqlite/query_iterator.go @@ -27,7 +27,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/iterator" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -65,8 +64,6 @@ func newQueryIterator(ctx context.Context, rows *fsql.Rows, onlyRecordIDs bool) // Next implements iterator.Interface. func (iter *queryIterator) Next() (struct{}, *types.Document, error) { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -136,8 +133,6 @@ func (iter *queryIterator) Next() (struct{}, *types.Document, error) { // Close implements iterator.Interface. func (iter *queryIterator) Close() { - defer observability.FuncCall(iter.ctx)() - iter.m.Lock() defer iter.m.Unlock() @@ -148,8 +143,6 @@ func (iter *queryIterator) Close() { // // This should be called only when the caller already holds the mutex. func (iter *queryIterator) close() { - defer observability.FuncCall(iter.ctx)() - if iter.rows != nil { iter.rows.Close() iter.rows = nil diff --git a/internal/clientconn/conn.go b/internal/clientconn/conn.go index 8af09cb78aa2..c563c0843f78 100644 --- a/internal/clientconn/conn.go +++ b/internal/clientconn/conn.go @@ -28,7 +28,6 @@ import ( "net/netip" "os" "path/filepath" - "runtime/pprof" "sync/atomic" "time" @@ -43,7 +42,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/logging" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/wire" ) @@ -582,12 +580,6 @@ func (c *conn) route(connCtx context.Context, reqHeader *wire.MsgHeader, reqBody func (c *conn) handleOpMsg(connCtx context.Context, msg *wire.OpMsg, command string) (*wire.OpMsg, error) { if cmd, ok := c.h.Commands()[command]; ok { if cmd.Handler != nil { - defer observability.FuncCall(connCtx)() - - defer pprof.SetGoroutineLabels(connCtx) - connCtx = pprof.WithLabels(connCtx, pprof.Labels("command", command)) - pprof.SetGoroutineLabels(connCtx) - return cmd.Handler(connCtx, msg) } } diff --git a/internal/clientconn/listener.go b/internal/clientconn/listener.go index 9f93b14b2b0c..e77caf205a62 100644 --- a/internal/clientconn/listener.go +++ b/internal/clientconn/listener.go @@ -22,7 +22,6 @@ import ( "log/slog" "math/rand" "net" - "runtime/pprof" "sync" "time" @@ -266,10 +265,6 @@ func acceptLoop(ctx context.Context, listener net.Listener, wg *sync.WaitGroup, connID := fmt.Sprintf("%s -> %s", remoteAddr, netConn.LocalAddr()) - defer pprof.SetGoroutineLabels(connCtx) - connCtx = pprof.WithLabels(connCtx, pprof.Labels("conn", connID)) - pprof.SetGoroutineLabels(connCtx) - opts := &newConnOpts{ netConn: netConn, mode: l.Mode, diff --git a/internal/util/fsql/db.go b/internal/util/fsql/db.go index 2eaa3d75c3da..2e3930f81a34 100644 --- a/internal/util/fsql/db.go +++ b/internal/util/fsql/db.go @@ -24,7 +24,6 @@ import ( "go.uber.org/zap" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -70,14 +69,11 @@ func (db *DB) Close() error { // Ping calls [*sql.DB.Ping]. func (db *DB) Ping(ctx context.Context) error { - defer observability.FuncCall(ctx)() return db.sqlDB.Ping() } // QueryContext calls [*sql.DB.QueryContext]. func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error) { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} @@ -93,8 +89,6 @@ func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Row // QueryRowContext calls [*sql.DB.QueryRowContext]. func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} @@ -110,8 +104,6 @@ func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *s // ExecContext calls [*sql.DB.ExecContext]. func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} @@ -137,8 +129,6 @@ func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.R // // If f returns an error or context is canceled, the transaction is rolled back. func (db *DB) InTransaction(ctx context.Context, f func(*Tx) error) (err error) { - defer observability.FuncCall(ctx)() - var sqlTx *sql.Tx if sqlTx, err = db.sqlDB.BeginTx(ctx, nil); err != nil { diff --git a/internal/util/fsql/tx.go b/internal/util/fsql/tx.go index 025729acc3b7..3da2f5d86874 100644 --- a/internal/util/fsql/tx.go +++ b/internal/util/fsql/tx.go @@ -21,7 +21,6 @@ import ( "go.uber.org/zap" - "github.com/FerretDB/FerretDB/internal/util/observability" "github.com/FerretDB/FerretDB/internal/util/resource" ) @@ -65,8 +64,6 @@ func (tx *Tx) Rollback() error { // QueryContext calls [*sql.Tx.QueryContext]. func (tx *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error) { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} @@ -82,8 +79,6 @@ func (tx *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Row // QueryRowContext calls [*sql.Tx.QueryRowContext]. func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} @@ -99,8 +94,6 @@ func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *s // ExecContext calls [*sql.Tx.ExecContext]. func (tx *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) { - defer observability.FuncCall(ctx)() - start := time.Now() fields := []any{zap.Any("args", args)} diff --git a/internal/util/observability/funccall.go b/internal/util/observability/funccall.go deleted file mode 100644 index ef13340767cb..000000000000 --- a/internal/util/observability/funccall.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2021 FerretDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package observability - -import ( - "context" - "runtime" - "runtime/trace" - - "github.com/FerretDB/FerretDB/internal/util/resource" -) - -// funcCall tracks function calls. -type funcCall struct { - token *resource.Token - region *trace.Region -} - -// FuncCall adds observability to a function call. -// -// It should be called at the very beginning of the function, -// and returned function should be called at exit. -// The returned function must not be passed or stored. -// The only valid way to use FuncCall is: -// -// func foo(ctx context.Context) { -// defer FuncCall(ctx)() -// // ... -// -// For the Go execution tracer, FuncCall creates a new region for the function call -// and attaches it to the task in the context (or background task). -func FuncCall(ctx context.Context) func() { - fc := &funcCall{ - token: resource.NewToken(), - } - resource.Track(fc, fc.token) - - if trace.IsEnabled() { - pc := make([]uintptr, 1) - runtime.Callers(1, pc) - f, _ := runtime.CallersFrames(pc).Next() - funcName := f.Function - - fc.region = trace.StartRegion(ctx, funcName) - } - - return fc.leave -} - -// leave is called on function exit. -func (fc *funcCall) leave() { - if fc.region != nil { - fc.region.End() - } - - resource.Untrack(fc, fc.token) -} diff --git a/internal/util/testutil/testutil.go b/internal/util/testutil/testutil.go index 2e36aa783078..fbbb76785bea 100644 --- a/internal/util/testutil/testutil.go +++ b/internal/util/testutil/testutil.go @@ -17,7 +17,6 @@ package testutil import ( "context" - "runtime/trace" "go.opentelemetry.io/otel" @@ -60,8 +59,5 @@ func Ctx(tb testtb.TB) context.Context { span.End() }) - ctx, task := trace.NewTask(ctx, tb.Name()) - tb.Cleanup(task.End) - return ctx }