Skip to content

Commit

Permalink
remove debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Jul 4, 2024
1 parent 95f2b40 commit b9041f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ internal static class VmMetadataApiHandler
/// Check for environment variable COSMOS_DISABLE_VM_METADATA_ACCESS to decide if VM metadata call should be made or not.
/// If environment variable is set to true, then VM metadata call will not be made.
/// If environment variable is set to false, then VM metadata call will be made.
/// If environment variable is not set, then set the value according to the debugger which means
/// In Debug mode, it is will be true and VM metadata call will be disabled.
/// In Release mode, it is will be false and VM metadata call will be enabled.
/// If environment variable is not set, then VM metadata call will be made.
/// </summary>.
/// <param name="httpClient"></param>
internal static void TryInitialize(CosmosHttpClient httpClient)
{
bool isVMMetadataAccessDisabled =
ConfigurationManager.GetEnvironmentVariable<bool>("COSMOS_DISABLE_VM_METADATA_ACCESS", System.Diagnostics.Debugger.IsAttached);
ConfigurationManager.GetEnvironmentVariable<bool>("COSMOS_DISABLE_VM_METADATA_ACCESS", false);
if (isVMMetadataAccessDisabled)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ public void Initialize()
[TestMethod]
[DataRow("true", DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is set as true, VM ID should not be fetched")]
[DataRow("false", DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is set as false, VM ID should be fetched")]
[DataRow(null, DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is NOT set, VM ID should be fetched")]
public async Task GetVmIdAsMachineIdTest(string isVmMetadataAccessDisabled)
{
Environment.SetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", isVmMetadataAccessDisabled);
if (isVmMetadataAccessDisabled != null)
{
Environment.SetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", isVmMetadataAccessDisabled);
}

try
{
Expand Down

0 comments on commit b9041f6

Please sign in to comment.