# Path: stackimpact/utils.py
# def timestamp():
#     return int(time.time())
# 
# def generate_uuid():
#     return str(uuid.uuid4())
# 
# def generate_sha1(text):
#     sha1_hash = hashlib.sha1()
#     sha1_hash.update(text.encode('utf-8'))
#     return sha1_hash.hexdigest()


import threading
import random
import math
from .utils import timestamp, generate_uuid, generate_sha1
        self.unit = unit
        self.measurement = None
        self.has_last_value = False
        self.last_value = None


    def has_measurement(self):
        return self.measurement != None


    def create_measurement(self, trigger, value, duration = None, breakdown = None):
        ready = True

        if self.typ == Metric.TYPE_COUNTER:
            if not self.has_last_value:
                ready = False
                self.has_last_value = True
                self.last_value = value
            else:
                tmp_value = value
                value = value - self.last_value
                self.last_value = tmp_value

        if ready:
            self.measurement = Measurement(
                generate_uuid(),
                trigger,
                value,
                duration,
                breakdown,

# Path: stackimpact/utils.py
# def timestamp():
#     return int(time.time())
# 
# def generate_uuid():
#     return str(uuid.uuid4())
# 
# def generate_sha1(text):
#     sha1_hash = hashlib.sha1()
#     sha1_hash.update(text.encode('utf-8'))
#     return sha1_hash.hexdigest()


# Path: stackimpact/metric.py
import threading
import random
import math
from .utils import timestamp, generate_uuid, generate_sha1

        self.unit = unit
        self.measurement = None
        self.has_last_value = False
        self.last_value = None


    def has_measurement(self):
        return self.measurement != None


    def create_measurement(self, trigger, value, duration = None, breakdown = None):
        ready = True

        if self.typ == Metric.TYPE_COUNTER:
            if not self.has_last_value:
                ready = False
                self.has_last_value = True
                self.last_value = value
            else:
                tmp_value = value
                value = value - self.last_value
                self.last_value = tmp_value

        if ready:
            self.measurement = Measurement(
                generate_uuid(),
                trigger,
                value,
                duration,
                breakdown,

                timestamp())