Collect Haystack metrics #931
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Collect Haystack metrics | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run twice a day, at 2am and 2pm UTC. New data becomes available ~1am https://pypistats.org/faqs | |
- cron: "0 2,14 * * *" | |
push: | |
branches: [main] | |
paths: [".github/workflows/github_metrics.yml"] | |
jobs: | |
github-metrics: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
repo: | |
- deepset-ai/haystack | |
- deepset-ai/haystack-core-integrations | |
- deepset-ai/hayhooks | |
env: | |
GITHUB_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }} | |
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get Github stars | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} stars | |
- name: Get Github clones | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} clones | |
- name: Get Github views | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} views | |
- name: Get Github referrers | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} referrers | |
- name: Get Github forks | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} forks | |
- name: Get Github contributors | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} contributors | |
- name: Get Github open issues | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} open-issues | |
- name: Get Github discussions | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} discussions | |
- name: Get Github discussions | |
working-directory: collector | |
run: hatch run collector github --repo-name ${{ matrix.repo }} size | |
haystack-pypi-metrics: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: | |
- haystack-ai | |
- farm-haystack | |
- llama-index | |
- langchain | |
- hayhooks | |
max-parallel: 1 | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get PyPI downloads | |
id: pypi-downloads | |
working-directory: collector | |
run: | | |
# Add delay between API calls | |
sleep $((RANDOM % 3 + 10)) # Random delay between 10-12 seconds to spread out initial requests | |
last_month=$(hatch run collector pypi downloads ${{ matrix.package }} last_month) | |
sleep 10 # Wait 10 seconds between calls to stay under 30 requests/minute | |
last_week=$(hatch run collector pypi downloads ${{ matrix.package }} last_week) | |
sleep 10 # Wait 10 seconds between calls to stay under 30 requests/minute | |
last_day=$(hatch run collector pypi downloads ${{ matrix.package }} last_day) | |
echo "last_month=$last_month" >> $GITHUB_OUTPUT | |
echo "last_week=$last_week" >> $GITHUB_OUTPUT | |
echo "last_day=$last_day" >> $GITHUB_OUTPUT | |
- name: Send metrics | |
uses: masci/datadog@v1 | |
with: | |
api-key: ${{ secrets.DATADOG_API_KEY }} | |
api-url: https://api.datadoghq.eu | |
metrics: | | |
- type: "count" | |
name: "haystack.pypi.downloads_last_month" | |
value: ${{ steps.pypi-downloads.outputs.last_month }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack" | |
- "type:health" | |
- type: "count" | |
name: "haystack.pypi.downloads_last_week" | |
value: ${{ steps.pypi-downloads.outputs.last_week }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack" | |
- "type:health" | |
- type: "count" | |
name: "haystack.pypi.downloads_last_day" | |
value: ${{ steps.pypi-downloads.outputs.last_day }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack" | |
- "type:health" | |
generate-integrations-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.get-packages.outputs.matrix }} | |
steps: | |
- name: Get package list from README | |
id: get-packages | |
run: | | |
pypi_regex="https:\/\/pypi\.org\/project\/([\w-]+)" | |
readme_url="https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/main/README.md" | |
packages=$(curl -s "$readme_url"| awk '/## Inventory/,0' | grep -Po "$pypi_regex" | awk -F'/' '{print $NF}') | |
matrix=$(echo "$packages" | jq -R -s -c 'split("\n")[:-1] | {packages: .}') | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
integrations-pypi-metrics: | |
needs: generate-integrations-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: ${{ fromJson(needs.generate-integrations-matrix.outputs.matrix).packages }} | |
max-parallel: 2 | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get PyPI downloads | |
id: pypi-downloads | |
working-directory: collector | |
run: | | |
# Add delay between API calls | |
sleep $((RANDOM % 3 + 10)) # Random delay between 10-12 seconds to spread out initial requests | |
last_month=$(hatch run collector pypi downloads ${{ matrix.package }} last_month) | |
sleep 10 # Wait 10 seconds between calls to stay under 30 requests/minute | |
last_week=$(hatch run collector pypi downloads ${{ matrix.package }} last_week) | |
sleep 10 # Wait 10 seconds between calls to stay under 30 requests/minute | |
last_day=$(hatch run collector pypi downloads ${{ matrix.package }} last_day) | |
echo "last_month=$last_month" >> $GITHUB_OUTPUT | |
echo "last_week=$last_week" >> $GITHUB_OUTPUT | |
echo "last_day=$last_day" >> $GITHUB_OUTPUT | |
- name: Send metrics | |
uses: masci/datadog@v1 | |
with: | |
api-key: ${{ secrets.DATADOG_API_KEY }} | |
api-url: https://api.datadoghq.eu | |
metrics: | | |
- type: "count" | |
name: "haystack.pypi.downloads_last_month" | |
value: ${{ steps.pypi-downloads.outputs.last_month }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack-core-integrations" | |
- "type:health" | |
- type: "count" | |
name: "haystack.pypi.downloads_last_week" | |
value: ${{ steps.pypi-downloads.outputs.last_week }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack-core-integrations" | |
- "type:health" | |
- type: "count" | |
name: "haystack.pypi.downloads_last_day" | |
value: ${{ steps.pypi-downloads.outputs.last_day }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:haystack-core-integrations" | |
- "type:health" | |
non-haystack-core-integrations-pypi-metrics: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: | |
- apify-haystack | |
- openinference-instrumentation-haystack | |
- assemblyai-haystack | |
- context-haystack | |
- couchbase-haystack | |
- deepl-haystack | |
- docling-haystack | |
- duckduckgo-api-haystack | |
- elevenlabs-haystack | |
- lancedb-haystack | |
- marqo-haystack | |
- mastodon-fetcher-haystack | |
- milvus-haystack | |
- mixedbread-ai-haystack | |
- needle-haystack-ai | |
- neo4j-haystack | |
- notion-haystack | |
- takeoff-haystack | |
- vllm-haystack | |
- voyage-embedders-haystack | |
max-parallel: 2 | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get PyPI downloads | |
id: pypi-downloads | |
working-directory: collector | |
run: | | |
# Add delay between API calls | |
sleep $((RANDOM % 3 + 10)) # Random delay between 10-12 seconds to spread out initial requests | |
last_month=$(hatch run collector pypi downloads ${{ matrix.package }} last_month) | |
echo "last_month=$last_month" >> $GITHUB_OUTPUT | |
- name: Send metrics | |
uses: masci/datadog@v1 | |
with: | |
api-key: ${{ secrets.DATADOG_API_KEY }} | |
api-url: https://api.datadoghq.eu | |
metrics: | | |
- type: "count" | |
name: "haystack.pypi.downloads_last_month" | |
value: ${{ steps.pypi-downloads.outputs.last_month }} | |
host: ${{ matrix.package }} | |
tags: | |
- "project:non-haystack-core-integrations" | |
- "type:health" | |
twitter-metrics: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
username: | |
- Haystack_AI | |
- llama_index | |
- LangChainAI | |
env: | |
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get Twitter follower count | |
working-directory: collector | |
run: hatch run collector twitter --username ${{ matrix.username }} followers | |
docker-metrics: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
repo: | |
- deepset/haystack | |
- deepset/hayhooks | |
env: | |
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Get docker pulls | |
working-directory: collector | |
run: hatch run collector docker --repo-name ${{ matrix.repo }} pulls |