Merge pull request #58 from instana/ibm

LGTM
This commit is contained in:
Steve Waterworth
2021-03-02 16:45:16 +00:00
committed by GitHub
33 changed files with 33 additions and 73 deletions

2
.env
View File

@@ -1,3 +1,3 @@
# environment file for docker-compose
REPO=robotshop
TAG=0.5.2
TAG=2.0.0

View File

@@ -94,3 +94,4 @@ $ helm install robot-shop --set openshift=true helm
| payment.gateway | null | string | External URL end-point to simulate partial/3rd party traces. |
| psp.enabled | false | boolean | Enable Pod Security Policy for clusters with a PSP Admission controller |
| redis.storageClassName | standard | string | Storage class to use with Redis's StatefulSet. The default for EKS is gp2. |
| ocCreateRoute | false | boolean | If you are running on OpenShift and need a Route to the web service, set this to `true` |

View File

@@ -16,3 +16,14 @@ spec:
{{ else }}
type: LoadBalancer
{{ end }}
---
{{if .Values.ocCreateRoute}}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: web
spec:
to:
kind: Service
name: web
{{end}}

View File

@@ -31,3 +31,5 @@ openshift: false
# Storage class to use with redis statefulset.
redis:
storageClassName: standard
ocCreateRoute: false

View File

@@ -3,17 +3,17 @@
//
db = db.getSiblingDB('catalogue');
db.products.insertMany([
{sku: 'HAL-1', name: 'HAL', description: 'Sorry Dave, I cant do that', price: 2001, instock: 2, categories: ['Artificial Intelligence']},
{sku: 'PB-1', name: 'Positronic Brain', description: 'Highly advanced sentient processing unit with the laws of robotics burned in', price: 200, instock: 0, categories: ['Artificial Intelligence']},
{sku: 'ROB-1', name: 'Robbie', description: 'Large mechanical workhorse, crude but effective. Comes in handy when you are lost in space', price: 1200, instock: 12, categories: ['Robot']},
{sku: 'EVE-1', name: 'Eve', description: 'Extraterrestrial Vegetation Evaluator', price: 5000, instock: 10, categories: ['Robot']},
{sku: 'C3P0', name: 'C3P0', description: 'Protocol android', price: 953, instock: 1, categories: ['Robot']},
{sku: 'R2D2', name: 'R2D2', description: 'R2 maintenance robot and secret messenger. Help me Obi Wan', price: 1024, instock: 1, categories: ['Robot']},
{sku: 'K9', name: 'K9', description: 'Time travelling companion at heel', price: 300, instock: 12, categories: ['Robot']},
{sku: 'RD-10', name: 'Kryten', description: 'Red Drawf crew member', price: 700, instock: 5, categories: ['Robot']},
{sku: 'HHGTTG', name: 'Marvin', description: 'Marvin, your paranoid android. Brain the size of a planet', price: 42, instock: 48, categories: ['Robot']},
{sku: 'STAN-1', name: 'Stan', description: 'APM guru', price: 67, instock: 1000, categories: ['Robot', 'Artificial Intelligence']},
{sku: 'STNG', name: 'Mr Data', description: 'Could be R. Daneel Olivaw? Protype positronic brain android', price: 1000, instock: 0, categories: ['Robot']}
{sku: 'Watson', name: 'Watson', description: 'Probably the smartest AI on the planet', price: 2001, instock: 2, categories: ['Artificial Intelligence']},
{sku: 'Ewooid', name: 'Ewooid', description: 'Fully sentient assistant', price: 200, instock: 0, categories: ['Artificial Intelligence']},
{sku: 'HPTD', name: 'High-Powered Travel Droid', description: 'Traveling to the far reaches of the Galaxy? You need this for protection. Comes in handy when you are lost in space', price: 1200, instock: 12, categories: ['Robot']},
{sku: 'UHJ', name: 'Ultimate Harvesting Juggernaut', description: 'Extraterrestrial vegetation harvester', price: 5000, instock: 10, categories: ['Robot']},
{sku: 'EPE', name: 'Extreme Probe Emulator', description: 'Versatile interface adapter for hacking into systems', price: 953, instock: 1, categories: ['Robot']},
{sku: 'EMM', name: 'Exceptional Medical Machine', description: 'Fully automatic surgery droid with exceptional bedside manner', price: 1024, instock: 1, categories: ['Robot']},
{sku: 'SHCE', name: 'Strategic Human Control Emulator', description: 'Diplomatic protocol assistant', price: 300, instock: 12, categories: ['Robot']},
{sku: 'RED', name: 'Responsive Enforcer Droid', description: 'Security detail, will gaurd anything', price: 700, instock: 5, categories: ['Robot']},
{sku: 'RMC', name: 'Robotic Mining Cyborg', description: 'Excellent tunneling capability to get those rare minerals', price: 42, instock: 48, categories: ['Robot']},
{sku: 'STAN-1', name: 'Stan', description: 'Observability guru', price: 67, instock: 1000, categories: ['Robot', 'Artificial Intelligence']},
{sku: 'CNA', name: 'Cybernated Neutralization Android', description: 'Is your spaceship a bit whiffy? This little fellow will bring a breath of fresh air', price: 1000, instock: 0, categories: ['Robot']}
]);
// full text index for searching

