The telemetry data available in CodeStream is contextual, meaning that it's all related to the code you have open in your IDE. To do this, CodeStream needs to know what services in New Relic are built from the repositories you have open in your IDE. CodeStream will prompt you to select a service to associate with the repository you currently have open in your IDE.
In some cases your repository may need to be associated with multiple services. For example, you might have different services that represent different environments (like production, or staging) and they may all be associated with the same repository. To associate the current repository with an additional service, click on Add another service.
Making these associations on the fly when prompted is a great way to get started, but we recommend one of the following methods because they require less ongoing manual effort and eliminate the possibility of end-user mistakes, such as misconfigured remote URLs.
Set the environment variable NEW_RELIC_METADATA_REPOSITORY_URL. New Relic agents create the repository entity and associate it with your application entity automatically.
This requires the SSH or HTTPS remote URL format. We recommend that this be set as part of your build pipeline.
Go to the APM summary page via one.newrelic.com > All capabilities > APM & Services > (select an app), then look click on the ellipses menu to the right of the service name. Click on the Repositories tab to connect a repository.
Click Connect repository to find an existing repository or add a new one.
Use New Relic's NerdGraph APIs to create a repository and associate it with your application entities.
Step 1: Create a repository entity
To create a repository entity, use the referenceEntityCreateOrUpdateRepository API and make sure to save the GUID that's produced. The API takes the following parameters:
accountId - the integer account ID for the account you want to add the repository to
url - example https://github.com/newrelic/beta-docs-site.git
To find the entity you create, you can use a query like the following. Note that the URL you provided to referenceEntityCreateOrUpdateRepository gets saved as an entity tag.
{
actor{
entitySearch(query:"name = 'a name' OR tags.url = 'a url'"){
count
query
results{
entities{
guid
name
tags{
key
values
}
}
}
}
}
}
Step 2: Associate the repository entity to your application entity
First, find the GUID for the application you want to associate your repository to.
Parameters:
sourceEntityGuid - the entity GUID of the application
targetEntityGuid - the entity GUID of your repository
type - always BUILT_FROM
mutation{
entityRelationshipUserDefinedCreateOrReplace(
sourceEntityGuid:""
targetEntityGuid:""
type:BUILT_FROM
){
errors{
message
type
}
}
}
To see all entities related to your repository you can do a query like this:
With any of these methods you can specify the remote URL in either the SSH or HTTPS format:
git@github.com:newrelic/beta-docs-site.git
https://github.com/newrelic/beta-docs-site.git
Advertencia
It's possible to add the same repository more than once, if you're using different protocols to do so. The UI warns you about this, but won't prevent you from doing so.
For example, https://github.com/tuna/repo and git@github.com:tuna/repo are the same repo, with different protocols.