Get Metrics About Your Project
tip
Once you're project is indexed, you can get metrics about your project using
pyoso. It's always safer to query on the project_id field rather than the name or display_name fields.
Find Your project_id
You can lookup your project's project_id using SQL:
query = """
SELECT
project_id,
project_name,
display_name,
description
FROM projects_v1
WHERE project_name = 'opensource-observer'
"""
df = client.to_pandas(query)
In the case of opensource-observer, we get back the following:
{
"projectId": "UuWbpo5bpL5QsYvlukUWNm2uE8HFjxQxzCM0e+HMZfk=",
"projectName": "opensource-observer",
"displayName": "Open Source Observer",
"description": "Open Source Observer is a free analytics suite that helps funders measure the impact of open source software contributions to the health of their ecosystem."
}
Browse Available Metrics
OSO maintains a directory of available metrics in metrics_v0.
To see all available metrics, you can run the following query:
query = """
SELECT
metric_id,
metric_name,
display_name,
description
FROM metrics_v0
"""
df = client.to_pandas(query)
In the case of daily GitHub commits, we get back the following:
{
"metricId": "0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE=",
"metricName": "GITHUB_commits_daily",
"displayName": "GitHub commits daily",
"description": "..."
},
Get a Single Metric Value
For any particular metric, you can get a current value (e.g. to display on a website):
query = """
SELECT
metric_id,
project_id,
amount
FROM key_metrics_by_project_v0
WHERE project_id = 'UuWbpo5bpL5QsYvlukUWNm2uE8HFjxQxzCM0e+HMZfk='
AND metric_id = '1zNSDLeL7d1bqMgJ4b/AGBd0lQs4Q4Wy9jIf2ge72kw='
"""
df = client.to_pandas(query)
In the case of daily GitHub commits, we get back the following:
{
"projectId": "UuWbpo5bpL5QsYvlukUWNm2uE8HFjxQxzCM0e+HMZfk=",
"metricId": "1zNSDLeL7d1bqMgJ4b/AGBd0lQs4Q4Wy9jIf2ge72kw=",
"amount": 2930
},
Timeseries Metrics
OSO also maintains a standard set of timeseries metrics for each project (e.g. to power graphs):
query = """
SELECT
tm.project_id,
tm.sample_date,
tm.amount,
tm.unit,
m.metric_name
FROM timeseries_metrics_by_project_v0 tm
JOIN metrics_v0 m ON tm.metric_id = m.metric_id
WHERE tm.project_id = 'UuWbpo5bpL5QsYvlukUWNm2uE8HFjxQxzCM0e+HMZfk='
AND tm.metric_id = '0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE='
ORDER BY tm.sample_date ASC
"""
df = client.to_pandas(query)