8000 Add example of PyMS with metrics by vmjelicic · Pull Request #208 · python-microservices/pyms · GitHub
[go: up one dir, main page]

Skip to content

Add example of PyMS with metrics #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/microservice_metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pyms.flask.app import Microservice

ms = Microservice()
13 changes: 13 additions & 0 deletions examples/microservice_metrics/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pyms:
services:
metrics: true
requests:
data: ""
swagger:
path: ""
file: "swagger.yaml"
config:
DEBUG: true
TESTING: false
APP_NAME: "Python Microservice"
APPLICATION_ROOT: ""
6 changes: 6 additions & 0 deletions examples/microservice_metrics/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from examples.microservice_metrics import ms

app = ms.create_app()

if __name__ == '__main__':
app.run()
55 changes: 55 additions & 0 deletions examples/microservice_metrics/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
swagger: "2.0"
info:
description: "This is a sample server Test server"
version: "1.0.0"
title: "Swagger Test list"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
tags:
- name: "colors"
description: "Everything about your colors"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Example endpoint list of colors"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes:
- "http"
paths:
/:
get:
tags:
- "test"
summary: "Example endpoint"
description: ""
operationId: "examples.microservice_metrics.views.example"
consumes:
- "application/json"
produces:
- "application/json"
responses:
"200":
description: "A list of colors (may be filtered by palette)"
schema:
$ref: '#/definitions/Example'
"405":
description: "Invalid input"
definitions:
Example:
type: "object"
properties:
main:
type: "string"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
10 changes: 10 additions & 0 deletions examples/microservice_metrics/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import current_app

from examples.microservice_metrics import ms


def example():
current_app.logger.info("start request")
result = ms.requests.get_for_object("https://ghibliapi.herokuapp.com/films/2baf70d1-42bb-4437-b551-e5fed5a87abe")
current_app.logger.info("end request")
return result
0