Skip to content

Commit

Permalink
[repo] Misc changes (#5053)
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla authored Nov 15, 2023
1 parent b0f9607 commit c337d1e
Show file tree
Hide file tree
Showing 41 changed files with 219 additions and 218 deletions.
36 changes: 18 additions & 18 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@
This section covers packages that are **not** directly referenced by the NuGet packages published from this repository.
For example, these packages are used in the tests, examples or referenced as "PrivateAssets", but not in the NuGet packages themselves.
-->
<!-- 'net7.0' is the default `TargetFramework`. Use `VersionOverride` in the project to override the package versions from a different `TargetFramework` -->
<!-- 'net8.0' is the default `TargetFramework`. Use `VersionOverride` in the project to override the package versions from a different `TargetFramework` -->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="[0.13.10,0.14)" />
<PackageVersion Include="CommandLineParser" Version="[2.9.1,3.0)" />
<PackageVersion Include="Grpc.AspNetCore" Version="[2.55.0,3.0)" />
<PackageVersion Include="Grpc.AspNetCore.Server" Version="[2.55.0, 3.0)" />
<PackageVersion Include="Grpc.Tools" Version="[2.56.2,3.0)" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="[3.11.0-beta1.23402.2]" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="[3.1.6,5.0)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="3.1.20" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="[6.0.0,)" />
<PackageVersion Include="Grpc.AspNetCore" Version="[2.59.0,3.0)" />
<PackageVersion Include="Grpc.AspNetCore.Server" Version="[2.59.0, 3.0)" />
<PackageVersion Include="Grpc.Tools" Version="[2.59.0,3.0)" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="[3.11.0-beta1.23525.2]" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[8.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="[8.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="[8.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="[8.0.0,)" />
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.7.2,18.0.0)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.8.0,18.0.0)" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[1.1.1,2.0)" />
<PackageVersion Include="MinVer" Version="[4.3.0,5.0)" />
<PackageVersion Include="Moq" Version="[4.18.4,5.0)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="[1.5.0,2.0)" />
<PackageVersion Include="RabbitMQ.Client" Version="[6.5.0,7.0)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="[1.5.1,2.0)" />
<PackageVersion Include="RabbitMQ.Client" Version="[6.6.0,7.0)" />
<PackageVersion Include="StyleCop.Analyzers" Version="[1.2.0-beta.507,2.0)" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="[6.4.0]" />
<PackageVersion Include="Testcontainers.MsSql" Version="3.3.0" />
<PackageVersion Include="Testcontainers.SqlEdge" Version="3.3.0" />
<PackageVersion Include="xunit" Version="[2.5.0,3.0)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.5.0,3.0)" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="[6.5.0,)" />
<PackageVersion Include="Testcontainers.MsSql" Version="3.6.0" />
<PackageVersion Include="Testcontainers.SqlEdge" Version="3.6.0" />
<PackageVersion Include="xunit" Version="[2.6.1,3.0)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.5.3,3.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
3 changes: 2 additions & 1 deletion OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
build\docfx.cmd = build\docfx.cmd
build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml
build\docker-compose.net7.0.yml = build\docker-compose.net7.0.yml
build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml
build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png
Expand Down Expand Up @@ -268,8 +269,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A49299
src\Shared\PeerServiceResolver.cs = src\Shared\PeerServiceResolver.cs
src\Shared\PeriodicExportingMetricReaderHelper.cs = src\Shared\PeriodicExportingMetricReaderHelper.cs
src\Shared\PooledList.cs = src\Shared\PooledList.cs
src\Shared\ResourceSemanticConventions.cs = src\Shared\ResourceSemanticConventions.cs
src\Shared\RequestMethodHelper.cs = src\Shared\RequestMethodHelper.cs
src\Shared\ResourceSemanticConventions.cs = src\Shared\ResourceSemanticConventions.cs
src\Shared\SemanticConventions.cs = src\Shared\SemanticConventions.cs
src\Shared\SpanAttributeConstants.cs = src\Shared\SpanAttributeConstants.cs
src\Shared\SpanHelper.cs = src\Shared\SpanHelper.cs
Expand Down
2 changes: 1 addition & 1 deletion build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<DefaultTargetFrameworkForExampleApps>net7.0</DefaultTargetFrameworkForExampleApps>
<DefaultTargetFrameworkForExampleApps>net8.0</DefaultTargetFrameworkForExampleApps>
</PropertyGroup>

<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
Expand Down
4 changes: 2 additions & 2 deletions examples/MicroserviceExample/WebApi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG SDK_VERSION=7.0
ARG SDK_VERSION=8.0
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net7.0
ARG PUBLISH_FRAMEWORK=net8.0
WORKDIR /app
COPY . ./
RUN dotnet publish ./examples/MicroserviceExample/WebApi -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true
Expand Down
4 changes: 2 additions & 2 deletions examples/MicroserviceExample/WorkerService/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG SDK_VERSION=7.0
ARG SDK_VERSION=8.0
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net7.0
ARG PUBLISH_FRAMEWORK=net8.0
WORKDIR /app
COPY . ./
RUN dotnet publish ./examples/MicroserviceExample/WorkerService -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true
Expand Down
4 changes: 2 additions & 2 deletions test/Benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Navigate to `./test/Benchmarks` directory and run the following command:

```sh
dotnet run -c Release -f net7.0 -- -m
dotnet run -c Release -f net8.0 -- -m
```

[How to use console arguments](https://benchmarkdotnet.org/articles/guides/console-args.html)

- `-m` enables MemoryDiagnoser and prints memory statistics
- `-f` allows you to filter the benchmarks by their full name using glob patterns
- `dotnet run -c Release -f net7.0 -- -f *TraceBenchmarks*`
- `dotnet run -c Release -f net8.0 -- -f *TraceBenchmarks*`
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Api.Tests/BaggageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public async Task AsyncLocalTests()
{
Baggage.SetBaggage("key1", "value1");

await InnerTask().ConfigureAwait(false);
await InnerTask();

Baggage.SetBaggage("key4", "value4");

Expand Down
6 changes: 3 additions & 3 deletions test/OpenTelemetry.Api.Tests/Trace/TracerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ public async Task Tracer_StartRootSpan_StartsNewTrace()

async Task DoSomeAsyncWork()
{
await Task.Delay(10).ConfigureAwait(false);
await Task.Delay(10);
using (tracer.GetTracer("tracername").StartRootSpan("RootSpan2"))
{
await Task.Delay(10).ConfigureAwait(false);
await Task.Delay(10);
}
}

using (tracer.GetTracer("tracername").StartActiveSpan("RootSpan1"))
{
await DoSomeAsyncWork().ConfigureAwait(false);
await DoSomeAsyncWork();
}

Assert.Equal(2, exportedItems.Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public void SendExportRequest_ExportTraceServiceRequest_SendsCorrectHttpRequest(
{
return new HttpResponseMessage();
})
.Callback<HttpRequestMessage, CancellationToken>((r, ct) =>
.Callback<HttpRequestMessage, CancellationToken>(async (r, ct) =>
{
httpRequest = r;

// We have to capture content as it can't be accessed after request is disposed inside of SendExportRequest method
httpRequestContent = r.Content.ReadAsByteArrayAsync(ct)?.Result;
httpRequestContent = await r.Content.ReadAsByteArrayAsync(ct);
})
#else
.Setup<Task<HttpResponseMessage>>("SendAsync", ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>())
Expand All @@ -124,7 +124,7 @@ public void SendExportRequest_ExportTraceServiceRequest_SendsCorrectHttpRequest(
httpRequest = r;

// We have to capture content as it can't be accessed after request is disposed inside of SendExportRequest method
httpRequestContent = await r.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
httpRequestContent = await r.Content.ReadAsByteArrayAsync();
})
#endif
.Verifiable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public async Task TestRecoveryAfterFailedExport()
endpoints.MapGrpcService<MockTraceService>();
});
}))
.StartAsync().ConfigureAwait(false);
.StartAsync();

