Skip to content

Commit

Permalink
Merge branch 'main' into other/opensearch
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffinito authored Jan 21, 2025
2 parents 1952939 + 0ea3cee commit eb1cf48
Show file tree
Hide file tree
Showing 75 changed files with 2,527 additions and 286 deletions.
5 changes: 5 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
When generating new source code files, always include the copyright header.

When writing unit tests, always use modern NUnit assertions.

We use JustMock.Lite, so use only mock configurations that are valid for that package.
1 change: 1 addition & 0 deletions .github/workflows/all_solutions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ jobs:
AwsLambda.Sns,
AwsLambda.Sqs,
AwsLambda.WebRequest,
AwsSdk,
AzureFunction,
BasicInstrumentation,
CatInbound,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_buildtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Add msbuild to PATH (required for MsiInstaller build)
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/build_profiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
- "feature/**"
paths-ignore:
- ".github/**" # skip changes to the .github folder (workflows, etc.)

# needs to run on every push to main to keep CodeCov in sync
push:
branches:
- main
paths-ignore:
- ".github/**" # skip changes to the .github folder (workflows, etc.)

# this workflow can be called from another workflow
workflow_call:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/post_deploy_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,26 @@ jobs:
env:
BUILD_PATH: ${{ github.workspace }}/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj
PUBLISH_PATH: ${{ github.workspace }}/publish

release-tags:
name: Create release tags
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- name: Create release tags for Lambda and K8s Init Containers
run: |
RELEASE_TITLE="New Relic .NET Agent ${AGENT_VERSION}.0"
RELEASE_TAG="${AGENT_VERSION}.0_dotnet"
RELEASE_NOTES="Automated release for [.NET Agent ${AGENT_VERSION}](https://github.com/newrelic/newrelic-dotnet-agent/releases/tag/${AGENT_VERSION})"
gh auth login --with-token <<< $GH_RELEASE_TOKEN
echo "newrelic/newrelic-lambda-layers - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}"
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-lambda-layers --notes=${RELEASE_NOTES}
echo "newrelic/newrelic-agent-init-container - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}"
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-agent-init-container --notes=${RELEASE_NOTES}
env:
GH_RELEASE_TOKEN: ${{ secrets.DOTNET_AGENT_GH_TOKEN }}
AGENT_VERSION: "v${{ inputs.agent_version }}"
5 changes: 5 additions & 0 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches:
- main
- "feature/**"

# needs to run on every push to main to keep CodeCov in sync
push:
branches:
- main

workflow_dispatch: # allows for manual trigger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static async Task<List<string>> UpdatePackageReferences(string csprojPath

