-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SqlClient] Include instance in
db.namespace
and activity name, sta…
…rt activity with required tags (#2277)
- Loading branch information
Showing
7 changed files
with
247 additions
and
107 deletions.
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTestCase.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,53 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Collections; | ||
|
||
namespace OpenTelemetry.Instrumentation.SqlClient.Tests; | ||
|
||
public class SqlClientTestCase : IEnumerable<object[]> | ||
{ | ||
public string ConnectionString { get; set; } = string.Empty; | ||
|
||
public string ExpectedActivityName { get; set; } = string.Empty; | ||
|
||
public string? ExpectedServerAddress { get; set; } | ||
|
||
public int? ExpectedPort { get; set; } | ||
|
||
public string? ExpectedDbNamespace { get; set; } | ||
|
||
public string? ExpectedInstanceName { get; set; } | ||
|
||
private static SqlClientTestCase[] TestCases => | ||
[ | ||
new SqlClientTestCase | ||
{ | ||
ConnectionString = @"Data Source=SomeServer", | ||
ExpectedActivityName = "SomeServer", | ||
ExpectedServerAddress = "SomeServer", | ||
ExpectedPort = null, | ||
ExpectedDbNamespace = null, | ||
ExpectedInstanceName = null, | ||
}, | ||
new SqlClientTestCase | ||
{ | ||
ConnectionString = @"Data Source=SomeServer,1434", | ||
ExpectedActivityName = "SomeServer:1434", | ||
ExpectedServerAddress = "SomeServer", | ||
ExpectedPort = 1434, | ||
ExpectedDbNamespace = null, | ||
ExpectedInstanceName = null, | ||
}, | ||
]; | ||
|
||
public IEnumerator<object[]> GetEnumerator() | ||
{ | ||
foreach (var testCase in TestCases) | ||
{ | ||
yield return new object[] { testCase }; | ||
} | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); | ||
} |
Oops, something went wrong.