File tree Expand file tree Collapse file tree 5 files changed +87
-0
lines changed
examples/microservice_metrics Expand file tree Collapse file tree 5 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ from pyms .flask .app import Microservice
2+
3+ ms = Microservice ()
Original file line number Diff line number Diff line change 1+ pyms :
2+ services :
3+ metrics : true
4+ requests :
5+ data : " "
6+ swagger :
7+ path : " "
8+ file : " swagger.yaml"
9+ config :
10+ DEBUG : true
11+ TESTING : false
12+ APP_NAME : " Python Microservice"
13+ APPLICATION_ROOT : " "
Original file line number Diff line number Diff line change 1+ from examples .microservice_metrics import ms
2+
3+ app = ms .create_app ()
4+
5+ if __name__ == '__main__' :
6+ app .run ()
Original file line number Diff line number Diff line change 1+ ---
2+ swagger : " 2.0"
3+ info :
4+ description : " This is a sample server Test server"
5+ version : " 1.0.0"
6+ title : " Swagger Test list"
7+ termsOfService : " http://swagger.io/terms/"
8+ contact :
9+ email : " apiteam@swagger.io"
10+ license :
11+ name : " Apache 2.0"
12+ url : " http://www.apache.org/licenses/LICENSE-2.0.html"
13+ tags :
14+ - name : " colors"
15+ description : " Everything about your colors"
16+ externalDocs :
17+ description : " Find out more"
18+ url : " http://swagger.io"
19+ - name : " store"
20+ description : " Example endpoint list of colors"
21+ - name : " user"
22+ description : " Operations about user"
23+ externalDocs :
24+ description : " Find out more about our store"
25+ url : " http://swagger.io"
26+ schemes :
27+ - " http"
28+ paths :
29+ / :
30+ get :
31+ tags :
32+ - " test"
33+ summary : " Example endpoint"
34+ description : " "
35+ operationId : " examples.microservice_metrics.views.example"
36+ consumes :
37+ - " application/json"
38+ produces :
39+ - " application/json"
40+ responses :
41+ " 200 " :
42+ description : " A list of colors (may be filtered by palette)"
43+ schema :
44+ $ref : ' #/definitions/Example'
45+ " 405 " :
46+ description : " Invalid input"
47+ definitions :
48+ Example :
49+ type : " object"
50+ properties :
51+ main :
52+ type : " string"
53+ externalDocs :
54+ description : " Find out more about Swagger"
55+ url : " http://swagger.io"
Original file line number Diff line number Diff line change 1+ from flask import current_app
2+
3+ from examples .microservice_metrics import ms
4+
5+
6+ def example ():
7+ current_app .logger .info ("start request" )
8+ result = ms .requests .get_for_object ("https://ghibliapi.herokuapp.com/films/2baf70d1-42bb-4437-b551-e5fed5a87abe" )
9+ current_app .logger .info ("end request" )
10+ return result
You can’t perform that action at this time.
0 commit comments