Skip to main content

Check out Port for yourselfย 

GitHub Copilot

Port's Github Copilot integration allows you to ingest your Github Copilot usage metrics into your software catalog.

Supported aggregation hierarchiesโ€‹

Some aggregation hierarchies of Github Copilot usage metrics can be ingested into Port, they are listed below.
It is possible to reference any field that appears in the API responses linked below in the mapping configuration.

Setupโ€‹

Choose one of the following installation methods:

Using this installation option means that the integration will be hosted by Port, with a customizable resync interval to ingest data into Port.

Live event support

Currently, live events are not supported for this integration.
Resyncs will be performed periodically (with a configurable interval), or manually triggered by you via Port's UI.

Therefore, real-time events (including GitOps) will not be ingested into Port immediately.
Live events support for this integration is WIP and will be supported in the near future.

Self-hosted installation

Alternatively, you can install the integration using the Real-time (self-hosted) method to update Port in real time using webhooks.

Installation

To install, follow these steps:

  1. Go to the Data sources page of your portal.

  2. Click on the + Data source button in the top-right corner.

  3. Click on the relevant integration in the list.

  4. Under Select your installation method, choose Hosted by Port.

  5. Configure the integration settings and application settings as you wish (see below for details).

Application settings

Every integration hosted by Port has the following customizable application settings, which are configurable after installation:

  • Resync interval: The frequency at which Port will ingest data from the integration. There are various options available, ranging from every 1 hour to once a day.

  • Send raw data examples: A boolean toggle (enabled by default). If enabled, raw data examples will be sent from the integration to Port. These examples are used when testing your mapping configuration, they allow you to run your jq expressions against real data and see the results.

Integration settings

Every integration has its own tool-specific settings, under the Integration settings section.
Each of these settings has an โ“˜ icon next to it, which you can hover over to see a description of the setting.

Port secrets

Some integration settings require sensitive pieces of data, such as tokens.
For these settings, Port secrets will be used, ensuring that your sensitive data is encrypted and secure.

When filling in such a setting, its value will be obscured (shown as โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข).
For each such setting, Port will automatically create a secret in your organization.

To see all secrets in your organization, follow these steps.

Limitations

  • The maximum time for a full sync to run is based on the configured resync interval. For very large amounts of data where a resync operation is expected to take longer, please use a longer interval.

Port source IP addresses

When using this installation method, Port will make outbound calls to your 3rd-party applications from static IP addresses.
You may need to add these addresses to your allowlist, in order to allow Port to interact with the integrated service:

54.73.167.226  
63.33.143.237
54.76.185.219

Configurationโ€‹

Port integrations use a YAML mapping block to ingest data from the third-party api into Port.

The mapping makes use of the JQ JSON processor to select, modify, concatenate, transform and perform other operations on existing fields and values from the integration API.

Permissionsโ€‹

Port's Github Copilot integration requires a classic Github token with at least one of the following scopes to be enabled:

  • manage_billing:copilot.
  • read:org.
  • read:enterprise.

Examplesโ€‹

To view and test the integration's mapping against examples of the third-party API responses, use the jq playground in your data sources page.
Find the integration in the list of data sources and click on it to open the playground.

Additional examples of blueprints and the relevant integration configurations:

GitHub Copilot Usage Blueprint
{
"identifier": "github_copilot_usage",
"title": "GitHub Copilot Usage",
"icon": "Github",
"schema": {
"properties": {
"record_date": {
"type": "string",
"title": "Record Date",
"format": "date-time"
},
"breakdown": {
"type": "object",
"title": "Breakdown"
},
"total_suggestions_count": {
"type": "number",
"title": "Total Suggestions Count"
},
"total_acceptances_count": {
"type": "number",
"title": "Total Acceptances Count"
},
"total_lines_suggested": {
"type": "number",
"title": "Total Lines Suggested"
},
"total_lines_accepted": {
"type": "number",
"title": "Total Lines Accepted"
},
"total_active_users": {
"type": "number",
"title": "Total Active Users"
},
"total_chat_acceptances": {
"type": "number",
"title": "Total Chat Acceptances"
},
"total_chat_turns": {
"type": "number",
"title": "Total Chat Turns"
},
"total_active_chat_users": {
"type": "number",
"title": "Total Active Chat Users"
},
"git_hub_org": {
"type": "string",
"title": "GitHub Org"
},
"git_hub_team": {
"type": "string",
"title": "GitHub Team"
}
},
"required": []
},
"calculationProperties": {
"acceptance_rate": {
"title": "Acceptance Rate",
"icon": "DefaultProperty",
"calculation": "if (.properties.total_suggestions_count == 0) then 0 else ((.properties.total_acceptances_count / .properties.total_suggestions_count) * 100 | round) end",
"type": "number"
}
},
"relations": {}
}

Team hierarchy metricsโ€‹

Integration configuration
entityDeletionThreshold: 0
resources:
- kind: copilot-team-metrics
selector:
query: 'true'
port:
entity:
mappings:
identifier: (.__team.slug + "@" + .date)
title: (.__team.slug + " copilot-metrics " + .date)
blueprint: '"github_copilot_usage"'
properties:
record_date: .date + "T00:00:00Z"
breakdown: .
total_suggestions_count: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_suggestions]
| map(select(. != null) ) | add
total_acceptances_count: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_acceptances]
| map(select(. != null)) | add
total_lines_suggested: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_lines_suggested]
| map(select(. != null)) | add
total_lines_accepted: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_lines_accepted]
| map(select(. != null)) | add
total_active_users: .total_active_users
total_chat_acceptances: >-
[
(.copilot_ide_chat.editors[]?.models[]?.total_chat_copy_events // 0),
(.copilot_ide_chat.editors[]?.models[]?.total_chat_insertion_events // 0)
]
| map(select(. != null)) | add
total_chat_turns: >-
[.copilot_ide_chat.editors[]?.models[]?.total_chats // 0]
| map(select(. != null)) | add
total_active_chat_users: >-
[.copilot_ide_chat.editors[]?.total_engaged_users // 0]
| map(select(. != null)) | add
git_hub_org: .__organization.login
git_hub_team: .__team.slug

Organization hierarchy metricsโ€‹

Integration configuration
entityDeletionThreshold: 0
resources:
- kind: copilot-organization-metrics
selector:
query: 'true'
port:
entity:
mappings:
identifier: (.__organization.login + "@" + .date)
title: (.__organization.login + " copilot-metrics " + .date)
blueprint: '"github_copilot_usage"'
properties:
record_date: .date + "T00:00:00Z"
breakdown: .
total_suggestions_count: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_suggestions]
| map(select(. != null) ) | add
total_acceptances_count: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_acceptances]
| map(select(. != null)) | add
total_lines_suggested: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_lines_suggested]
| map(select(. != null)) | add
total_lines_accepted: >-
[.copilot_ide_code_completions.editors[]?.models[]?.languages[]?.total_code_lines_accepted]
| map(select(. != null)) | add
total_active_users: .total_active_users
total_chat_acceptances: >-
[
(.copilot_ide_chat.editors[]?.models[]?.total_chat_copy_events // 0),
(.copilot_ide_chat.editors[]?.models[]?.total_chat_insertion_events // 0)
]
| map(select(. != null)) | add
total_chat_turns: >-
[.copilot_ide_chat.editors[]?.models[]?.total_chats // 0]
| map(select(. != null)) | add
total_active_chat_users: >-
[.copilot_ide_chat.editors[]?.total_engaged_users // 0]
| map(select(. != null)) | add
git_hub_org: .__organization.login