Get Metrics About Your Project
Once you're project is indexed, you can get metrics about your project using our GraphQL API or directly from BigQuery. 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 either BigQuery or our GraphQL API:
- SQL
- GraphQL
select
project_id,
project_name,
display_name,
description
from `oso_production.projects_v1`
where project_name = 'opensource-observer'
query findProject {
oso_projectsV1(
where: { projectName: { _eq: "opensource-observer" } }
) {
projectId
projectName
displayName
description
}
}
In the case of opensource-observer
, we get back the following:
{
"projectId": "Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc=",
"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:
- SQL
- GraphQL
select
metric_id,
metric_name,
display_name,
description
from `oso_production.metrics_v0`;
query getMetrics {
oso_metricsV0 {
metricId
metricName
displayName
description
}
}
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):
- SQL
- GraphQL
select
metric_id,
project_id,
amount
from `oso_production.key_metrics_by_project_v0`
where project_id = 'Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc='
and metric_id = '0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE='
query getKeyMetrics {
oso_keyMetricsByProjectV0(
where: {
projectId: { _eq: "Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc=" },
metricId: { _eq: "0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE=" }
}
) {
metricId,
projectId,
amount,
}
}
In the case of daily GitHub commits, we get back the following:
{
"projectId": "Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc=",
"metricId": "0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE=",
"amount": 20
},
Timeseries Metrics
OSO also maintains a standard set of timeseries metrics for each project (e.g. to power graphs):
- SQL
- GraphQL
select
tm.project_id,
tm.sample_date,
tm.amount,
tm.unit
m.metric_name,
from `oso_production.timeseries_metrics_by_project_v0` tm
join `oso_production.metrics_v0` m on tm.metric_id = m.metric_id
where tm.project_id = 'Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc='
and tm.metric_id = '0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE='
query getTimeseriesMetrics {
oso_timeseriesMetricsByProjectV0(
where: {
projectId: { _eq: "Erx9J64anc8oSeN-wDKm0sojJf8ONrFVYbQ7GFnqSyc=" },
metricId: { _eq: "0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE=" }
}
) {
projectId,
metricId,
sampleDate,
amount,
unit
}
}