Отключение отслеживания зависимостей - функции Azure (изолированное, v4) - .net 9C#

Место общения программистов C#
Ответить
Anonymous
 Отключение отслеживания зависимостей - функции Azure (изолированное, v4) - .net 9

Сообщение Anonymous »

Я изо всех сил пытаюсь отключить отслеживание зависимости в проекте, который использует функции Azure (V4), используя .NET 9 в качестве изолированного процесса. Я хочу сделать это, так как эти записи забивают наши файлы журнала с информацией, которую мы не используем, что в конечном итоге стоит нам денег.

Код: Выделить всё

{
"version": "2.0",
// By default these new logging filters are filtered out by the function logs. You need to modify the host.json file
// to opt-in for additional filters and categories.
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
},
"enableDependencyTracking": false
},
"logLevel": {
"Witness.Io": "Information"
}
},
"extensions": {
"queues": {
"maxPollingInterval": "00:00:10.000",
"batchSize": 1 // The number of queue messages that the Functions runtime retrieves simultaneously and processes in parallel.
}
},
// Set functionTimeout to 10 minutes
"functionTimeout": "00:10:00"
}
Это не решило проблему, поэтому я попытался написать телеметрический процессор, основанный на сообщении в блоге, который я нашел здесь - https://github.com/rohitranjanms/applic ... yProcessor. Main Метод нашей программы.public static void Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWebApplication(config =>
{
config.UseNewtonsoftJson();
})
.ConfigureServices(services =>
{
// Disable dependency tracking - based on approach detailed here - https://github.com/RohitRanjanMS/Applic ... ocessor.cs.
services.AddApplicationInsightsTelemetryProcessor();
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();

var keyVaultService = new KeyVaultService(new Uri(Environment.GetEnvironmentVariable("KEY_VAULT_URI") ?? throw new InvalidOperationException($"Missing environment variable: '{"KEY_VAULT_URI"}'.")));
services.AddKeyVaultService(keyVaultService);

services.AddTransient();
services.AddTransient();
services.AddConfigRepository();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();

services.AddTransient();
services.AddTransient();
services.AddTransient();

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

LogConfiguration(keyVaultService);
})
.ConfigureLogging(logging =>
{
// Allow all Information-level App Insights logs through (this defaults to Warning).
RemoveApplicationInsightsFilter(logging.Services);
})
.Build();

host.Run();
}
< /code>
Процессор выглядит следующим образом: < /p>
///
/// Dependency tracking processor.
///
/// This is used to filter out the dependency tracking logs that we don't want.
public class DependencyTrackingProcessor : ITelemetryProcessor
{
///
/// Initializes a new instance of the class. Link processors to each other in the chain.
///
/// The next telemetry processor.
public DependencyTrackingProcessor(ITelemetryProcessor nextProcessor)
{
NextProcessor = nextProcessor;
}

private ITelemetryProcessor NextProcessor { get; }

///
public void Process(ITelemetry item)
{
if (item is DependencyTelemetry)
{
// Do not send telemetry for dependency tracking.
return;
}

// Call the next processor in the chain.
NextProcessor.Process(item);
}
}
< /code>
Ничего из этого не оказывает никакого влияния. Кто -нибудь может сказать мне, что я делаю не так?>

Подробнее здесь: https://stackoverflow.com/questions/796 ... d-v4-net-9
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»