Skip to content

Commit

Permalink
Add initial project skeleton
Browse files Browse the repository at this point in the history
- Add Environment variables with dotenv
- Add demo API with FlaskRestful
- Add Installation guideline
  • Loading branch information
mjrulesamrat committed Apr 3, 2021
1 parent c1878ae commit 9c6156f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
# Flask Opentelemetry

*ToDo
Distributed HTTP request-response tracing with Opentelemetry.

## Project setup guidelines
# Project setup guidelines

*ToDo
Create Python Virtual environment and run projec locally.

- Create virtual environment

```bash
python3.6 -m venv venv
```

- Install dependencies

```bash
. venv/bin/active
pip install -r requirements.txt
```

- Copy and Set environment variables

```bash
cp sample.env .env
```

- Export flask application

```bash
export FLASK_APP=app.py
```

- Run project locally

```bash
flask run
```

## Jaeger setup guidelines

Expand All @@ -13,4 +45,3 @@
## Features

*ToDo

26 changes: 26 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
__author__ = "Jay Modi"

import os
import requests

from flask import Flask
from flask_restful import Resource, Api
from dotenv import load_dotenv

load_dotenv() # take environment variables from .env

app = Flask(__name__)
api = Api(app)

class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}

api.add_resource(HelloWorld, '/')


if __name__ == "__main__":
app.run(
debug=os.getenv("DEBUG"),
port=os.getenv("API_PORT")
)
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Utilities
requests==2.25.1
python-dotenv==0.17.0

# flask
Flask==1.1.2
Flask-RESTful==0.3.8
6 changes: 6 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Flask
DEBUG=1
API_PORT=5000

# Opentelemetry
OTEL_PYTHON_FLASK_EXCLUDED_URLS="heathcheck"

0 comments on commit 9c6156f

Please sign in to comment.