Skip to content

Latest commit

 

History

History
90 lines (80 loc) · 4.3 KB

File metadata and controls

90 lines (80 loc) · 4.3 KB

Synthetic integers

When a field generator type is int, a random integer is created.

Field Description Possible values Required? Default
type The data type for the dimension. int Yes
name The unique name for the dimension. String Yes
cardinality Indicates the number of unique values for this dimension. Use zero for unconstrained cardinality. Integer Yes
cardinality_distribution Skews the cardinality selection of the generated values. A distribution object. Yes, if cardinality not 0.
percent_missing The stochastic frequency for omitting this dimension from records (inclusive). Integer between 0 and 100. No. 0
percent_nulls The stochastic frequency (inclusive) for generating null values. Integer between 0 and 100. No. 0
distribution Specifies the distribution of the numbers generated, with each rounded to the nearest integer value. A distribution object. Yes.

In this example, session_start spawns a new worker every 3600 seconds. Each worker pauses for a uniform delay of 5–10 seconds then emits a record via example_event_1, cycling continuously.

The emitter example_event_1 produces the following dimensions:

  • user is an enum dimension, selecting one of the values using a uniform cardinality_distribution distribution object.
  • whiteboard_pen_delta - the change in the number of whiteboard pens each person owns - is an int selected using a normal distribution with a mean of 0 and standard deviation (stddev) of 4.
  • cups_of_coffee_consumed is an int generated using an exponential distribution, meaning that - on average - 25 cups of coffee are consumed, but the distribution is exponential.
{
  "states": [
    {
      "name": "session_start",
      "type": "event:start:timer",
      "cardinality_distribution": { "type": "constant", "value": 3600 },
      "next": "pause_event"
    },
    {
      "name": "pause_event",
      "type": "event:intermediate:timer",
      "cardinality_distribution": { "type": "uniform", "min": 5, "max": 10 },
      "next": "emit_event"
    },
    {
      "name": "emit_event",
      "type": "activity",
      "emitter": "example_event_1",
      "next": "pause_event"
    }
  ],
  "emitters": [
    {
      "name": "example_event_1",
      "dimensions": [
        {
          "name": "user",
          "type": "enum",
          "values": ["Aisha", "Mateo", "Chen", "Fatima", "Liam", "Kwame", "Elena", "Noah", "Tenzing", "Keisha"],
          "cardinality_distribution": { "type": "uniform", "min": 0, "max": 9 }
        },
        {
          "name": "whiteboard_pen_delta",
          "type": "int",
          "distribution": { "type": "normal", "mean": 0, "stddev": 4 }, "cardinality": 0
        },
        {
          "name": "cups_of_coffee_consumed",
          "type": "int",
          "distribution": { "type": "exponential", "mean": 25 }, "cardinality": 0
        }
      ]
    }
  ]
}

Save the configuration above as example.json and use the following command to create 10 records with one worker:

python3 src/generator.py -f example.json -n 10 -m 1

This is an example of the output:

{"time":"2042-09-23T11:03:03.402","user":"Elena","whiteboard_pen_delta":0,"cups_of_coffee_consumed":7}
{"time":"2042-09-23T11:03:10.723","user":"Keisha","whiteboard_pen_delta":0,"cups_of_coffee_consumed":5}
{"time":"2042-09-23T11:03:17.208","user":"Tenzing","whiteboard_pen_delta":0,"cups_of_coffee_consumed":74}
{"time":"2042-09-23T11:03:28.188","user":"Noah","whiteboard_pen_delta":-4,"cups_of_coffee_consumed":0}
{"time":"2042-09-23T11:03:34.053","user":"Fatima","whiteboard_pen_delta":1,"cups_of_coffee_consumed":5}
{"time":"2042-09-23T11:03:41.417","user":"Mateo","whiteboard_pen_delta":0,"cups_of_coffee_consumed":8}
{"time":"2042-09-23T11:03:46.727","user":"Tenzing","whiteboard_pen_delta":0,"cups_of_coffee_consumed":77}
{"time":"2042-09-23T11:03:54.689","user":"Elena","whiteboard_pen_delta":-3,"cups_of_coffee_consumed":31}
{"time":"2042-09-23T11:04:01.295","user":"Elena","whiteboard_pen_delta":0,"cups_of_coffee_consumed":13}
{"time":"2042-09-23T11:04:08.081","user":"Kwame","whiteboard_pen_delta":3,"cups_of_coffee_consumed":21}