Skip to content

Commit 72da319

Browse files
authored
Make statistics by class (#1328)
1 parent a208ceb commit 72da319

18 files changed

+789
-704
lines changed

.github/workflows/collect-statistics.yml

Lines changed: 44 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
default: '1'
1010
type: string
1111
run_number:
12-
description: 'Number of run tries per runner'
12+
description: 'Number of run tries per runner (values greater than 1 are not supported with grafana)'
1313
required: false
1414
default: '1'
1515
type: string
@@ -18,8 +18,13 @@ on:
1818
required: false
1919
default: manual-run
2020
type: string
21-
aggregate:
22-
description: 'Aggregate data'
21+
push_results:
22+
description: 'Push metrics into github'
23+
required: false
24+
default: false
25+
type: boolean
26+
send_to_grafana:
27+
description: 'Send metrics to grafana'
2328
required: false
2429
default: false
2530
type: boolean
@@ -32,7 +37,7 @@ on:
3237
default: '1'
3338
type: string
3439
run_number:
35-
description: 'Number of run tries per runner'
40+
description: 'Number of run tries per runner (values greater than 1 are not supported with grafana)'
3641
required: false
3742
default: '1'
3843
type: string
@@ -41,17 +46,20 @@ on:
4146
required: false
4247
default: manual-run
4348
type: string
44-
aggregate:
45-
description: 'Aggregate data'
49+
push_results:
50+
description: 'Push metrics into github'
51+
required: false
52+
default: false
53+
type: boolean
54+
send_to_grafana:
55+
description: 'Send metrics to grafana'
4656
required: false
4757
default: false
4858
type: boolean
4959

5060
env:
5161
data_branch: monitoring-data
5262
data_path: monitoring/data
53-
aggregated_data_branch: monitoring-aggregated-data
54-
aggregated_data_path: monitoring/aggregated_data
5563
monitoring_properties: monitoring/monitoring.properties
5664
push_script: monitoring/push_with_rebase.sh
5765

@@ -65,7 +73,7 @@ jobs:
6573
id: set-matrix
6674
run: |
6775
arr=$(echo [$(seq -s , ${{ inputs.runners }})])
68-
echo "::set-output name=matrix::$arr"
76+
echo "matrix=$arr" >> $GITHUB_OUTPUT
6977
echo $arr
7078
7179
build_and_collect_statistics:
@@ -112,27 +120,31 @@ jobs:
112120
- name: Get current date
113121
id: date
114122
run: |
115-
echo "::set-output name=date::$(date +'%Y-%m-%d')"
116-
echo "::set-output name=timestamp::$(date +%s)"
117-
echo "::set-output name=last_month::$(date --date='last month' +%s)"
123+
echo "date=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
124+
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
125+
echo "last_month=$(date --date='last month' +%s)" >> $GITHUB_OUTPUT
118126
119127
- name: Get metadata
120128
id: metadata
121129
run: |
122-
echo "::set-output name=commit::$(git rev-parse HEAD)"
123-
echo "::set-output name=short_commit::$(git rev-parse --short HEAD)"
124-
echo "::set-output name=branch::$(git name-rev --name-only HEAD)"
125-
echo "::set-output name=build::$(date +'%Y.%-m')"
130+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
131+
echo "short_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
132+
echo "branch=$(git name-rev --name-only HEAD)" >> $GITHUB_OUTPUT
133+
echo "build=$(date +'%Y.%-m')" >> $GITHUB_OUTPUT
126134
127135
- name: Insert metadata
136+
id: insert
128137
shell: bash
129138
run: |
130-
OUT_FILE="$data_path/data-$branch-$date-$timestamp-$short_commit-${{ matrix.value }}.json"
139+
OUT_FILE="$data_path/$date-$branch-$short_commit-${{ matrix.value }}.json"
140+
echo "output=$OUT_FILE" >> $GITHUB_OUTPUT
141+
131142
INPUTS=($(seq ${{ inputs.run_number }}))
132143
INPUTS=(${INPUTS[@]/#/stats-})
133144
INPUTS=(${INPUTS[@]/%/.json})
134145
INPUTS=${INPUTS[@]}
135146
echo $INPUTS
147+
136148
python monitoring/insert_metadata.py \
137149
--stats_file $INPUTS \
138150
--output_file "$OUT_FILE" \
@@ -151,7 +163,14 @@ jobs:
151163
build: ${{ steps.metadata.outputs.build }}
152164
run_id: ${{ github.run_id }}-${{ matrix.value }}
153165

166+
- name: Upload statistics
167+
uses: actions/upload-artifact@v3
168+
with:
169+
name: statistics-${{ matrix.value }}
170+
path: ${{ steps.insert.outputs.output }}
171+
154172
- name: Commit and push statistics
173+
if: ${{ inputs.push_results }}
155174
run: |
156175
chmod +x $push_script
157176
./$push_script
@@ -161,63 +180,17 @@ jobs:
161180
message: ${{ inputs.message_prefix }}-${{ steps.date.outputs.date }}
162181
github_token: ${{ secrets.GITHUB_TOKEN }}
163182

183+
- name: Send metrics to grafana
184+
if: ${{ inputs.send_to_grafana }}
185+
run: |
186+
python monitoring/prepare_metrics.py --stats_file $stats_file --output_file grafana_metrics.json
187+
echo "TODO send metrics to grafana"
188+
env:
189+
stats_file: ${{ steps.insert.outputs.output }}
190+
164191
- name: Upload logs
165192
if: ${{ always() }}
166193
uses: actions/upload-artifact@v3
167194
with:
168195
name: logs-${{ matrix.value }}
169196
path: logs/
170-
171-
aggregate:
172-
needs: build_and_collect_statistics
173-
if: ${{ inputs.aggregate }}
174-
runs-on: ubuntu-latest
175-
steps:
176-
- name: Checkout repository
177-
uses: actions/checkout@v3
178-
179-
- name: Checkout monitoring data
180-
uses: actions/checkout@v3
181-
with:
182-
ref: ${{ env.data_branch }}
183-
path: ${{ env.data_path }}
184-
185-
- name: Checkout aggregated monitoring data
186-
uses: actions/checkout@v3
187-
with:
188-
ref: ${{ env.aggregated_data_branch }}
189-
path: ${{ env.aggregated_data_path }}
190-
191-
- uses: actions/setup-python@v4
192-
with:
193-
python-version: '3.9'
194-
195-
- name: Get current date
196-
id: date
197-
run: |
198-
echo "::set-output name=date::$(date +'%Y-%m-%d')"
199-
echo "::set-output name=timestamp::$(date +%s)"
200-
echo "::set-output name=last_month::$(date --date='last month' +%s)"
201-
202-
- name: Build aggregated data (last month)
203-
run: |
204-
OUT_FILE=$aggregated_data_path/aggregated-data-$date.json
205-
python monitoring/build_aggregated_data.py \
206-
--input_data_dir $data_path \
207-
--output_file $OUT_FILE \
208-
--timestamp_from $timestamp_from \
209-
--timestamp_to $timestamp
210-
env:
211-
date: ${{ steps.date.outputs.date }}
212-
timestamp: ${{ steps.date.outputs.timestamp }}
213-
timestamp_from: ${{ steps.date.outputs.last_month }}
214-
215-
- name: Commit and push aggregated statistics
216-
run: |
217-
chmod +x $push_script
218-
./$push_script
219-
env:
220-
target_branch: ${{ env.aggregated_data_branch }}
221-
target_directory: ${{ env.aggregated_data_path }}
222-
message: ${{ inputs.message_prefix }}-${{ steps.date.outputs.date }}
223-
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/night-statistics-monitoring.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ jobs:
1212
runners: 3
1313
run_number: 1
1414
message_prefix: night-monitoring
15-
aggregate: true
15+
push_results: true
16+
send_to_grafana: true

0 commit comments

Comments
 (0)