incubator-devlake icon indicating copy to clipboard operation
incubator-devlake copied to clipboard

[Question][GitHub] How to create a new metric using PR description extraction

Open KunalKatariya opened this issue 9 months ago • 5 comments

Question

We are enforcing "AI Usage" stats to be present in PR description. Example of stats:

AI Usage:

  1. AI lines: 20
  2. Human lines: 80

I would like to create a new metric by extracting this information from PR descriptions and display. How can I achieve this?

Screenshots

If applicable, add screenshots to help explain.

Additional context

Add any other context here.

KunalKatariya avatar Feb 10 '26 08:02 KunalKatariya

You can extract "AI Usage" stats from PR descriptions and display them as a new metric in DevLake by following these steps:

  1. Add custom fields: Use the customize plugin/service to create new columns (e.g., x_ai_lines, x_human_lines) in the relevant PR metrics table. This is supported by the backend service, which manages dynamic schema changes for custom metrics "customize plugin service".

  2. Extract values from PR descriptions: Implement a parser (typically using regex) in your data ingestion pipeline or as a plugin extension to extract the "AI lines" and "Human lines" values from the PR description and populate the custom fields during ingestion. The project settings UI and linker plugin show how regex-based extraction from PR descriptions is supported for other use cases "project settings UI".

  3. Store and access the metrics: Once extracted, these values are stored in your database and can be queried like any other metric. DevLake recommends creating a dedicated table per data stream for new metrics, following naming and indexing conventions "plugin/table conventions".

  4. Visualize in dashboards: After the data is collected, you can create or modify Grafana dashboard panels to visualize your new metrics. All data is stored in MySQL, and you can use custom SQL queries in Grafana to aggregate and display the extracted "AI Usage" stats "custom dashboards" "dashboard SQL example".

This approach lets you track and visualize "AI lines" and "Human lines" from PR descriptions alongside your other engineering metrics.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about incubator-devlake Share Dosu with your team

dosubot[bot] avatar Feb 10 '26 08:02 dosubot[bot]

I think you could write your own plugin for your purpose—check out the DORA plugin; it does something similar.

klesh avatar Feb 12 '26 14:02 klesh

@klesh thank you for your answer. I will try out the suggestion you mentioned.

KunalKatariya avatar Feb 13 '26 02:02 KunalKatariya

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar Apr 15 '26 00:04 github-actions[bot]

This issue has been closed because it has been inactive for a long time. You can reopen it if you encounter the similar problem in the future.

github-actions[bot] avatar Apr 23 '26 00:04 github-actions[bot]