Giter VIP home page Giter VIP logo

sample-fastapi-with-dbs's Introduction

sample-fastapi-with-dbs

Simple Fast API app with MongoDB and Redis

To show how you can see metrics for External calls and DB calls in FastAPI app, we have created a sample app which uses a database (MongoDB) so that the example is more realistic

Run using docker-compose

  • Git clone this repo

git clone https://github.com/SigNoz/sample-fastapi-with-dbs.git

Change OTEL_EXPORTER_OTLP_ENDPOINT env variable in docker-compose.yaml file to send data to SigNoz.

- OTEL_EXPORTER_OTLP_ENDPOINT=<IP of SigNoz>:4317

and then run:

docker-compose up -d

Application would be available at http://localhost:5000/. Browse and generate some data.

Or just run the following command from the terminal of your VM a few times to make some API calls to the sample app. This should return Hello World

 curl http://localhost:5000  

Run sample app without docker

Install Mongo

If you already have Mongo daemon running, you can skip the following step to install Mongo

Download MongoDB for:

Install Redis

You need to install redis server. For example if you are on Ubuntu, you can use the following

sudo apt-get install redis-server

Set up instructions

pip3 install -r requirements.txt
opentelemetry-bootstrap --action=install

Run the sample app

OTEL_METRICS_EXPORTER=none OTEL_RESOURCE_ATTRIBUTES=service.name=fastAPI OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz>:4317" opentelemetry-instrument uvicorn app.main:app --port 5000 --host 0.0.0.0

Send load to application

pip3 install locust
locust -f locust.py --headless --users 10 --spawn-rate 1 -H http://localhost:5000

sample-fastapi-with-dbs's People

Contributors

ankitnayan avatar pranay01 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.