Skip to content

Commit 08dcf25

Browse files
authored
Feature/trace as a service (#61)
* Create first version of trace as a service * Init trace with the new service * Fix initialization of all service * Set a reporting_host to jaeger * fix last commit * Added sampler to start the tracer * Fix pylint, added more tests * fix travis coveralls * Fix coverage * Fix pipfile lock * 1.4.0.rc1 * Added more test and fix flask init * fix tests * fix travis tests * fix travis tests * Get trace when request not present * Updated tests
1 parent f71b7c5 commit 08dcf25

24 files changed

+565
-286
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ python:
33
- '3.6'
44
install:
55
- pip install pipenv
6-
- pip install -U tox coveralls
6+
- pip install -U tox coverage==4.0.3 coveralls==1.8.2
77

88
script:
99
- pipenv install --dev

Pipfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ pyyaml = ">=5.1.2"
1010
anyconfig = ">=0.9.8"
1111
swagger-ui-bundle = ">=0.0.2"
1212
connexion = {extras = ["swagger-ui"],version = ">=2.2.0"}
13-
lightstep = "==4.1.0"
13+
jaeger-client = "==4.1.0"
1414
flask-opentracing = "*"
15-
opentracing = ">=2.0.0"
16-
15+
opentracing = ">=2.1"
16+
opentracing-instrumentation = "==3.2.1"
1717
[dev-packages]
1818
requests-mock = "*"
19-
coverage = "*"
19+
coverage = "==4.4.0"
2020
pytest = "*"
2121
pytest-cov = "*"
2222
pylint = "*"
2323
tox = "*"
2424
safety = "*"
2525
bandit = "*"
2626
mkdocs = "*"
27+
lightstep = "==4.1.0"
2728

2829
[requires]
2930
python_version = "3.6"

Pipfile.lock

Lines changed: 193 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pyms.flask.app import Microservice
2+
3+
ms = Microservice(service="my-ms", path=__file__)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pyms:
2+
requests:
3+
data: ""
4+
swagger:
5+
path: ""
6+
file: "swagger.yaml"
7+
tracer:
8+
client: "jaeger"
9+
host: "localhost"
10+
component_name: "Python Microservice"
11+
my-ms:
12+
DEBUG: true
13+
TESTING: false
14+
APP_NAME: "Python Microservice"
15+
APPLICATION_ROOT: ""

examples/microservice_tracer/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from examples.microservice_requests import ms
2+
app = ms.create_app()
3+
4+
if __name__ == '__main__':
5+
app.run()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
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_requests.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"

examples/microservice_tracer/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import current_app
2+
3+
from examples.microservice_requests 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

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ confidence=
5454
# --enable=similarities". If you want to run only the classes checker, but have
5555
# no Warning level messages displayed, use"--disable=all --enable=classes
5656
# --disable=W"
57-
disable=C0301,C0111,C0103,logging-format-interpolation,broad-except,unnecessary-pass
57+
disable=C0301,C0111,C0103,logging-format-interpolation,broad-except,unnecessary-pass,no-member
5858

5959
# Enable the message, report, category or checker with the given id(s). You can
6060
# either give multiple identifier separated by comma (,) or put this option

pyms/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__email__ = "[email protected]"
44

5-
__version__ = "1.3.2"
5+
__version__ = "1.4.1.rc2"

0 commit comments

Comments
 (0)