#!/usr/bin/env python3

import json
import math
import os
import random


metrics = {}


def noise(value):
    r = (-0.5 + random.random()) / 10 # [-0.05, 0.05]
    return (1 + r) * value # 5% variation up or down


def add_metric(name, value):
    global metrics
    metrics[name] = [noise(value), noise(value), noise(value)]


x = int(os.getenv('BUILD', '0'))
add_metric('const', 5)
add_metric('rand/tens',  20 + random.random() * 10)
add_metric('rand/thousands', 2000 + random.random() * 1000)
add_metric('math/lineup', x * 2)
add_metric('math/linedown', 2 - x * 2)
add_metric('math/sin', 5 + math.sin(x*math.pi/4))
metrics['exact'] = 1.38 * x

print(json.dumps(metrics, indent=4))
