Skip to content
New issue

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

Question: Using autometrics in a database (postgresql)? #68

Closed
aiswaryapajit opened this issue Jul 21, 2023 · 2 comments
Closed

Question: Using autometrics in a database (postgresql)? #68

aiswaryapajit opened this issue Jul 21, 2023 · 2 comments
Labels
question Further information is requested

Comments

@aiswaryapajit
Copy link

aiswaryapajit commented Jul 21, 2023

can we use autometrics to be run at database side(postgresql) or is there any way to use api of autometrics

@brettimus
Copy link
Collaborator

brettimus commented Jul 21, 2023

hey! so discussed this with @actualwitch this morning.

if you want to track metrics of database queries, you would have to wrap your application code that calls the database. of course, this doesn't give you metrics on specific subqueries, and would include the latency of sending the request to the database server, however! it would give you metrics for getting the data your application needs from the database, which is closest to what your users would experience.

to make it concrete, this is what you'd be trying to do, application-side:

@autometrics
def list_all_users():
  return db.query("select * from users")

@brettimus brettimus changed the title can we use autometrics to be run at database side(postgresql) or is there any way to use api of autometrics Question: Using autometrics in a database (postgresql)? Jul 21, 2023
@brettimus brettimus added the question Further information is requested label Jul 21, 2023
@brettimus
Copy link
Collaborator

a little bit off topic, but @actualwitch pointed out that lots of python APIs will use context instead of functions for this kind of (db) operation. she proposed supporting instrumentation via context manager here

i'm going to close this issue as answered!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants