question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot startup fastapi with apm

See original GitHub issue

With start apm in docker, I just set up agent in fastapi. Then I run app with uvicorn, it hangs. To Reproduce

  1. Start Service with docker compose Reference

image

  • Test apm status image
  1. Run the following simple FastAPI app:
from fastapi import FastAPI
from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
import uvicorn


apm = make_apm_client({'SERVICE_NAME': 'test', 'SERVER_URL': 'http://0.0.0.0:8200'})
app = FastAPI()
app.add_middleware(ElasticAPM, client=apm)


@app.get("/")
def read_root():
    return {"Hello": "World"}


if __name__ == '__main__':
    uvicorn.run(app, host='0.0.0.0', port=8000)
  • Result image

Environment

  • OS: Mac
  • Python version: 3.7.10
  • Framework and version: fastapi==0.66.0
  • APM Server version: image: docker.elastic.co/apm/apm-server:7.13.2
  • Agent version: elastic-apm==6.3.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
beniwohlicommented, Jul 7, 2021

Hi @alexcc4! Thanks for opening the issue and providing a test case! I opened a PR with a fix in #1185. We’ll make a release with this fix ASAP!

0reactions
alexcc4commented, Jul 8, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Starlette/FastAPI Support | APM Python Agent ... - Elastic
Incorporating Elastic APM into your Starlette project only requires a few easy steps. Installationedit. Install the Elastic APM agent using pip: $ pip...
Read more >
Monitoring Python Applications with Elastic APM
A guide to monitoring Flask, FastAPI and Python Applications with Elastic APM and Kibana.
Read more >
tiangolo/fastapi - Gitter
Hi together, I have some problems to get a solution regarding the dependency ... But elasticsearch-apm officially supports fastapi as of a few...
Read more >
[Python] New Relic with fastapi - Agents
Hi All I am trying to use newrelic with fastapi in python, i have the same setup for the Flask app which is...
Read more >
FastAPI is not quitting when pressing Ctr+c - Stack Overflow
I've read about this problem in using uvicorn and I found the below code snippet to ... CTRL^C doesn't work while startup in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found