Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# IDE
.vscode/
*.swp
*.swo

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
139 changes: 139 additions & 0 deletions conf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

14 changes: 7 additions & 7 deletions conf/synthbean.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
spans:
first_span:
transactions:
first_transaction#:
duration: 1000
# jitter: 10
second_span:
# jitter: 10
second_transaction:
duration: 5000

#instance_count: 100
instance_count: 100

#instances:
# fast_instance:
# spans:
# transactions:
# instance_based_first_span:
# duration: 2000
# instance_based_second_span:
# duration: 2000
# slow_instance:
# spans:
# transactions:
# instance_based_first_span:
# duration: 3000
# instance_based_second_span:
Expand Down
Binary file added giphy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PyYAML = "^5.4.1"
halo = "^0.0.31"
psutil = "^5.8.0"
pygame = "^2.0.1"
pyglet = "^1.5.16"

[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
Expand Down
2 changes: 1 addition & 1 deletion synthbean.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
num_workers = synth_config.get('instance_count', 1)
stack_config = apm_config['elasticapm']

if synth_config.get('spans'):
if synth_config.get('transactions'):
for i in range(0, num_workers):
client = synthbean.apm_preflight(
stack_config,
Expand Down
25 changes: 14 additions & 11 deletions synthbean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def gen_welcome_msg(cli_args):
welcome_text = 'SynthBean active!'
if cli_args.ac_dc:
create_easter()
welcome_text = '-- 🎸🏴‍☠️️ For those who about to rock, the Elastic Observability Team salutes you! --'
welcome_text = '-- 🎸🏴‍☠️️ For those who are about to rock, the Elastic Observability Team salutes you! --'
return welcome_text

def verify_smoothing_config(synth_config):
if synth_config.get('smoothing_strategy') == 'floor':
for span in synth_config['spans']:
if synth_config['spans'][span].get('jitter'):
if synth_config.get('smoothing_strategy') == 'floor' and synth_config.get('transactions'):
for transaction in synth_config['transactions']:
if synth_config['transactions'][transaction].get('jitter'):
raise Exception(
'Cannot use jitter and the "floor" smoothing strategy concurrently')

Expand Down Expand Up @@ -73,22 +73,25 @@ def calculate_jitter(delay: int, jitter: int) -> int:


def create_span_pool(synth_config, loop, client) -> None:
for span in synth_config['spans']:
async def worker(delay, span, jitter):
for transaction in synth_config['transactions']:
async def worker(delay, transaction, jitter):
while True:
if jitter:
delay = calculate_jitter(delay, jitter)
client.begin_transaction(transaction_type="script")
await asyncio.sleep(delay / 1000)
client.end_transaction(name=span, result="success")
client.end_transaction(name=transaction, result="success")

span_config = synth_config['spans'][span]
transaction_config = synth_config['transactions'][transaction]
loop.create_task(
worker(span_config['duration'], span, span_config.get('jitter')))
worker(transaction_config['duration'], transaction, transaction_config.get('jitter')))


def create_easter() -> None:
import synthbean.resources.easter
from multiprocessing import Process
p = Process(target=synthbean.resources.easter.easter_time)
p.start()
p1 = Process(target=synthbean.resources.easter.easter_time)
p1.start()

p2 = Process(target=synthbean.resources.easter.easter_show)
p2.start()
23 changes: 23 additions & 0 deletions synthbean/resources/easter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'

import time
import tempfile
import base64
import pygame
import pyglet


def play_music(music_file):
Expand All @@ -17,6 +19,27 @@ def play_music(music_file):
# check if playback has finished
clock.tick(30)

def easter_show():
time.sleep(1)
# pick an animated gif file you have in the working directory
ag_file = "giphy.gif"
animation = pyglet.resource.animation(ag_file)
sprite = pyglet.sprite.Sprite(animation)

# create a window and set it to the image size
win = pyglet.window.Window(width=sprite.width, height=sprite.height)

# set window background color = r, g, b, alpha
# each value goes from 0.0 to 1.0
green = 0, 1, 0, 1
pyglet.gl.glClearColor(*green)

@win.event
def on_draw():
win.clear()
sprite.draw()

pyglet.app.run()

def easter_time():
thunder64 = '''\
Expand Down