Skip to content

Commit

Permalink
Merge branch 'mike/baggage-predicate' of github.com:honeycombio/opent…
Browse files Browse the repository at this point in the history
…elemetry-dotnet-contrib into mike/baggage-predicate
  • Loading branch information
MikeGoldsmith committed Jun 17, 2024
2 parents 87478e0 + 881e8da commit 24ce184
Show file tree
Hide file tree
Showing 45 changed files with 161 additions and 167 deletions.
6 changes: 3 additions & 3 deletions build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<OpenTelemetryExporterInMemoryPkgVer>$(OpenTelemetryCoreLatestVersion)</OpenTelemetryExporterInMemoryPkgVer>
<OpenTelemetryExporterInMemoryLatestPreReleasePkgVer>$(OpenTelemetryCoreLatestPrereleaseVersion)</OpenTelemetryExporterInMemoryLatestPreReleasePkgVer>
<SupportedNetTargets>net8.0;net7.0;net6.0</SupportedNetTargets>
<XUnitRunnerVisualStudioPkgVer>[2.5.0,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitPkgVer>[2.5.0,3.0)</XUnitPkgVer>
<WiremockNetPkgVer>[1.5.48,2.0)</WiremockNetPkgVer>
<XUnitRunnerVisualStudioPkgVer>[2.8.1,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitPkgVer>[2.8.1,3.0)</XUnitPkgVer>
<WiremockNetPkgVer>[1.5.58,2.0)</WiremockNetPkgVer>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Added `rpc.system`, `rpc.service`, and `rpc.method` to activity tags based on
[semantic convention v1.26.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.26.0/docs/cloud-providers/aws-sdk.md#common-attributes).
([#1865](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1865))

## 1.1.0-beta.4

Released 2024-Apr-12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ internal static class AWSSemanticConventions
public const string AttributeHttpResponseContentLength = "http.response_content_length";

public const string AttributeValueDynamoDb = "dynamodb";

public const string AttributeValueRPCSystem = "rpc.system";
public const string AttributeValueRPCService = "rpc.service";
public const string AttributeValueRPCMethod = "rpc.method";
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ private static string FetchRequestId(IRequestContext requestContext, IResponseCo
{
activity.SetTag(AWSSemanticConventions.AttributeAWSServiceName, service);
activity.SetTag(AWSSemanticConventions.AttributeAWSOperationName, operation);

// Follow: https://github.com/open-telemetry/semantic-conventions/blob/v1.26.0/docs/cloud-providers/aws-sdk.md#common-attributes
activity.SetTag(AWSSemanticConventions.AttributeValueRPCSystem, "aws-api");
activity.SetTag(AWSSemanticConventions.AttributeValueRPCService, service);
activity.SetTag(AWSSemanticConventions.AttributeValueRPCMethod, operation);
var client = executionContext.RequestContext.ClientConfig;
if (client != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HangfireInstrumentationOptions

/// <summary>
/// Gets or sets a filter function that determines whether or not to
/// collect telemetry about the the <see cref="BackgroundJob"/> being executed.
/// collect telemetry about the <see cref="BackgroundJob"/> being executed.
/// </summary>
/// <remarks>
/// <b>Notes:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ActivityInstrumentationHelperTest
[Theory]
[InlineData("TestActivitySource", null)]
[InlineData("TestActivitySource", "1.0.0")]
public void SetActivitySource(string name, string version)
public void SetActivitySource(string name, string? version)
{
using var activity = new Activity("Test");
using var activitySource = new ActivitySource(name, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1520,8 +1520,8 @@ private void AssertFluentdForwardModeForLogRecord(GenevaExporterOptions exporter
}
else
{
_ = mapping.TryGetValue("env_properties", out object envProprties);
var envPropertiesMapping = envProprties as IDictionary<object, object>;
_ = mapping.TryGetValue("env_properties", out object envProperties);
var envPropertiesMapping = envProperties as IDictionary<object, object>;

foreach (var item in stateKeyValuePairList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void CannotUseReservedDimensionsInPrepopulatedFields()
}

[Fact]
public void SuccessfulExportOnLinux()
public async Task SuccessfulExportOnLinux()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand Down Expand Up @@ -198,7 +198,7 @@ public void SuccessfulExportOnLinux()
out _);

// Wait a little more than the ExportInterval for the exporter to export the data.
Task.Delay(5500).Wait();
await Task.Delay(5500);

// Read the data sent via socket.
var receivedData = new byte[1024];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ private void AssertFluentdForwardModeForActivity(GenevaExporterOptions exporterO
#endregion

#region Assert Activity Tags
_ = mapping.TryGetValue("env_properties", out object envProprties);
var envPropertiesMapping = envProprties as IDictionary<object, object>;
_ = mapping.TryGetValue("env_properties", out object envProperties);
var envPropertiesMapping = envProperties as IDictionary<object, object>;
foreach (var tag in activity.TagObjects)
{
if (CS40_PART_B_MAPPING.TryGetValue(tag.Key, out string replacementKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task AddTraceEnricherOfTRegistersEnricher()
.AddTraceEnricher<MyTraceEnricher2>())
.Build();

await host.StartAsync().ConfigureAwait(false);
await host.StartAsync();

var enrichers = host.Services.GetServices<TraceEnricher>().ToArray();
Assert.NotNull(enrichers);
Expand Down Expand Up @@ -61,7 +61,7 @@ public async Task AddTraceEnricherOfTRegistersEnricher()
Assert.Equal(1, tagObject2.Single().Value);
}

await host.StopAsync().ConfigureAwait(false);
await host.StopAsync();
}

[Fact]
Expand All @@ -80,7 +80,7 @@ public async Task AddTraceEnricherRegistersEnricher()
.AddTraceEnricher(new MyTraceEnricher2()))
.Build();

await host.StartAsync().ConfigureAwait(false);
await host.StartAsync();

var enrichers = host.Services.GetServices<TraceEnricher>().ToArray();
Assert.NotNull(enrichers);
Expand All @@ -102,7 +102,7 @@ public async Task AddTraceEnricherRegistersEnricher()
Assert.Equal(1, tagObject2.Single().Value);
}

await host.StopAsync().ConfigureAwait(false);
await host.StopAsync();
}

[Fact]
Expand All @@ -126,7 +126,7 @@ public async Task AddTraceEnricherActionRegistersEnricher()
.AddTraceEnricher(bag => bag.Add(testKey2, testValue2)))
.Build();

await host.StartAsync().ConfigureAwait(false);
await host.StartAsync();

using var source1 = new ActivitySource(SourceName);

Expand Down Expand Up @@ -162,7 +162,7 @@ public async Task AddTraceEnricherFactoryRegistersEnricher()
.AddTraceEnricher(sp => new MyTraceEnricher2()))
.Build();

await host.StartAsync().ConfigureAwait(false);
await host.StartAsync();

var enrichers = host.Services.GetServices<TraceEnricher>().ToArray();
Assert.NotNull(enrichers);
Expand All @@ -184,6 +184,6 @@ public async Task AddTraceEnricherFactoryRegistersEnricher()
Assert.Equal(1, tagObject2.Single().Value);
}

await host.StopAsync().ConfigureAwait(false);
await host.StopAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ namespace OpenTelemetry.Instrumentation.AWS.Tests;
public class TestAWSClientInstrumentation
{
[Fact]
#if NETFRAMEWORK
public void TestDDBScanSuccessful()
#else
public async Task TestDDBScanSuccessful()
#endif
{
var exportedItems = new List<Activity>();

Expand All @@ -46,7 +50,7 @@ public void TestDDBScanSuccessful()
#if NETFRAMEWORK
ddb.Scan(scan_request);
#else
ddb.ScanAsync(scan_request).Wait();
await ddb.ScanAsync(scan_request);
#endif
Assert.Single(exportedItems);

Expand All @@ -61,7 +65,11 @@ public void TestDDBScanSuccessful()
}

[Fact]
#if NETFRAMEWORK
public void TestDDBSubtypeScanSuccessful()
#else
public async Task TestDDBSubtypeScanSuccessful()
#endif
{
var exportedItems = new List<Activity>();

Expand All @@ -85,7 +93,7 @@ public void TestDDBSubtypeScanSuccessful()
#if NETFRAMEWORK
ddb.Scan(scan_request);
#else
ddb.ScanAsync(scan_request).Wait();
await ddb.ScanAsync(scan_request);
#endif
Assert.Single(exportedItems);

Expand Down Expand Up @@ -154,7 +162,11 @@ public async Task TestDDBScanUnsuccessful()
}

[Fact]
#if NETFRAMEWORK
public void TestSQSSendMessageSuccessful()
#else
public async Task TestSQSSendMessageSuccessful()
#endif
{
var exportedItems = new List<Activity>();

Expand All @@ -178,7 +190,7 @@ public void TestSQSSendMessageSuccessful()
#if NETFRAMEWORK
sqs.SendMessage(send_msg_req);
#else
sqs.SendMessageAsync(send_msg_req).Wait();
await sqs.SendMessageAsync(send_msg_req);
#endif
Assert.Single(exportedItems);
Activity awssdk_activity = exportedItems[0];
Expand All @@ -205,6 +217,9 @@ private void ValidateDynamoActivityTags(Activity ddb_activity)
Assert.Equal("us-east-1", Utils.GetTagValue(ddb_activity, "aws.region"));
Assert.Equal("SampleProduct", Utils.GetTagValue(ddb_activity, "aws.table_name"));
Assert.Equal("dynamodb", Utils.GetTagValue(ddb_activity, "db.system"));
Assert.Equal("aws-api", Utils.GetTagValue(ddb_activity, "rpc.system"));
Assert.Equal("DynamoDB", Utils.GetTagValue(ddb_activity, "rpc.service"));
Assert.Equal("Scan", Utils.GetTagValue(ddb_activity, "rpc.method"));
}

private void ValidateSqsActivityTags(Activity sqs_activity)
Expand All @@ -214,5 +229,8 @@ private void ValidateSqsActivityTags(Activity sqs_activity)
Assert.Equal("SendMessage", Utils.GetTagValue(sqs_activity, "aws.operation"));
Assert.Equal("us-east-1", Utils.GetTagValue(sqs_activity, "aws.region"));
Assert.Equal("https://sqs.us-east-1.amazonaws.com/123456789/MyTestQueue", Utils.GetTagValue(sqs_activity, "aws.queue_url"));
Assert.Equal("aws-api", Utils.GetTagValue(sqs_activity, "rpc.system"));
Assert.Equal("SQS", Utils.GetTagValue(sqs_activity, "rpc.service"));
Assert.Equal("SendMessage", Utils.GetTagValue(sqs_activity, "rpc.method"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void SetHttpTagsFromResult_APIGatewayHttpApiV2ProxyResponse_SetsCorrectTa
[InlineData(null, "localhost", "localhost", null)]
[InlineData("http", "localhost", "localhost", 80)]
[InlineData("https", "localhost", "localhost", 443)]
public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string httpSchema, string hostHeader, string expectedHost, int? expectedPort)
public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string? httpSchema, string? hostHeader, string? expectedHost, int? expectedPort)
{
(var host, var port) = AWSLambdaHttpUtils.GetHostAndPort(httpSchema, hostHeader);

Expand All @@ -244,7 +244,7 @@ public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string httpSchem
[InlineData(new[] { "value 1" }, "?name=value+1")]
[InlineData(new[] { "value1", "value2" }, "?name=value1&name=value2")]
#pragma warning restore CA1861 // Avoid constant arrays as arguments
public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList<string> values, string expectedQueryString)
public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList<string>? values, string expectedQueryString)
{
var request = new APIGatewayProxyRequest();
if (values != null)
Expand All @@ -265,7 +265,7 @@ public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList<strin
[InlineData("", "")]
[InlineData("name=value1", "?name=value1")]
[InlineData("sdckj9_+", "?sdckj9_+")]
public void GetQueryString_APIGatewayHttpApiV2ProxyRequest_CorrectQueryString(string rawQueryString, string expectedQueryString)
public void GetQueryString_APIGatewayHttpApiV2ProxyRequest_CorrectQueryString(string? rawQueryString, string expectedQueryString)
{
var request = new APIGatewayHttpApiV2ProxyRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CommonExtensionsTests
[InlineData("test")]
[InlineData(443)]
[InlineData(null)]
public void AddTagIfNotNull_Tag_CorrectTagsList(object tag)
public void AddTagIfNotNull_Tag_CorrectTagsList(object? tag)
{
var tags = new List<KeyValuePair<string, object>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task Can_Restore_Activity()
});
}

await testTask.ConfigureAwait(false);
await testTask;
}

[Fact(Skip = "Temporarily disable until stable.")]
Expand Down Expand Up @@ -120,7 +120,7 @@ public async Task Can_Restore_Baggage()
});
}

await testTask.ConfigureAwait(false);
await testTask;
}