View File

@@ -9,8 +9,6 @@ import uuid
import json
import requests
import traceback
import opentracing as ot
import opentracing.ext.tags as tags
from flask import Flask
from flask import Response
from flask import request
@@ -61,11 +59,6 @@ def pay(id):
anonymous_user = True
# add some log info to the active trace
span = ot.tracer.active_span
span.log_kv({'id': id})
span.log_kv({'cart': cart})
# check user exists
try:
req = requests.get('http://{user}:8080/check/{id}'.format(user=USER, id=id))
@@ -133,36 +126,13 @@ def pay(id):
def queueOrder(order):
app.logger.info('queue order')
# RabbitMQ pika is not currently traced automatically
# opentracing tracer is automatically set to Instana tracer
# start a span
parent_span = ot.tracer.active_span
with ot.tracer.start_active_span('queueOrder', child_of=parent_span,
tags={
'exchange': Publisher.EXCHANGE,
'key': Publisher.ROUTING_KEY
}) as tscope:
tscope.span.set_tag('span.kind', 'intermediate')
tscope.span.log_kv({'orderid': order.get('orderid')})
with ot.tracer.start_active_span('rabbitmq', child_of=tscope.span,
tags={
'exchange': Publisher.EXCHANGE,
'sort': 'publish',
'address': Publisher.HOST,
'key': Publisher.ROUTING_KEY
}
) as scope:
# For screenshot demo requirements optionally add in a bit of delay
delay = int(os.getenv('PAYMENT_DELAY_MS', 0))
time.sleep(delay / 1000)
# For screenshot demo requirements optionally add in a bit of delay
delay = int(os.getenv('PAYMENT_DELAY_MS', 0))
time.sleep(delay / 1000)
headers = {}
ot.tracer.inject(scope.span.context, ot.Format.HTTP_HEADERS, headers)
app.logger.info('msg headers {}'.format(headers))
publisher.publish(order, headers)
headers = {}
publisher.publish(order, headers)
def countItems(items):
@@ -173,29 +143,6 @@ def countItems(items):
return count
class InstanaDataCenterMiddleware():
data_centers = [
"us-east1",
"us-east2",
"us-east3",
"us-east4",
"us-central1",
"us-west1",
"us-west2",
"eu-west3",
"eu-west4"
]
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
span = ot.tracer.active_span
span.log_kv({'datacenter': random.choice(self.data_centers)})
return self.app(environ, start_response)
# RabbitMQ
publisher = Publisher(app.logger)
@@ -207,5 +154,4 @@ if __name__ == "__main__":
app.logger.info('Payment gateway {}'.format(PAYMENT_GATEWAY))
port = int(os.getenv("SHOP_PAYMENT_PORT", "8080"))
app.logger.info('Starting on port {}'.format(port))
app.wsgi_app = InstanaDataCenterMiddleware(app.wsgi_app)
app.run(host='0.0.0.0', port=port)

View File

@@ -18,7 +18,7 @@ server {
location /images/ {
expires 5s;
root /usr/share/nginx/html;
try_files $uri /images/placeholder.jpg;
try_files $uri /images/placeholder.png;
}
#error_page 404 /404.html;

BIN
web/static/images/Aplha.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
web/static/images/CNA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
web/static/images/EMM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
web/static/images/EPE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

BIN
web/static/images/HPTD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
web/static/images/RED.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
web/static/images/RMC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

BIN
web/static/images/SHCE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

BIN
web/static/images/UHJ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -6,7 +6,7 @@
<h3>{{ data.product.name }}</h3>
<div class="productimage">
<img src="/images/{{ data.product.sku }}.jpg"/>
<img src="/images/{{ data.product.sku }}.png"/>
</div>
<div class="rating">
Rating