Skip to content

Commit

Permalink
Exclude AzureFunctionsConsumption too
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Dec 1, 2023
1 parent 1db8b88 commit d46236f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te

LambdaMetadata = LambdaMetadata.Create();

IsRunningInAzureAppService = ImmutableAzureAppServiceSettings.GetIsAzureAppService(source, telemetry);
IsRunningInAzureFunctionsConsumptionPlan = ImmutableAzureAppServiceSettings.GetIsFunctionsAppConsumptionPlan(source, telemetry);

if (IsRunningInAzureAppService)
{
AzureAppServiceMetadata = new ImmutableAzureAppServiceSettings(source, _telemetry);
}

EnvironmentInternal = config
.WithKeys(ConfigurationKeys.Environment)
.AsString();
Expand Down Expand Up @@ -116,6 +124,11 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te
.WithKeys(ConfigurationKeys.TraceEnabled)
.AsBool(defaultValue: true);

if (AzureAppServiceMetadata?.IsUnsafeToTrace == true)
{
TraceEnabledInternal = false;
}

var disabledIntegrationNames = config.WithKeys(ConfigurationKeys.DisabledIntegrations)
.AsString()
?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ??
Expand Down Expand Up @@ -214,7 +227,7 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te
// If Lambda/GCP we don't wanat to have a flush interval. The serverless integration
// manually calls flush and waits for the result before ending execution.
// This can artificially increase the execution time of functions
var defaultTraceBatchInterval = LambdaMetadata.IsRunningInLambda || IsRunningInGCPFunctions ? 0 : 100;
var defaultTraceBatchInterval = LambdaMetadata.IsRunningInLambda || IsRunningInGCPFunctions || IsRunningInAzureFunctionsConsumptionPlan ? 0 : 100;
TraceBatchInterval = config
.WithKeys(ConfigurationKeys.SerializationBatchInterval)
.AsInt32(defaultTraceBatchInterval);
Expand Down Expand Up @@ -328,19 +341,6 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te
.WithKeys(ConfigurationKeys.RareSamplerEnabled)
.AsBool(false);

IsRunningInAzureAppService = ImmutableAzureAppServiceSettings.GetIsAzureAppService(source, telemetry);

IsRunningInAzureFunctionsConsumptionPlan = ImmutableAzureAppServiceSettings.GetIsFunctionsAppConsumptionPlan(source, telemetry);

if (IsRunningInAzureAppService)
{
AzureAppServiceMetadata = new ImmutableAzureAppServiceSettings(source, _telemetry);
if (AzureAppServiceMetadata.IsUnsafeToTrace)
{
TraceEnabledInternal = false;
}
}

StatsComputationEnabledInternal = config
.WithKeys(ConfigurationKeys.StatsComputationEnabled)
.AsBool(defaultValue: (IsRunningInGCPFunctions || IsRunningInAzureFunctionsConsumptionPlan));
Expand Down

0 comments on commit d46236f

Please sign in to comment.