foreach (var package in matchingPackages)
{
if (package.VersionAsVersion < versionData.NewVersionAsVersion && package.Pin)
if (package.VersionAsVersion < versionData.NewVersionAsVersion && !string.IsNullOrEmpty(versionData.IgnoreTfMs) && versionData.IgnoreTfMs.Split(",").Contains(package.TargetFramework))
{
Log.Warning($"Not updating {package.Include} for {package.TargetFramework}, it is pinned to {package.Version}. Manual verification recommended.");
Log.Warning($"Not updating {package.Include} for {package.TargetFramework}, this TFM is ignored. Manual verification recommended.");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ public class NugetVersionData
public Version NewVersionAsVersion { get; set; }
public string Url { get; set; }
public DateTime PublishDate { get; set; }
public string IgnoreTfMs { get; }

public NugetVersionData(string packageName, string oldVersion, string newVersion, string url, DateTime publishDate)
public NugetVersionData(string packageName, string oldVersion, string newVersion, string url,
DateTime publishDate, string ignoreTfMs)
{
PackageName = packageName;
OldVersion = oldVersion;
NewVersion = newVersion;
NewVersionAsVersion = new Version(newVersion);
Url = url;
PublishDate = publishDate;
IgnoreTfMs = ignoreTfMs;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public class PackageInfo
public bool IgnoreMajor { get; set; }
[JsonPropertyName("ignoreReason")]
public string IgnoreReason {get; set;}
[JsonPropertyName("ignoreTFMs")]
public string IgnoreTFMs { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

Expand Down Expand Up @@ -33,8 +33,5 @@ public string TargetFramework
return match.Success ? match.Value : null;
}
}

[XmlAttribute]
public bool Pin { get; set; }
}
}
19 changes: 13 additions & 6 deletions .github/workflows/scripts/nugetSlackNotifications/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static async Task CheckPackage(PackageInfo package, PackageMetadataResource meta
var previousVersionDescription = previous?.Identity.Version.ToNormalizedString() ?? "Unknown";
var latestVersionDescription = latest.Identity.Version.ToNormalizedString();
Log.Information($"Package {packageName} was updated from {previousVersionDescription} to {latestVersionDescription}.");
_newVersions.Add(new NugetVersionData(packageName, previousVersionDescription, latestVersionDescription, latest.PackageDetailsUrl.ToString(), latest.Published.Value.Date));
_newVersions.Add(new NugetVersionData(packageName, previousVersionDescription, latestVersionDescription, latest.PackageDetailsUrl.ToString(), latest.Published.Value.Date, package.IgnoreTFMs));
}
else
{
Expand Down Expand Up @@ -238,11 +238,15 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
var tokenAuth = new Credentials(_githubToken);
ghClient.Credentials = tokenAuth;

// create a new branch
var masterReference = await ghClient.Git.Reference.Get(Owner, Repo, "heads/main");
var branchName = $"dotty/test-updates-{DateTime.Now.ToString("yyyy-MMM-dd")}";
var newBranch = new NewReference($"refs/heads/{branchName}", masterReference.Object.Sha);
await ghClient.Git.Reference.Create(Owner, Repo, newBranch);
var latestCommit = await ghClient.Git.Commit.Get(Owner, Repo, masterReference.Object.Sha);
var newBranchRef = await ghClient.Git.Reference.Create(Owner, Repo, newBranch);
Log.Information($"Successfully created {branchName} branch.");

// commit changes to the newly created branch
var latestCommit = await ghClient.Git.Commit.Get(Owner, Repo, newBranchRef.Object.Sha);
var nt = new NewTree { BaseTree = latestCommit.Tree.Sha };
foreach (var projectInfo in projectInfos)
{
Expand All @@ -255,12 +259,15 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
Content = string.Join('\n', await File.ReadAllLinesAsync(Path.Combine(_searchRootPath, projectInfo.ProjectFile)))
});
}

var commitMessage = "test: Dotty instrumentation library updates for " + DateTime.Now.ToString("yyyy-MMM-dd");
Log.Information($"Successfully created {branchName} branch.");
var newTree = await ghClient.Git.Tree.Create(Owner, Repo, nt);
var newCommit = new NewCommit(commitMessage, newTree.Sha, newBranchRef.Object.Sha);
var commit = await ghClient.Git.Commit.Create(Owner, Repo, newCommit);
await ghClient.Git.Reference.Update(Owner, Repo, $"heads/{branchName}", new ReferenceUpdate(commit.Sha));

