Skip to content

Commit

Permalink
[Internal] Client Telemetry: Fixes loggers (#4594)
Browse files Browse the repository at this point in the history
* fix logger

* skipping latency record if it is in negative otherwise histogram will throw an exception, while recording it

* fix loggers
  • Loading branch information
sourabh1007 authored Jul 24, 2024
1 parent 9de654e commit 0f3e6ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Microsoft.Azure.Cosmos/src/Telemetry/ClientTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ internal static async Task RunProcessorTaskAsync(string telemetryDate, Task proc
Task resultTask = await Task.WhenAny(processingTask, delayTask);
if (resultTask == delayTask)
{
DefaultTrace.TraceError($"Processor task with date as {0} is cancelled as it did not finish in {1} milliseconds", telemetryDate, timeout.TotalMilliseconds);
DefaultTrace.TraceError("Processor task with date as {0} is cancelled as it did not finish in {1} milliseconds", telemetryDate, timeout.TotalMilliseconds);
}
else
{
Expand All @@ -244,12 +244,12 @@ internal void PushCacheDatapoint(string cacheName, TelemetryInformation data)
// If latency information is not available. Ignore this datapoint. It is not expected but putting this safety check
if (!data.RequestLatency.HasValue)
{
DefaultTrace.TraceWarning($"Latency data point is not available for {0} cache call", cacheName);
DefaultTrace.TraceWarning("Latency data point is not available for {0} cache call", cacheName);

return;
}

DefaultTrace.TraceVerbose($"Collecting cacheRefreshSource {0} data for Telemetry.", cacheName);
DefaultTrace.TraceVerbose("Collecting cacheRefreshSource {0} data for Telemetry.", cacheName);

string regionsContacted = ClientTelemetryHelper.GetContactedRegions(data.RegionsContactedList);

Expand Down Expand Up @@ -322,7 +322,7 @@ internal void PushOperationDatapoint(TelemetryInformation data)
}
else
{
DefaultTrace.TraceWarning($"Latency data point is not available for an operation");
DefaultTrace.TraceWarning("Latency data point is not available for an operation");
}

long requestChargeToRecord = (long)(data.RequestCharge * ClientTelemetryOptions.HistogramPrecisionFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CollectCacheInfo(string cacheName, Func<TelemetryInformation> functi
}
catch (Exception ex)
{
DefaultTrace.TraceError($"Error while collecting cache {0} telemetry. Exception : {1}", cacheName, ex);
DefaultTrace.TraceError("Error while collecting cache {0} telemetry. Exception : {1}", cacheName, ex);
}
}

Expand All @@ -63,7 +63,7 @@ public void CollectOperationAndNetworkInfo(Func<TelemetryInformation> functionFo
}
catch (Exception ex)
{
DefaultTrace.TraceError($"Error while collecting operation telemetry. Exception : {1}", ex);
DefaultTrace.TraceError("Error while collecting operation telemetry. Exception : {0}", ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void StopClientTelemetry()
}
catch (Exception ex)
{
DefaultTrace.TraceWarning($"Error While stopping Telemetry Job : {0}", ex);
DefaultTrace.TraceWarning("Error While stopping Telemetry Job : {0}", ex);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ static ValueTask<HttpRequestMessage> CreateRequestMessage()

azMetadata = await VmMetadataApiHandler.ProcessResponseAsync(response);

DefaultTrace.TraceInformation($"Succesfully get Instance Metadata Response : {0}", azMetadata.Compute.VMId);
DefaultTrace.TraceInformation("Successfully get Instance Metadata Response : {0}", azMetadata.Compute.VMId);
}
catch (Exception e)
{
DefaultTrace.TraceInformation($"Azure Environment metadata information not available. {0}", e.Message);
DefaultTrace.TraceInformation("Azure Environment metadata information not available. {0}", e.Message);
}
}

Expand Down Expand Up @@ -167,7 +167,7 @@ internal static string GetCloudInformation()
}
catch (Exception ex)
{
DefaultTrace.TraceWarning($"Error while generating hashed machine name {0}", ex.Message);
DefaultTrace.TraceWarning("Error while generating hashed machine name {0}", ex.Message);
}

return $"{VmMetadataApiHandler.UuidPrefix}{Guid.NewGuid()}";
Expand Down

0 comments on commit 0f3e6ca

Please sign in to comment.