var httpClient = new HttpClient() { BaseAddress = new Uri("http://localhost:5050") };

var codes = new[] { Grpc.Core.StatusCode.Unimplemented, Grpc.Core.StatusCode.OK };
await httpClient.GetAsync($"/MockCollector/SetResponseCodes/{string.Join(",", codes.Select(x => (int)x))}").ConfigureAwait(false);
await httpClient.GetAsync($"/MockCollector/SetResponseCodes/{string.Join(",", codes.Select(x => (int)x))}");

var exportResults = new List<ExportResult>();
var otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new Uri("http://localhost:4317") });
Expand Down Expand Up @@ -101,7 +101,7 @@ public async Task TestRecoveryAfterFailedExport()
Assert.Equal(2, exportResults.Count);
Assert.Equal(ExportResult.Success, exportResults[1]);

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

private class MockCollectorState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ await RunPrometheusExporterMiddlewareIntegrationTest(
path: null,
configureBranchedPipeline: null,
optionsName: null),
registerMeterProvider: false).ConfigureAwait(false);
registerMeterProvider: false);
}

[Fact]
Expand Down Expand Up @@ -235,7 +235,7 @@ await RunPrometheusExporterMiddlewareIntegrationTest(
configureBranchedPipeline: null,
optionsName: null)),
services => services.AddRouting(),
registerMeterProvider: false).ConfigureAwait(false);
registerMeterProvider: false);
}