// create PR
var newPr = new NewPullRequest(commitMessage, branchName, "main");
newPr.Body = "Dotty updated the following for your convenience.\n\n" + updateLog + "\n\n**Don't forget to update the .NET Compatibility docs:docs: with the new versions!**\n";
newPr.Body = "Dotty updated the following for your convenience.\n\n" + updateLog + "\n\n**Don't forget to update the .NET Compatibility docs:memo: with the new versions!**\n";
var pullRequest = await ghClient.PullRequest.Create(Owner, Repo, newPr);
Log.Information($"Successfully created PR for {branchName} at {pullRequest.HtmlUrl}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@
"packageName": "nlog.extensions.logging"
},
{
"packageName": "nservicebus"
"packageName": "nservicebus",
"ignoreTFMs": "net481",
"ignoreReason": "net481 doesn't support v9.x"
},
{
"packageName": "orcacle.manageddataaccess"
"packageName": "oracle.manageddataaccess"
},
{
"packageName": "orcacle.manageddataaccess.core"
"packageName": "oracle.manageddataaccess.core"
},
{
"packageName": "rabbitmq.client",
Expand Down
1 change: 1 addition & 0 deletions FullAgent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Home", "src\Agent\NewRelic\
{4F5D77F3-B41A-44A7-AF10-2D5462CE0162} = {4F5D77F3-B41A-44A7-AF10-2D5462CE0162}
{570429FD-C785-4673-82DF-643D06B6DC53} = {570429FD-C785-4673-82DF-643D06B6DC53}
{5BBEEC11-B753-4631-BCDD-43BE73B5CCAC} = {5BBEEC11-B753-4631-BCDD-43BE73B5CCAC}
{5D74E5C5-9BA3-423B-86F7-14C2D1A14661} = {5D74E5C5-9BA3-423B-86F7-14C2D1A14661}
{614988AD-7C73-4E71-8F95-520D5F485984} = {614988AD-7C73-4E71-8F95-520D5F485984}
{64C7F267-5185-4AB7-9EB5-0183D8BB0171} = {64C7F267-5185-4AB7-9EB5-0183D8BB0171}
{686AE051-BC8C-4AEC-803D-237AEB807CA9} = {686AE051-BC8C-4AEC-803D-237AEB807CA9}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ private void CollectOneTimeMetrics()
ReportIfLoggingDisabled();
ReportIfInstrumentationIsDisabled();
ReportIfGCSamplerV2IsEnabled();
ReportIfAwsAccountIdProvided();
}

public void CollectMetrics()
Expand Down Expand Up @@ -847,8 +848,14 @@ private void ReportIfGCSamplerV2IsEnabled()
{
ReportSupportabilityCountMetric(MetricNames.SupportabilityGCSamplerV2Enabled);
}

}

private void ReportIfAwsAccountIdProvided()
{
if (!string.IsNullOrEmpty(_configuration.AwsAccountId))
{
ReportSupportabilityCountMetric(MetricNames.SupportabilityAwsAccountIdProvided);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public interface IAttributeDefinitions

AttributeDefinition<object, object> GetLambdaAttribute(string name);
AttributeDefinition<object, object> GetFaasAttribute(string name);
AttributeDefinition<object, object> GetCloudSdkAttribute(string name);

AttributeDefinition<string, string> GetRequestParameterAttribute(string paramName);

Expand Down Expand Up @@ -190,6 +191,7 @@ public AttributeDefinitions(IAttributeFilter attribFilter)
private readonly ConcurrentDictionary<string, AttributeDefinition<string, string>> _requestHeadersAttributes = new ConcurrentDictionary<string, AttributeDefinition<string, string>>();
private readonly ConcurrentDictionary<string, AttributeDefinition<object, object>> _lambdaAttributes = new ConcurrentDictionary<string, AttributeDefinition<object, object>>();
private readonly ConcurrentDictionary<string, AttributeDefinition<object, object>> _faasAttributes = new();
private readonly ConcurrentDictionary<string, AttributeDefinition<object, object>> _cloudSdkAttributes = new();

private readonly ConcurrentDictionary<TypeAttributeValue, AttributeDefinition<TypeAttributeValue, string>> _typeAttributes = new ConcurrentDictionary<TypeAttributeValue, AttributeDefinition<TypeAttributeValue, string>>();

Expand Down Expand Up @@ -281,6 +283,20 @@ public AttributeDefinition<object, object> GetFaasAttribute(string name)
}


private AttributeDefinition<object, object> CreateCloudSdkAttribute(string attribName)
{
return AttributeDefinitionBuilder
.Create<object, object>(attribName, AttributeClassification.AgentAttributes)
.AppliesTo(AttributeDestinations.TransactionTrace)
.AppliesTo(AttributeDestinations.SpanEvent)
.WithConvert(x => x)
.Build(_attribFilter);
}

public AttributeDefinition<object, object> GetCloudSdkAttribute(string name)
{
return _cloudSdkAttributes.GetOrAdd(name, CreateCloudSdkAttribute);
}
public AttributeDefinition<object, object> GetCustomAttributeForTransaction(string name)
{
return _trxCustomAttributes.GetOrAdd(name, CreateCustomAttributeForTransaction);
Expand Down
Loading

0 comments on commit eb1cf48

Please sign in to comment.