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

How to integrate into Frappeframework #1834

Open
saranRe opened this issue May 24, 2023 · 3 comments
Open

How to integrate into Frappeframework #1834

saranRe opened this issue May 24, 2023 · 3 comments
Labels

Comments

@saranRe
Copy link

saranRe commented May 24, 2023

We are running Frappe in our Python Project

https://frappeframework.com/
https://github.com/frappe/frappe

Any tips on how to integrate elastic python apm agent into this?

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels May 24, 2023
@Raaja0007
Copy link

To integrate Elastic APM (Application Performance Monitoring) agent into your Python project running Frappe, you can follow these general steps:

Install the Elastic APM agent:

You can install the Elastic APM agent using pip:

-----pip install elastic-apm-----
Import and initialize the Elastic APM agent in your Frappe application's main entry point or initialization file. This could be the file where you define your Flask or Django application object. For example, in a Flask application, you might have a file called app.py:

-----------------from elasticapm.contrib.flask import ElasticAPM
-----------------from frappe import Frappe

app = Frappe()

Initialize the Elastic APM agent

apm = ElasticAPM(app)
Note: Make sure you import the appropriate module based on your web framework. In the example above, ElasticAPM from elasticapm.contrib.flask is used for Flask. If you're using a different framework, refer to the Elastic APM documentation for the relevant module.

Configure the Elastic APM agent by adding the necessary configuration parameters. You can specify these configurations either through environment variables or by passing them directly to the ElasticAPM constructor. Here's an example configuration using environment variables:

bash

export ELASTIC_APM_SERVICE_NAME="your_service_name"
export ELASTIC_APM_SERVER_URL="http://your-apm-server:8200"
Alternatively, you can provide the configuration directly:

python
apm = ElasticAPM(app, service_name="your_service_name", server_url="http://your-apm-server:8200")
Make sure to replace your_service_name with a meaningful name for your application and http://your-apm-server:8200 with the URL of your APM server.

Instrument your code:
By default, the Elastic APM agent will automatically capture traces for HTTP requests and certain database operations. However, you can also instrument additional code blocks to gain more insights. You can use decorators or context managers to manually instrument specific functions or code blocks. Refer to the Elastic APM documentation for instructions on instrumenting specific parts of your Frappe application.

Start your Frappe application:
Start your Frappe application as you normally would, and the Elastic APM agent will now monitor and report performance metrics and errors to your APM server.

Remember to consult the official Elastic APM documentation for more detailed information and instructions specific to your web framework and use case.

@saranRe
Copy link
Author

saranRe commented Jun 3, 2023

The above doesn't work. It seems to be the auto-generated response. Is it?

@basepi
Copy link
Contributor

basepi commented Jun 3, 2023

No, it was not an auto-generated response, at least not by our team. I assumed it was a developer or user of Frappe who had it working themselves. I don't have any experience with Frappe and was hoping our Flask instrumentation would work as @Raaja0007 suggested.

We'll add this to our backlog, thanks for the request!

@basepi basepi added feature instrumentation and removed triage Issues awaiting triage labels Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants