-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Instrumentation.SqlClient] Move package from main repository #1673
Merged
Kielek
merged 11 commits into
open-telemetry:main
from
Kielek:migrate-sqlclientinstrumentation
Apr 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
537b820
Feed Instrumentation.SqlClient from main repository
Kielek 9e2d9e1
Include SqlClient instrumentation package into solution
Kielek d9fb4dd
Brings all attributes from main repository
Kielek a09d839
Fix build SqlClient project
Kielek 9eb8314
Fix build test project
Kielek 9fbfdf2
Infrastructure code
Kielek a67b6b4
Merge branch 'main' into migrate-sqlclientinstrumentation
Kielek 0cf5262
Fix Microsoft.Extensions.Options package version
Kielek c2fd7e0
Include note about upgrading OTel .NET SDK to 1.8.1
Kielek 4f9c49b
Merge branch 'main' into migrate-sqlclientinstrumentation
Kielek cf55f12
Merge branch 'main' into migrate-sqlclientinstrumentation
Kielek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix build test project
- Loading branch information
commit 9eb8314df1da835aec50887a0c861c4950b22958
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
test/OpenTelemetry.Contrib.Tests.Shared/EnabledOnDockerPlatformTheoryAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma warning disable IDE0005 // Using directive is unnecessary.using System; | ||
using System; | ||
using System.Diagnostics; | ||
using System.Text; | ||
using Xunit; | ||
#pragma warning restore IDE0005 // Using directive is unnecessary. | ||
|
||
namespace OpenTelemetry.Tests; | ||
|
||
/// <summary> | ||
/// This <see cref="TheoryAttribute" /> skips tests if the required Docker engine is not available. | ||
/// </summary> | ||
internal class EnabledOnDockerPlatformTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EnabledOnDockerPlatformTheoryAttribute" /> class. | ||
/// </summary> | ||
public EnabledOnDockerPlatformTheoryAttribute(DockerPlatform dockerPlatform) | ||
{ | ||
const string executable = "docker"; | ||
|
||
var stdout = new StringBuilder(); | ||
var stderr = new StringBuilder(); | ||
|
||
void AppendStdout(object sender, DataReceivedEventArgs e) => stdout.Append(e.Data); | ||
void AppendStderr(object sender, DataReceivedEventArgs e) => stderr.Append(e.Data); | ||
|
||
var processStartInfo = new ProcessStartInfo(); | ||
processStartInfo.FileName = executable; | ||
processStartInfo.Arguments = string.Join(" ", "version", "--format '{{.Server.Os}}'"); | ||
processStartInfo.RedirectStandardOutput = true; | ||
processStartInfo.RedirectStandardError = true; | ||
processStartInfo.UseShellExecute = false; | ||
|
||
var process = new Process(); | ||
process.StartInfo = processStartInfo; | ||
process.OutputDataReceived += AppendStdout; | ||
process.ErrorDataReceived += AppendStderr; | ||
|
||
try | ||
{ | ||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(); | ||
} | ||
finally | ||
{ | ||
process.OutputDataReceived -= AppendStdout; | ||
process.ErrorDataReceived -= AppendStderr; | ||
} | ||
|
||
if (0.Equals(process.ExitCode) && stdout.ToString().IndexOf(dockerPlatform.ToString(), StringComparison.OrdinalIgnoreCase) > 0) | ||
{ | ||
return; | ||
} | ||
|
||
this.Skip = $"The Docker {dockerPlatform} engine is not available."; | ||
} | ||
|
||
public enum DockerPlatform | ||
{ | ||
/// <summary> | ||
/// Docker Linux engine. | ||
/// </summary> | ||
Linux, | ||
|
||
/// <summary> | ||
/// Docker Windows engine. | ||
/// </summary> | ||
Windows, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
test/OpenTelemetry.Contrib.Tests.Shared/OpenTelemetry.Contrib.Tests.Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletions
29
...etry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>Unit test project for OpenTelemetry SqlClient instrumentations</Description> | ||
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks> | ||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks> | ||
vishweshbankwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- this is temporary. will remove in future PR. --> | ||
<Nullable>disable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\EnabledOnDockerPlatformTheoryAttribute.cs" Link="Includes\EnabledOnDockerPlatformTheoryAttribute.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\SkipUnlessEnvVarFoundTheoryAttribute.cs" Link="Includes\SkipUnlessEnvVarFoundTheoryAttribute.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\EventSourceTestHelper.cs" Link="Includes\EventSourceTestHelper.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestEventListener.cs" Link="Includes\TestEventListener.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestSampler.cs" Link="Includes\TestSampler.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\ActivityHelperExtensions.cs" Link="Includes\ActivityHelperExtensions.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\EnabledOnDockerPlatformTheoryAttribute.cs" Link="Includes\EnabledOnDockerPlatformTheoryAttribute.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\SkipUnlessEnvVarFoundTheoryAttribute.cs" Link="Includes\SkipUnlessEnvVarFoundTheoryAttribute.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\EventSourceTestHelper.cs" Link="Includes\EventSourceTestHelper.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\TestEventListener.cs" Link="Includes\TestEventListener.cs" /> | ||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Contrib.Tests.Shared\TestSampler.cs" Link="Includes\TestSampler.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Data.SqlClient" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Testcontainers.MsSql" /> | ||
<PackageReference Include="Testcontainers.SqlEdge" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.3" /> | ||
<PackageReference Include="Testcontainers.MsSql" Version="3.6.0" /> | ||
<PackageReference Include="Testcontainers.SqlEdge" Version="3.6.0" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="$(OpenTelemetryExporterInMemoryPkgVer)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.SqlClient\OpenTelemetry.Instrumentation.SqlClient.csproj" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.InMemory\OpenTelemetry.Exporter.InMemory.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why do we need additional using? original file does not have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream - all usages have enable
ImplicitUsings
. In this repository, this file is also part ofOpenTelemetry.Contrib.Tests.Shared
. This feature is not enabled so I have to add it manually, but the SqlClient project enablesImplicitusings
- it requiers additional #pragma disable.