Required Python Version: >= 3.7.3
- Clone the repository
cd
into the repository and create a new virtuan environment withpython3 -m venv env
- activate the
env
withsource env/bin/activate
- install the requirements with
pip install -r requirements.txt
cd
into the root directory of the project withcd trace_project
- run
python manage.py migrate
From the root folder (trace_project) run python manage.py runserver
From the root folder (trace_project) run python -m pytest
From the root folder (trace_project) run python -m pytest -m unit
From the root folder (trace_project) run python -m pytest -m integration
The endpoint for sending the trace message is: /ws/trace/<trace_id:int>
Where the trace id is an integer that needs to be unique for each new Trace.
There are different ways to interact with the app. The quickest one would probably be just open a console in the browser and use the native support with Javascript.
If you want to use Python you can use the websocket-client
library.
Here a quick example:
first install the package
pip install websocket_client
from websocket import create_connection
import json
ws = create_connection("ws://localhost:8000/ws/trace/1")
message = [
{
"timestamp": 1569972082,
"type": "TRACE_START",
"group_id": "e6fa79ca-d142-4046-a134-5134f16a0b5e"
},
{
"timestamp": 1569972090,
"type": "SPAN_END",
"group_id": "dbed4e4e-8ec6-40dd-ae35-b118abf1ab69"
},
{
"timestamp": 1569972084,
"type": "SPAN_START",
"group_id": "1ff14a38-55ff-431a-a6ca-a86c82d8ed46",
"name": "movies_network_load"
},
{
"timestamp": 1569972090,
"type": "SPAN_END",
"group_id": "1ff14a38-55ff-431a-a6ca-a86c82d8ed46"
},
{
"timestamp": 1569972083,
"type": "EVENT",
"name": "movies_cache_content_rendered"
},
{
"timestamp": 1569972082,
"type": "SPAN_START",
"group_id": "dbed4e4e-8ec6-40dd-ae35-b118abf1ab69",
"name": "movies_load"
},
{
"timestamp": 1569972090,
"type": "TRACE_END",
"group_id": "e6fa79ca-d142-4046-a134-5134f16a0b5e"
}
]
ws.send(json.dumps(message))
msg = ws.recv()
print(msg)
The endpoint for retrieving (GET) or deleting (DELETE) a trace is
/api/trace/{trace_id:int}/
You can use any client you want to interact with it but since the project is currently in DEBUG mode you can just take advantage of the django_rest browsable api.