Skip to content

Commit 3650db9

Browse files
Merge pull request #2 from cfabriziohivemq/feat/copilot-metrics
Feat/copilot metrics
2 parents 278ba85 + eb7166d commit 3650db9

File tree

9 files changed

+259
-14088
lines changed

9 files changed

+259
-14088
lines changed

.github/workflow/copilot_metrics_retention.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Copilot Metrics Retention
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
first-job:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Copilot Metrics Retention
15+
uses: ambilykk/copilot-metrics-retention@main
16+
with:
17+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
18+
org_name: 'hivemq'
19+
json_path: 'metrics.json'
20+
21+
- uses: actions/upload-artifact@v4
22+
with:
23+
name: metrics.json
24+
path: 'metrics.json'
25+

.gitignore

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
plugins/
2+
metabase.jar
3+
uploads/
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[codz]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py.cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# UV
101+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
#uv.lock
105+
106+
# poetry
107+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108+
# This is especially recommended for binary packages to ensure reproducibility, and is more
109+
# commonly ignored for libraries.
110+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111+
#poetry.lock
112+
#poetry.toml
113+
114+
# pdm
115+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118+
#pdm.lock
119+
#pdm.toml
120+
.pdm-python
121+
.pdm-build/
122+
123+
# pixi
124+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125+
#pixi.lock
126+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127+
# in the .venv directory. It is recommended not to include this directory in version control.
128+
.pixi
129+
130+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131+
__pypackages__/
132+
133+
# Celery stuff
134+
celerybeat-schedule
135+
celerybeat.pid
136+
137+
# SageMath parsed files
138+
*.sage.py
139+
140+
# Environments
141+
.env
142+
.envrc
143+
.venv
144+
env/
145+
venv/
146+
ENV/
147+
env.bak/
148+
venv.bak/
149+
150+
# Spyder project settings
151+
.spyderproject
152+
.spyproject
153+
154+
# Rope project settings
155+
.ropeproject
156+
157+
# mkdocs documentation
158+
/site
159+
160+
# mypy
161+
.mypy_cache/
162+
.dmypy.json
163+
dmypy.json
164+
165+
# Pyre type checker
166+
.pyre/
167+
168+
# pytype static type analyzer
169+
.pytype/
170+
171+
# Cython debug symbols
172+
cython_debug/
173+
174+
# PyCharm
175+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
176+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
177+
# and can be added to the global gitignore or merged into this file. For a more nuclear
178+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
179+
#.idea/
180+
181+
# Abstra
182+
# Abstra is an AI-powered process automation framework.
183+
# Ignore directories containing user credentials, local state, and settings.
184+
# Learn more at https://abstra.io/docs
185+
.abstra/
186+
187+
# Visual Studio Code
188+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
189+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
190+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
191+
# you could uncomment the following to ignore the entire vscode folder
192+
# .vscode/
193+
194+
# Ruff stuff:
195+
.ruff_cache/
196+
197+
# PyPI configuration file
198+
.pypirc
199+
200+
# Cursor
201+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
202+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
203+
# refer to https://docs.cursor.com/context/ignore-files
204+
.cursorignore
205+
.cursorindexingignore
206+
207+
# Marimo
208+
marimo/_static/
209+
marimo/_lsp/
210+
__marimo__/

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
# Copilot-dashboard
22

33
## Intro
4-
Unfortunately Github only offers 28-day retention for the copilot metrics, this solution gives us the ability to retrieve data and visulasie them via metabase.
4+
GitHub only offers a 28-day retention period for Copilot metrics. This solution enables us to retrieve that data and visualize it using Metabase.
55

66
## Gh action
7-
there is a gh action that retrieves the json file and render it into a unique json. [Ref](*https://github.com/marketplace/actions/copilot-metrics-retention)
7+
A GitHub Action retrieves the JSON metrics and renders them into a single JSON file. [Ref](*https://github.com/marketplace/actions/copilot-metrics-retention)
8+
9+
## Convert the json into SQlite dbfile
10+
Open the terminal into the repo folder and run `python3 app.py`, visit the page `http://127.0.0.1:5000/`, download the json artifact and load the file, click on `Convert & Download SQLite DB`, this will generate a .db file available under the upload folder having the name `copilot_metrics.db`
11+
12+
## Visualite the copilot_metrics.db via metabase
13+
14+
Download the `metabase.jar` [Link](https://downloads.metabase.com/v0.55.2/metabase.jar) and execute
15+
```
16+
java --add-opens java.base/java.nio=ALL-UNNAMED -jar metabase.jar
17+
```
18+
This command will launch a Metabase server on port 3000 by default.
19+
20+
Access to it and complete the fake reistration, once in go to database and select `SQLite` and under path add `upload/copilot_metrics.db`, all data is available on the home page.
21+
22+
Enjoy!
23+
24+
25+
26+
27+
28+

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
app = Flask(__name__)
77
UPLOAD_FOLDER = Path("uploads")
8-
DB_PATH = Path("copilot_metrics.db")
98
UPLOAD_FOLDER.mkdir(exist_ok=True)
9+
DB_PATH = UPLOAD_FOLDER / "copilot_metrics.db"
1010

1111
def create_db(json_data):
1212
conn = sqlite3.connect(DB_PATH)
-4.36 MB
Binary file not shown.

0 commit comments

Comments
 (0)