Skip to content

Dotcom copilot metrics added #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 196 additions & 1 deletion src/cpuad-updater/grafana/dashboard-template.json
Original file line number Diff line number Diff line change
@@ -5694,6 +5694,201 @@
],
"title": "Accept Rate by Lines (%)",
"type": "status-history"
},
{
"datasource": {
"uid": "elasticsearch-total-uid"
},
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 0,
"y": 200
},
"id": 9001,
"options": {
"wideLayout": true
},
"pluginVersion": "11.4.0",
"targets": [
{
"metrics": [
{
"field": "dotcom_chat_total_engaged_users",
"id": "1",
"type": "max"
}
],
"query": "organization_slug: $organization_name",
"refId": "A",
"timeField": "day"
}
],
"title": "GitHub.com Copilot Chat: Total Engaged Users",
"type": "stat"
},
{
"datasource": {
"uid": "elasticsearch-total-uid"
},
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 6,
"y": 200
},
"id": 9002,
"options": {
"wideLayout": true
},
"pluginVersion": "11.4.0",
"targets": [
{
"metrics": [
{
"field": "dotcom_chat_total_chats",
"id": "1",
"type": "sum"
}
],
"query": "organization_slug: $organization_name",
"refId": "A",
"timeField": "day"
}
],
"title": "GitHub.com Copilot Chat: Total Chats",
"type": "stat"
},
{
"datasource": {
"uid": "elasticsearch-total-uid"
},
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 12,
"y": 200
},
"id": 9003,
"options": {
"wideLayout": true
},
"pluginVersion": "11.4.0",
"targets": [
{
"metrics": [
{
"field": "dotcom_pr_total_engaged_users",
"id": "1",
"type": "max"
}
],
"query": "organization_slug: $organization_name",
"refId": "A",
"timeField": "day"
}
],
"title": "GitHub.com Copilot PR: Total Engaged Users",
"type": "stat"
},
{
"datasource": {
"uid": "elasticsearch-total-uid"
},
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 18,
"y": 200
},
"id": 9004,
"options": {
"wideLayout": true
},
"pluginVersion": "11.4.0",
"targets": [
{
"metrics": [
{
"field": "dotcom_pr_total_summaries",
"id": "1",
"type": "sum"
}
],
"query": "organization_slug: $organization_name",
"refId": "A",
"timeField": "day"
}
],
"title": "GitHub.com Copilot PR: Total PR Summaries",
"type": "stat"
},
{
"datasource": {
"uid": "elasticsearch-total-uid"
},
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 206
},
"id": 9005,
"options": {
"showHeader": true
},
"pluginVersion": "11.4.0",
"targets": [
{
"metrics": [],
"query": "organization_slug: $organization_name",
"refId": "A",
"timeField": "day"
}
],
"title": "GitHub.com Copilot PR Breakdown",
"transformations": [
{
"id": "extractFields",
"options": {
"fields": [
"dotcom_pr_breakdown.repository",
"dotcom_pr_breakdown.model",
"dotcom_pr_breakdown.total_pr_summaries_created",
"dotcom_pr_breakdown.model_engaged_users"
]
}
}
],
"type": "table"
}
],
"preload": false,
@@ -5909,4 +6104,4 @@
},
"overwrite": true,
"folderId": 0
}
}
34 changes: 34 additions & 0 deletions src/cpuad-updater/mapping/copilot_usage_total_mapping.json
Original file line number Diff line number Diff line change
@@ -54,6 +54,40 @@
},
"unique_hash" : {
"type" : "keyword"
},
"dotcom_chat_total_engaged_users": {
"type": "long"
},
"dotcom_chat_total_chats": {
"type": "long"
},
"dotcom_chat_breakdown": {
"type": "nested",
"properties": {
"model": { "type": "keyword" },
"is_custom_model": { "type": "boolean" },
"custom_model_training_date": { "type": "date", "format": "yyyy-MM-dd||strict_date_optional_time||epoch_millis" },
"total_engaged_users": { "type": "long" },
"total_chats": { "type": "long" }
}
},
"dotcom_pr_total_engaged_users": {
"type": "long"
},
"dotcom_pr_total_summaries": {
"type": "long"
},
"dotcom_pr_breakdown": {
"type": "nested",
"properties": {
"repository": { "type": "keyword" },
"repo_engaged_users": { "type": "long" },
"model": { "type": "keyword" },
"is_custom_model": { "type": "boolean" },
"custom_model_training_date": { "type": "date", "format": "yyyy-MM-dd||strict_date_optional_time||epoch_millis" },
"total_pr_summaries_created": { "type": "long" },
"model_engaged_users": { "type": "long" }
}
}
}
},
56 changes: 56 additions & 0 deletions src/cpuad-updater/metrics_2_usage_convertor.py
Original file line number Diff line number Diff line change
@@ -103,6 +103,55 @@ def convert_day(metrics_day):

