Exemple #1
0
    def inner(user):
        project_info = get_project_info(user)

        envelope = Envelope()
        envelope.add_event(event)
        return send_envelope(user.client, project_info.id, project_info.key,
                             envelope)
Exemple #2
0
 def inner(user):
     transaction_data = generator()
     project_info = get_project_info(user)
     envelope = Envelope()
     envelope.add_transaction(transaction_data)
     return send_envelope(user.client, project_info.id, project_info.key,
                          envelope)
Exemple #3
0
    def inner(user):
        """
        Sends a canned event from the event cache, the event is retrieved
        from
        """
        project_info = get_project_info(user)

        return send_message(user.client, project_info.id, project_info.key,
                            event)
def _kafka_send_event(user, event, send_outcome=True):
    project_info = get_project_info(user)
    event_id = get_uuid()
    event["event_id"] = event_id

    # set required attributes for processing in a central place
    event["project"] = project_info.id
    event["timestamp"] = time.time()

    kafka_send_event(user, event, project_info.id)

    if send_outcome:
        kafka_send_outcome(user, project_info.id, Outcome.ACCEPTED, event_id)
def _kafka_send_outcome(user, outcome: Outcome):
    project_info = get_project_info(user)
    event_id = get_uuid()
    kafka_send_outcome(
        user, project_info.id, outcome, event_id, reason=outcome.reason()
    )
Exemple #6
0
    def inner(user):
        event = event_generator()
        project_info = get_project_info(user)

        return send_message(user.client, project_info.id, project_info.key,
                            event)
Exemple #7
0
    def inner(user):
        project_info = get_project_info(user)
        # get maximum deviation in seconds of duration
        max_duration_deviation = int(params["duration_range"].total_seconds())
        # get maximum deviation in seconds of start time
        max_start_deviation = int(params["started_range"].total_seconds())
        now = datetime.utcnow()
        # set the base in the past enough for max_start_spread + max_duration_spread to end up before now
        base_start = now - timedelta(seconds=max_start_deviation +
                                     max_duration_deviation)
        started_time = base_start + timedelta(
            seconds=random.randint(0, max_start_deviation))
        duration = random.randint(0, max_duration_deviation)
        started = started_time.isoformat()[:23] + "Z"  # date with milliseconds
        timestamp = now.isoformat()[:23] + "Z"
        rel = random.randint(1, params["num_releases"])
        release = f"r-1.0.{rel}"
        env = random.randint(1, params["num_environments"])
        environment = f"environment-{env}"

        ok = params["ok_weight"]
        exited = params["exited_weight"]
        errored = params["errored_weight"]
        crashed = params["crashed_weight"]
        abnormal = params["abnormal_weight"]
        status = random.choices(
            ["ok", "exited", "errored", "crashed", "abnormal"],
            weights=[ok, exited, errored, crashed, abnormal],
        )[0]

        if status == "ok":
            init = "true"
            seq = 0
        else:
            init = "false"
            seq = random.randint(1, 5)

        if status == "errored":
            errors = random.randint(1, 20)
        else:
            errors = 0

        usr = random.randint(1, params["num_users"])
        user_id = f"u-{usr}"

        session = uuid.uuid4()

        session_data = session_data_tmpl.format(
            started=started,
            init=init,
            status=status,
            errors=errors,
            duration=duration,
            session=session,
            user=user_id,
            seq=seq,
            timestamp=timestamp,
            release=release,
            environment=environment,
        )

        return send_session(user.client, project_info.id, project_info.key,
                            session_data)