Skip to content

Commit 072b337

Browse files
change IsNullOrEmpty to IsNullorWhiteSpace (#24319)
1 parent fba7686 commit 072b337

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/HttpHelper.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ internal static string GetDbDependencyTarget(this AzMonList tagObjects)
225225
{
226226
string target = tagObjects.GetDependencyTarget(PartBType.Db);
227227
string dbName = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeDbName)?.ToString();
228-
bool isTargetEmpty = string.IsNullOrEmpty(target);
229-
bool isDbNameEmpty = string.IsNullOrEmpty(dbName);
228+
bool isTargetEmpty = string.IsNullOrWhiteSpace(target);
229+
bool isDbNameEmpty = string.IsNullOrWhiteSpace(dbName);
230230
if (!isTargetEmpty && !isDbNameEmpty)
231231
{
232232
target = $"{target} | {dbName}";
@@ -264,7 +264,7 @@ internal static string GetDependencyTarget(this AzMonList tagObjects, PartBType
264264
}
265265

266266
var peerService = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributePeerService)?.ToString();
267-
if (!string.IsNullOrEmpty(peerService))
267+
if (!string.IsNullOrWhiteSpace(peerService))
268268
{
269269
target = peerService;
270270
return target;
@@ -273,7 +273,7 @@ internal static string GetDependencyTarget(this AzMonList tagObjects, PartBType
273273
if (type == PartBType.Http)
274274
{
275275
var httpHost = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeHttpHost)?.ToString();
276-
if (!string.IsNullOrEmpty(httpHost))
276+
if (!string.IsNullOrWhiteSpace(httpHost))
277277
{
278278
string portSection = $":{defaultPort}";
279279
if (httpHost.EndsWith(portSection, StringComparison.OrdinalIgnoreCase))
@@ -288,21 +288,21 @@ internal static string GetDependencyTarget(this AzMonList tagObjects, PartBType
288288
return target;
289289
}
290290
var httpUrl = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeHttpUrl)?.ToString();
291-
if (!string.IsNullOrEmpty(httpUrl) && Uri.TryCreate(httpUrl.ToString(), UriKind.RelativeOrAbsolute, out var uri) && uri.IsAbsoluteUri)
291+
if (!string.IsNullOrWhiteSpace(httpUrl) && Uri.TryCreate(httpUrl.ToString(), UriKind.RelativeOrAbsolute, out var uri) && uri.IsAbsoluteUri)
292292
{
293293
target = uri.Authority;
294-
if (!string.IsNullOrEmpty(target))
294+
if (!string.IsNullOrWhiteSpace(target))
295295
{
296296
return target;
297297
}
298298
}
299299
}
300300

301301
target = tagObjects.GetHostUsingNetPeerAttributes();
302-
if (!string.IsNullOrEmpty(target))
302+
if (!string.IsNullOrWhiteSpace(target))
303303
{
304304
var netPeerPort = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeNetPeerPort)?.ToString();
305-
if (!string.IsNullOrEmpty(netPeerPort) && netPeerPort != defaultPort)
305+
if (!string.IsNullOrWhiteSpace(netPeerPort) && netPeerPort != defaultPort)
306306
{
307307
target = $"{target}:{netPeerPort}";
308308
}
@@ -314,13 +314,13 @@ internal static string GetDependencyTarget(this AzMonList tagObjects, PartBType
314314

315315
internal static string GetHttpDependencyName(this AzMonList tagObjects, string httpUrl)
316316
{
317-
if (string.IsNullOrEmpty(httpUrl))
317+
if (string.IsNullOrWhiteSpace(httpUrl))
318318
{
319319
return null;
320320
}
321321

322322
var httpMethod = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeHttpMethod)?.ToString();
323-
if (!string.IsNullOrEmpty(httpMethod))
323+
if (!string.IsNullOrWhiteSpace(httpMethod))
324324
{
325325
if (Uri.TryCreate(httpUrl.ToString(), UriKind.RelativeOrAbsolute, out var uri) && uri.IsAbsoluteUri)
326326
{

sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/TelemetryPartA.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ internal static string GetOperationName(Activity activity, ref AzMonList partBTa
7373
var httpRoute = AzMonList.GetTagValue(ref partBTags, SemanticConventions.AttributeHttpRoute)?.ToString();
7474
// ASP.NET instrumentation assigns route as {controller}/{action}/{id} which would result in the same name for different operations.
7575
// To work around that we will use path from httpUrl.
76-
if (!string.IsNullOrEmpty(httpRoute) && !httpRoute.Contains("{controller}"))
76+
if (!string.IsNullOrWhiteSpace(httpRoute) && !httpRoute.Contains("{controller}"))
7777
{
7878
return $"{httpMethod} {httpRoute}";
7979
}
8080
var httpUrl = AzMonList.GetTagValue(ref partBTags, SemanticConventions.AttributeHttpUrl)?.ToString();
81-
if (!string.IsNullOrEmpty(httpUrl) && Uri.TryCreate(httpUrl.ToString(), UriKind.RelativeOrAbsolute, out var uri) && uri.IsAbsoluteUri)
81+
if (!string.IsNullOrWhiteSpace(httpUrl) && Uri.TryCreate(httpUrl.ToString(), UriKind.RelativeOrAbsolute, out var uri) && uri.IsAbsoluteUri)
8282
{
8383
return $"{httpMethod} {uri.AbsolutePath}";
8484
}

0 commit comments

Comments
 (0)