breakdown_chat_list = list(breakdown_chat_dict.values())

# --- Copilot dotcom chat metrics ---
dotcom_chat = metrics_day.get("copilot_dotcom_chat", {})
dotcom_chat_total_engaged_users = dotcom_chat.get("total_engaged_users", 0)
dotcom_chat_total_chats = 0
dotcom_chat_breakdown = []
for model in dotcom_chat.get("models", []):
model_name = model.get("name", "unknown")
is_custom_model = model.get("is_custom_model", False)
custom_model_training_date = model.get("custom_model_training_date")
total_engaged_users = model.get("total_engaged_users", 0)
total_chats = model.get("total_chats", 0)
dotcom_chat_total_chats += total_chats
dotcom_chat_breakdown.append(
{
"model": model_name,
"is_custom_model": is_custom_model,
"custom_model_training_date": custom_model_training_date,
"total_engaged_users": total_engaged_users,
"total_chats": total_chats,
}
)

# --- Copilot dotcom pull request/code review metrics ---
dotcom_pr = metrics_day.get("copilot_dotcom_pull_requests", {})
dotcom_pr_total_engaged_users = dotcom_pr.get("total_engaged_users", 0)
dotcom_pr_total_summaries = 0
dotcom_pr_breakdown = []
for repo in dotcom_pr.get("repositories", []):
repo_name = repo.get("name", "unknown")
repo_engaged_users = repo.get("total_engaged_users", 0)
for model in repo.get("models", []):
model_name = model.get("name", "unknown")
is_custom_model = model.get("is_custom_model", False)
custom_model_training_date = model.get("custom_model_training_date")
total_pr_summaries_created = model.get("total_pr_summaries_created", 0)
model_engaged_users = model.get("total_engaged_users", 0)
dotcom_pr_total_summaries += total_pr_summaries_created
dotcom_pr_breakdown.append(
{
"repository": repo_name,
"repo_engaged_users": repo_engaged_users,
"model": model_name,
"is_custom_model": is_custom_model,
"custom_model_training_date": custom_model_training_date,
"total_pr_summaries_created": total_pr_summaries_created,
"model_engaged_users": model_engaged_users,
}
)

usage = {
"day": day,
"total_suggestions_count": total_suggestions_count,
@@ -117,6 +166,13 @@ def convert_day(metrics_day):
"total_chat_insertion_events": total_chat_insertion_events,
"breakdown": breakdown_list,
"breakdown_chat": breakdown_chat_list,
# --- dotcom metrics ---
"dotcom_chat_total_engaged_users": dotcom_chat_total_engaged_users,
"dotcom_chat_total_chats": dotcom_chat_total_chats,
"dotcom_chat_breakdown": dotcom_chat_breakdown,
"dotcom_pr_total_engaged_users": dotcom_pr_total_engaged_users,
"dotcom_pr_total_summaries": dotcom_pr_total_summaries,
"dotcom_pr_breakdown": dotcom_pr_breakdown,
}
return usage