We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to be able to debug MongoDB queries that are executed by projection jobs.
Something like this:
package example func example() { queries := make(chan mongo.ExecutedQuery) go func(){ for q := range queries { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } }() store := mongo.NewEventStore(..., mongo.MonitorQueries(queries)) events, errs, err := store.Query(context.TODO(), query.New(...)) }
To easily identify which part of an app caused a query, maybe implement "query descriptions":
package example func example() { queries := make(chan mongo.ExecutedQuery) go func(){ for q := range queries { if query.Description(q.Query) == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } // or if query.Expand(q.Query).Description() == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } } }() q := query.New(...) q.Describe("example") store := mongo.NewEventStore(..., mongo.MonitorQueries(queries)) events, errs, err := store.Query(context.TODO(), q) }
Or maybe event implement full query metadata support:
package example func example() { queries := make(chan mongo.ExecutedQuery) go func(){ for q := range queries { if query.MetadataOf[map[string]string](q.Query)["description"] == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } // or if query.Expand(q.Query).Metadata().(map[string]string)["description"] == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } } }() q := query.New(query.Metadata(map[string]string{ "description": "example", })) store := mongo.NewEventStore(..., mongo.MonitorQueries(queries)) events, errs, err := store.Query(context.TODO(), q) }
Metadata could support arbitrary types:
package example func example() { queries := make(chan mongo.ExecutedQuery) go func(){ for q := range queries { if query.MetadataOf[string](q.Query) == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } if query.Expand(q.Query).Metadata().(string) == "example" { log.Printf("Query: %s", q.Query) log.Printf("Runtime: %s", q.Runtime) } } }() q := query.New(query.Metadata("example")) store := mongo.NewEventStore(..., mongo.MonitorQueries(queries)) events, errs, err := store.Query(context.TODO(), q) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I want to be able to debug MongoDB queries that are executed by projection jobs.
Something like this:
To easily identify which part of an app caused a query, maybe implement "query descriptions":
Or maybe event implement full query metadata support:
Metadata could support arbitrary types:
The text was updated successfully, but these errors were encountered: