Skip to content

Commit

Permalink
[Internal] Benchmark: Adds options for ClientTelemetry TelemetryEndpo…
Browse files Browse the repository at this point in the history
…int and TelemetryScheduleInSec (#2872)

Right now, Client Telemetry can be only Enabled or disabled in Performance tests. This PR will give flexibility to pass other configurations related to telemetry i.e ScheduledTimeInSec and EndPointURL
  • Loading branch information
sourabh1007 authored Nov 11, 2021
1 parent 27d377b commit ad631a5
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public class BenchmarkConfig
[Option(Required = false, HelpText = "Enable Telemetry")]
public bool EnableTelemetry { get; set; }

[Option(Required = false, HelpText = "Telemetry Schedule in Seconds")]
public int TelemetryScheduleInSec { get; set; }

[Option(Required = false, HelpText = "Telemetry Endpoint")]
public string TelemetryEndpoint { get; set; }

[Option(Required = false, HelpText = "Endpoint to publish results to")]
public string ResultsEndpoint { get; set; }

Expand Down Expand Up @@ -167,13 +173,28 @@ internal Microsoft.Azure.Cosmos.CosmosClient CreateCosmosClient(string accountKe
ApplicationName = BenchmarkConfig.UserAgentSuffix,
MaxRetryAttemptsOnRateLimitedRequests = 0,
MaxRequestsPerTcpConnection = this.MaxRequestsPerTcpConnection,
MaxTcpConnectionsPerEndpoint = this.MaxTcpConnectionsPerEndpoint,
EnableClientTelemetry = this.EnableTelemetry
MaxTcpConnectionsPerEndpoint = this.MaxTcpConnectionsPerEndpoint
};

if(this.EnableTelemetry)
if (this.EnableTelemetry)
{
Environment.SetEnvironmentVariable(Microsoft.Azure.Cosmos.Telemetry.ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, "1");
Environment.SetEnvironmentVariable(
Microsoft.Azure.Cosmos.Telemetry.ClientTelemetryOptions.EnvPropsClientTelemetryEnabled,
"true");

if (this.TelemetryScheduleInSec > 0)
{
Environment.SetEnvironmentVariable(
Microsoft.Azure.Cosmos.Telemetry.ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds,
Convert.ToString(this.TelemetryScheduleInSec));
}

if (!string.IsNullOrEmpty(this.TelemetryEndpoint))
{
Environment.SetEnvironmentVariable(
Microsoft.Azure.Cosmos.Telemetry.ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint,
this.TelemetryEndpoint);
}
}

if (!string.IsNullOrWhiteSpace(this.ConsistencyLevel))
Expand Down

0 comments on commit ad631a5

Please sign in to comment.