Skip to content

Commit 1015be6

Browse files
authored
SigV4 Authentication support for http/protobuf exporter (#177)
1 parent 5801a1c commit 1015be6

File tree

8 files changed

+796
-3
lines changed

8 files changed

+796
-3
lines changed

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/AWS.Distro.OpenTelemetry.AutoInstrumentation.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
19-
<PackageReference Include="AWSSDK.Core" Version="3.7.303.27" />
19+
<PackageReference Include="AWSSDK.Core" Version="3.7.300" />
20+
<PackageReference Include="AWSSDK.XRay" Version="3.7.300" />
2021
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.2.4" />
2122
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2223
<PackageReference Include="OpenTelemetry" Version="1.9.0" />

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/GlobalSuppressions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Reviewed", Scope = "type", Target = "~T:UdpExporter")]
2323
[assembly: SuppressMessage("Design", "CA1050:Declare types in namespaces", Justification = "Reviewed", Scope = "type", Target = "~T:UdpExporter")]
2424
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:Closing square brackets should be spaced correctly", Justification = "Reviewed", Scope = "member", Target = "~M:OtlpUdpExporter.Export(OpenTelemetry.Batch{System.Diagnostics.Activity}@)~OpenTelemetry.ExportResult")]
25-
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:Closing square brackets should be spaced correctly", Justification = "Reviewed", Scope = "member", Target = "~M:OtlpUdpExporter.SerializeSpans(OpenTelemetry.Batch{System.Diagnostics.Activity})~System.Byte[]")]
2625
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Reviewed", Scope = "type", Target = "~T:StatusCodeConverter")]
2726
[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Reviewed", Scope = "member", Target = "~F:AWS.Distro.OpenTelemetry.AutoInstrumentation.Version.version")]
2827
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1400:Access modifier should be declared", Justification = "Reviewed", Scope = "type", Target = "~T:AWS.Distro.OpenTelemetry.AutoInstrumentation.Version")]
2928
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Reviewed", Scope = "member", Target = "~F:AWS.Distro.OpenTelemetry.AutoInstrumentation.Version.version")]
3029
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:File header copyright text should match", Justification = "Reviewed")]
3130
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:Closing square brackets should be spaced correctly", Justification = "Reviewed", Scope = "member", Target = "~M:OtlpExporterUtils.SerializeSpans(OpenTelemetry.Batch{System.Diagnostics.Activity},OpenTelemetry.Resources.Resource)~System.Byte[]")]
31+
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Reviewed", Scope = "type", Target = "~T:RetryHelper")]
32+
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:Closing square brackets should be spaced correctly", Justification = "Reviewed", Scope = "member", Target = "~M:OtlpAwsSpanExporter.Export(OpenTelemetry.Batch{System.Diagnostics.Activity}@)~OpenTelemetry.ExportResult,~M:OtlpUdpExporter.SerializeSpans(OpenTelemetry.Batch{System.Diagnostics.Activity})~System.Byte[]")]
3233

3334
// TODO, review these suppressions.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using Amazon.Runtime;
5+
using Amazon.Runtime.Internal;
6+
using Amazon.Runtime.Internal.Auth;
7+
8+
/// <summary>
9+
/// Provides AWS authentication and signing capabilities for AWS service requests.
10+
/// </summary>
11+
public interface IAwsAuthenticator
12+
{
13+
/// <summary>
14+
/// Asynchronously retrieves AWS credentials that can be used to authenticate requests.
15+
/// </summary>
16+
/// <returns>
17+
/// A Task that resolves to an ImmutableCredentials object containing AWS access credentials.
18+
/// The credentials include access key, secret key, and optional session token.
19+
/// </returns>
20+
Task<ImmutableCredentials> GetCredentialsAsync();
21+
22+
/// <summary>
23+
/// Signs an AWS request using AWS Signature Version 4.
24+
/// </summary>
25+
void Sign(IRequest request, IClientConfig config, ImmutableCredentials credentials);
26+
}
27+
28+
/// <summary>
29+
/// Default implementation of IAwsAuthenticator that uses AWS SDK's built-in credential
30+
/// and signing mechanisms.
31+
/// </summary>
32+
public class DefaultAwsAuthenticator : IAwsAuthenticator
33+
{
34+
/// <inheritdoc/>
35+
public async Task<ImmutableCredentials> GetCredentialsAsync()
36+
{
37+
return await FallbackCredentialsFactory.GetCredentials().GetCredentialsAsync();
38+
}
39+
40+
/// <inheritdoc/>
41+
public void Sign(IRequest request, IClientConfig config, ImmutableCredentials credentials)
42+
{
43+
new AWS4Signer().Sign(request, config, null, credentials);
44+
}
45+
}

0 commit comments

Comments
 (0)