Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InfluxDB output mode and add CI for it #16

Merged
merged 1 commit into from
Mar 13, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: pytest -vv
- name: Install Telegraf
run: sudo apt-get install -y telegraf
- name: Test InfluxDB output
run: telegraf --test --config tests/slo.conf
8 changes: 4 additions & 4 deletions backlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def render_influxdb(data):
count = len(result[status]["leadTime"])
if status == "Resolved":
measure = "leadTime"
extra = " leadTime={leadTime} cycleTime={cycleTime}".format(
extra = ",leadTime={leadTime},cycleTime={cycleTime}".format(
leadTime=mean(result[status]["leadTime"]),
cycleTime=mean(result[status]["cycleTime"]),
)
Expand All @@ -187,9 +187,9 @@ def render_influxdb(data):
output.append(
'{measure},team="{team}",status="{status}",title="{title}" count={count}{extra}'.format(
measure=measure,
team=data["team"],
status=status,
title=conf["title"],
team="\\ ".join(data["team"].split(" ")),
status="\\ ".join(status.split(" ")),
title="\\ ".join(conf["title"].split(" ")),
count=count,
extra=extra,
)
Expand Down
5 changes: 5 additions & 0 deletions tests/slo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[inputs.exec]]
commands = [ "env REDMINE_API_KEY=abcdefgah0123456789 ./backlogger.py --output=influxdb" ]
interval = "1h"
timeout = "10s"
data_format = "influx"
4 changes: 2 additions & 2 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_influxdb(self):
self.assertEqual(
backlogger.render_influxdb(data),
[
'slo,team="Awesome Team",status="In Progress",title="Workable Backlog" count=2',
'leadTime,team="Awesome Team",status="Resolved",title="Workable Backlog" count=1 leadTime=383.2547222222222 cycleTime=48.0',
'slo,team="Awesome\\ Team",status="In\\ Progress",title="Workable\\ Backlog" count=2',
'leadTime,team="Awesome\\ Team",status="Resolved",title="Workable\\ Backlog" count=1,leadTime=383.2547222222222,cycleTime=48.0',
],
)