Skip to content

Commit

Permalink
Remove FuncCall (#4476)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored Jul 18, 2024
1 parent 8fdcfd9 commit 035827a
Show file tree
Hide file tree
Showing 23 changed files with 0 additions and 325 deletions.
3 changes: 0 additions & 3 deletions integration/setup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"flag"
"fmt"
"net/url"
"runtime/trace"
"slices"
"strings"
"time"
Expand All @@ -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"

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}

Expand All @@ -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()
Expand All @@ -326,7 +317,6 @@ func insertBenchmarkProvider(tb testtb.TB, ctx context.Context, collection *mong
inserted = true
}

region.End()
span.End()

return
Expand Down
8 changes: 0 additions & 8 deletions integration/setup/setup_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ package setup
import (
"context"
"fmt"
"runtime/trace"
"strings"

"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/mongo"
"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"

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -192,7 +185,6 @@ func setupCompatCollections(tb testtb.TB, ctx context.Context, client *mongo.Cli

collections = append(collections, collection)

region.End()
span.End()
}

Expand Down
7 changes: 0 additions & 7 deletions internal/backends/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
21 changes: 0 additions & 21 deletions internal/backends/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
11 changes: 0 additions & 11 deletions internal/backends/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 0 additions & 7 deletions internal/backends/decorators/oplog/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 035827a

Please sign in to comment.