private static async Task RunPrometheusExporterMiddlewareIntegrationTest(
Expand Down Expand Up @@ -265,7 +265,7 @@ private static async Task RunPrometheusExporterMiddlewareIntegrationTest(
configureServices?.Invoke(services);
})
.Configure(configure))
.StartAsync().ConfigureAwait(false);
.StartAsync();

var tags = new KeyValuePair<string, object>[]
{
Expand All @@ -284,7 +284,7 @@ private static async Task RunPrometheusExporterMiddlewareIntegrationTest(
counter.Add(0.99D, tags);
}

using var response = await host.GetTestClient().GetAsync(path).ConfigureAwait(false);
using var response = await host.GetTestClient().GetAsync(path);

var endTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();

Expand All @@ -294,7 +294,7 @@ private static async Task RunPrometheusExporterMiddlewareIntegrationTest(
Assert.True(response.Content.Headers.Contains("Last-Modified"));
Assert.Equal("text/plain; charset=utf-8; version=0.0.4", response.Content.Headers.ContentType.ToString());

string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();

var matches = Regex.Matches(
content,
Expand All @@ -318,7 +318,7 @@ private static async Task RunPrometheusExporterMiddlewareIntegrationTest(

validateResponse?.Invoke(response);

await host.StopAsync().ConfigureAwait(false);
await host.StopAsync();
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon
{
collectTasks[i] = Task.Run(async () =>
{
var response = await exporter.CollectionManager.EnterCollect().ConfigureAwait(false);
var response = await exporter.CollectionManager.EnterCollect();
try
{
return new Response
Expand All @@ -81,26 +81,26 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon
});
}

await Task.WhenAll(collectTasks).ConfigureAwait(false);
await Task.WhenAll(collectTasks);

Assert.Equal(1, runningCollectCount);

var firstResponse = collectTasks[0].Result;
var firstResponse = await collectTasks[0];

Assert.False(firstResponse.CollectionResponse.FromCache);

for (int i = 1; i < collectTasks.Length; i++)
{
Assert.Equal(firstResponse.ViewPayload, collectTasks[i].Result.ViewPayload);
Assert.Equal(firstResponse.CollectionResponse.GeneratedAtUtc, collectTasks[i].Result.CollectionResponse.GeneratedAtUtc);
Assert.Equal(firstResponse.ViewPayload, (await collectTasks[i]).ViewPayload);
Assert.Equal(firstResponse.CollectionResponse.GeneratedAtUtc, (await collectTasks[i]).CollectionResponse.GeneratedAtUtc);
}

counter.Add(100);

// This should use the cache and ignore the second counter update.
var task = exporter.CollectionManager.EnterCollect();
Assert.True(task.IsCompleted);
var response = await task.ConfigureAwait(false);
var response = await task;
try
{
if (cacheEnabled)
Expand Down Expand Up @@ -129,7 +129,7 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon
{
collectTasks[i] = Task.Run(async () =>
{
var response = await exporter.CollectionManager.EnterCollect().ConfigureAwait(false);
var response = await exporter.CollectionManager.EnterCollect();
try
{
return new Response
Expand All @@ -145,20 +145,20 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon
});
}

await Task.WhenAll(collectTasks).ConfigureAwait(false);
await Task.WhenAll(collectTasks);

Assert.Equal(cacheEnabled ? 2 : 3, runningCollectCount);
Assert.NotEqual(firstResponse.ViewPayload, collectTasks[0].Result.ViewPayload);
Assert.NotEqual(firstResponse.CollectionResponse.GeneratedAtUtc, collectTasks[0].Result.CollectionResponse.GeneratedAtUtc);
Assert.NotEqual(firstResponse.ViewPayload, (await collectTasks[0]).ViewPayload);
Assert.NotEqual(firstResponse.CollectionResponse.GeneratedAtUtc, (await collectTasks[0]).CollectionResponse.GeneratedAtUtc);

firstResponse = collectTasks[0].Result;
firstResponse = await collectTasks[0];

Assert.False(firstResponse.CollectionResponse.FromCache);

for (int i = 1; i < collectTasks.Length; i++)
{
Assert.Equal(firstResponse.ViewPayload, collectTasks[i].Result.ViewPayload);
Assert.Equal(firstResponse.CollectionResponse.GeneratedAtUtc, collectTasks[i].Result.CollectionResponse.GeneratedAtUtc);
Assert.Equal(firstResponse.ViewPayload, (await collectTasks[i]).ViewPayload);
Assert.Equal(firstResponse.CollectionResponse.GeneratedAtUtc, (await collectTasks[i]).CollectionResponse.GeneratedAtUtc);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public void UriPrefixesInvalid()
[Fact]
public async Task PrometheusExporterHttpServerIntegration()
{
await this.RunPrometheusExporterHttpServerIntegrationTest().ConfigureAwait(false);
await this.RunPrometheusExporterHttpServerIntegrationTest();
}

[Fact]
public async Task PrometheusExporterHttpServerIntegration_NoMetrics()
{
await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true).ConfigureAwait(false);
await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true);
}

private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetrics = false)
Expand Down Expand Up @@ -125,7 +125,7 @@ private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetri
}

using HttpClient client = new HttpClient();
using var response = await client.GetAsync($"{address}metrics").ConfigureAwait(false);
using var response = await client.GetAsync($"{address}metrics");

if (!skipMetrics)
{
Expand All @@ -135,7 +135,7 @@ private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetri

Assert.Matches(
"^# TYPE counter_double_total counter\ncounter_double_total{key1='value1',key2='value2'} 101.17 \\d+\n\n# EOF\n$".Replace('\'', '"'),
await response.Content.ReadAsStringAsync().ConfigureAwait(false));
await response.Content.ReadAsStringAsync());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ await RunMetricsTest(
using var meter = new Meter(meterName);
var counter = meter.CreateCounter<long>("meter");
counter.Add(10);
}).ConfigureAwait(false);
});

Assert.Single(exportedItems);
var metricPointsEnumerator = exportedItems[0].GetMetricPoints().GetEnumerator();
Expand All @@ -75,7 +75,7 @@ await RunMetricsTest(
using var meter = new Meter(meterName);
var counter = meter.CreateCounter<long>("meter");
counter.Add(10);
}).ConfigureAwait(false);
});

Assert.Single(exportedItems);
Assert.Equal(10, exportedItems[0].MetricPoints[0].GetSumLong());
Expand All @@ -96,13 +96,13 @@ private static async Task RunMetricsTest(Action<MeterProviderBuilder> configure,

return Task.CompletedTask;
})))
.StartAsync().ConfigureAwait(false);
.StartAsync();

using var response = await host.GetTestClient().GetAsync($"/{nameof(RunMetricsTest)}").ConfigureAwait(false);
using var response = await host.GetTestClient().GetAsync($"/{nameof(RunMetricsTest)}");

Assert.Equal(HttpStatusCode.OK, response.StatusCode);

await host.StopAsync().ConfigureAwait(false);
await host.StopAsync();
}
}
#endif
Loading

0 comments on commit c337d1e

Please sign in to comment.