Skip to content

Commit

Permalink
Merge branch 'main' into instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AsakerMohd authored May 29, 2024
2 parents 9e36da0 + dc2a193 commit fc09f3d
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>AWS.OpenTelemetry.AutoInstrumentation.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>DynamicProxyGenAssembly2</_Parameter1>
</AssemblyAttribute>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)../../stylecop.json" Link="stylecop.json" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace AWS.OpenTelemetry.AutoInstrumentation;
/// represent "incoming" traffic, {<see cref="SpanKind.Client"/> and <see cref="SpanKind.Producer"/> spans
/// represent "outgoing" traffic, and <see cref="SpanKind.Internal"/> spans are ignored.
/// </summary>
internal sealed class AwsMetricAttributeGenerator : IMetricAttributeGenerator
internal class AwsMetricAttributeGenerator : IMetricAttributeGenerator
{
private static readonly ILoggerFactory Factory = LoggerFactory.Create(builder => builder.AddConsole());
private static readonly ILogger Logger = Factory.CreateLogger<AwsMetricAttributeGenerator>();
Expand All @@ -46,7 +46,7 @@ internal sealed class AwsMetricAttributeGenerator : IMetricAttributeGenerator
private static readonly string AttributeServiceName = "service.name";

/// <inheritdoc/>
public Dictionary<string, ActivityTagsCollection> GenerateMetricAttributeMapFromSpan(Activity span, Resource resource)
public virtual Dictionary<string, ActivityTagsCollection> GenerateMetricAttributeMapFromSpan(Activity span, Resource resource)
{
Dictionary<string, ActivityTagsCollection> attributesMap = new Dictionary<string, ActivityTagsCollection>();
if (ShouldGenerateServiceMetricAttributes(span))
Expand Down Expand Up @@ -89,7 +89,7 @@ private ActivityTagsCollection GenerateDependencyMetricAttributes(Activity span,
private static void SetService(Resource resource, Activity span, ActivityTagsCollection attributes)
#pragma warning restore SA1204 // Static elements should appear before instance elements
{
string? service = (string?)resource.Attributes.First(attribute => attribute.Key == AttributeServiceName).Value;
string? service = (string?)resource.Attributes.FirstOrDefault(attribute => attribute.Key == AttributeServiceName).Value;

// In practice the service name is never null, but we can be defensive here.
if (service == null || service.StartsWith(OtelUnknownServicePrefix))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Lib.Harmony" Version="2.3.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.5.3" />
Expand Down
Loading

0 comments on commit fc09f3d

Please sign in to comment.