[Fact]
Expand Down Expand Up @@ -401,7 +401,7 @@ public void Can_Create_RootActivity_And_Start_Activity()
using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null);

Assert.NotNull(rootActivity);
Assert.True(!string.IsNullOrEmpty(rootActivity.Id));
Assert.False(string.IsNullOrEmpty(rootActivity.Id));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class HttpInListenerTests
string url,
string expectedUrlScheme,
string expectedUrlPath,
string expectedUrlQuery,
string? expectedUrlQuery,
bool disableQueryRedaction,
string expectedHost,
int expectedPort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class HttpInMetricsListenerTests
public void AspNetMetricTagsAreCollectedSuccessfully(
string url,
int routeType,
string routeTemplate,
string enrichMode,
string? routeTemplate,
string? enrichMode,
string expectedScheme,
string? expectedHost,
string expectedRoute,
string? expectedRoute,
int? expectedPort,
int expectedStatus,
bool enableServerAttributesForRequestDuration = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ void ConfigureTestServices(IServiceCollection services)
[InlineData("POST", "POST", null, "POST")]
[InlineData("TRACE", "TRACE", null, "TRACE")]
[InlineData("CUSTOM", "_OTHER", "CUSTOM", "HTTP")]
public async Task HttpRequestMethodAndActivityDisplayIsSetAsPerSpec(string originalMethod, string expectedMethod, string expectedOriginalMethod, string expectedDisplayName)
public async Task HttpRequestMethodAndActivityDisplayIsSetAsPerSpec(string originalMethod, string expectedMethod, string? expectedOriginalMethod, string expectedDisplayName)
{
var exportedItems = new List<Activity>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public DependencyInjectionConfigTests(WebApplicationFactory<Program> factory)
[Theory]
[InlineData(null)]
[InlineData("CustomName")]
public void TestTracingOptionsDIConfig(string name)
public void TestTracingOptionsDIConfig(string? name)
{
name ??= Options.DefaultName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public IncomingRequestsCollectionsIsAccordingToTheSpecTests(WebApplicationFactor
[InlineData("/api/exception", null, null, 503, true)]
public async Task SuccessfulTemplateControllerCallGeneratesASpan_New(
string urlPath,
string query,
string userAgent,
string? query,
string? userAgent,
int statusCode,
bool recordException = false)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public IncomingRequestsCollectionsIsAccordingToTheSpecTests(WebApplicationFactor
activity.Dispose();
}

private static void ValidateTagValue(Activity activity, string attribute, string expectedValue)
private static void ValidateTagValue(Activity activity, string attribute, string? expectedValue)
{
if (string.IsNullOrEmpty(expectedValue))
{
Expand Down
Loading

0 comments on commit 24ce184

Please sign in to comment.