From 333e63b88fbb763745da770b474d267a48cd6587 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 3 Jul 2025 18:08:16 +0000
Subject: [PATCH 1/3] Initial plan
From c24904c5f0a992174f8b2bd234123cecfdfd714a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 3 Jul 2025 18:13:56 +0000
Subject: [PATCH 2/3] Initial exploration and planning for file sink telemetry
feature
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
---
global.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/global.json b/global.json
index 08b8436e55..0e5b329395 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.411",
+ "version": "8.0.117",
"rollForward": "latestFeature"
}
}
From c258d60d99af8d4d31c13c94d095f488b5f440ac Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 3 Jul 2025 18:34:30 +0000
Subject: [PATCH 3/3] Implement file sink telemetry configuration for CLI
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
---
schemas/dab.draft.schema.json | 34 ++++
src/Cli.Tests/ConfigureOptionsTests.cs | 215 +++++++++++++++++++++
src/Cli/Commands/ConfigureOptions.cs | 26 +++
src/Cli/ConfigGenerator.cs | 97 ++++++++++
src/Config/ObjectModel/FileOptions.cs | 37 ++++
src/Config/ObjectModel/TelemetryOptions.cs | 2 +-
6 files changed, 410 insertions(+), 1 deletion(-)
create mode 100644 src/Config/ObjectModel/FileOptions.cs
diff --git a/schemas/dab.draft.schema.json b/schemas/dab.draft.schema.json
index 692b82b642..61fc4c19b9 100644
--- a/schemas/dab.draft.schema.json
+++ b/schemas/dab.draft.schema.json
@@ -410,6 +410,40 @@
},
"required": ["endpoint"]
},
+ "file": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled": {
+ "type": "boolean",
+ "description": "Enable/disable file sink telemetry logging.",
+ "default": false
+ },
+ "path": {
+ "type": "string",
+ "description": "File path for telemetry logs.",
+ "default": "/logs/dab-log.txt"
+ },
+ "rolling-interval": {
+ "type": "string",
+ "description": "Rolling interval for log files.",
+ "default": "day",
+ "enum": ["hour", "day", "week"]
+ },
+ "retained-file-count-limit": {
+ "type": "integer",
+ "description": "Maximum number of retained log files.",
+ "default": 1,
+ "minimum": 1
+ },
+ "file-size-limit-bytes": {
+ "type": "integer",
+ "description": "Maximum file size in bytes before rolling.",
+ "default": 1048576,
+ "minimum": 1
+ }
+ }
+ },
"log-level": {
"type": "object",
"description": "Global configuration of log level, defines logging severity levels for specific classes, when 'null' it will set logging level based on 'host: mode' property",
diff --git a/src/Cli.Tests/ConfigureOptionsTests.cs b/src/Cli.Tests/ConfigureOptionsTests.cs
index 8ee064e262..886e240615 100644
--- a/src/Cli.Tests/ConfigureOptionsTests.cs
+++ b/src/Cli.Tests/ConfigureOptionsTests.cs
@@ -819,5 +819,220 @@ private void SetupFileSystemWithInitialConfig(string jsonConfig)
Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(jsonConfig, out RuntimeConfig? config));
Assert.IsNotNull(config.Runtime);
}
+
+ ///
+ /// Tests that running "dab configure --runtime.telemetry.file.enabled" on a config with various values results
+ /// in runtime config update. Takes in updated value for telemetry file enabled and
+ /// validates whether the runtime config reflects those updated values
+ ///
+ [DataTestMethod]
+ [DataRow(true, DisplayName = "Enable file sink telemetry.")]
+ [DataRow(false, DisplayName = "Disable file sink telemetry.")]
+ public void TestUpdateTelemetryFileEnabled(bool updatedEnabledValue)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update file enabled flag
+ ConfigureOptions options = new(
+ runtimeTelemetryFileEnabled: updatedEnabledValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate the Enabled Flag is updated
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File?.Enabled);
+ Assert.AreEqual(updatedEnabledValue, runtimeConfig.Runtime.Telemetry.File.Enabled);
+ }
+
+ ///
+ /// Tests that running "dab configure --runtime.telemetry.file.path" on a config with various values results
+ /// in runtime config update. Takes in updated value for telemetry file path and
+ /// validates whether the runtime config reflects those updated values
+ ///
+ [DataTestMethod]
+ [DataRow("/logs/custom-dab.log", DisplayName = "Update file path to custom location.")]
+ [DataRow("/var/log/dab-application.log", DisplayName = "Update file path to var log directory.")]
+ [DataRow("./logs/dab.log", DisplayName = "Update file path to relative location.")]
+ public void TestUpdateTelemetryFilePath(string updatedPathValue)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update file path value
+ ConfigureOptions options = new(
+ runtimeTelemetryFilePath: updatedPathValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate the Path is updated
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File?.Path);
+ Assert.AreEqual(updatedPathValue, runtimeConfig.Runtime.Telemetry.File.Path);
+ }
+
+ ///
+ /// Tests that running "dab configure --runtime.telemetry.file.rolling-interval" on a config with various values results
+ /// in runtime config update. Takes in updated value for telemetry file rolling interval and
+ /// validates whether the runtime config reflects those updated values
+ ///
+ [DataTestMethod]
+ [DataRow(RollingInterval.Hour, DisplayName = "Update rolling interval to Hour.")]
+ [DataRow(RollingInterval.Day, DisplayName = "Update rolling interval to Day.")]
+ [DataRow(RollingInterval.Week, DisplayName = "Update rolling interval to Week.")]
+ public void TestUpdateTelemetryFileRollingInterval(RollingInterval updatedRollingIntervalValue)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update rolling interval value
+ ConfigureOptions options = new(
+ runtimeTelemetryFileRollingInterval: updatedRollingIntervalValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate the Rolling Interval is updated
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File?.RollingInterval);
+ Assert.AreEqual(updatedRollingIntervalValue, runtimeConfig.Runtime.Telemetry.File.RollingInterval);
+ }
+
+ ///
+ /// Tests that running "dab configure --runtime.telemetry.file.retained-file-count-limit" on a config with various values results
+ /// in runtime config update. Takes in updated value for retained file count limit and
+ /// validates whether the runtime config reflects those updated values
+ ///
+ [DataTestMethod]
+ [DataRow(1, DisplayName = "Update retained file count limit to 1.")]
+ [DataRow(7, DisplayName = "Update retained file count limit to 7.")]
+ [DataRow(30, DisplayName = "Update retained file count limit to 30.")]
+ public void TestUpdateTelemetryFileRetainedFileCountLimit(int updatedRetainedFileCountLimitValue)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update retained file count limit value
+ ConfigureOptions options = new(
+ runtimeTelemetryFileRetainedFileCountLimit: updatedRetainedFileCountLimitValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate the Retained File Count Limit is updated
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File?.RetainedFileCountLimit);
+ Assert.AreEqual(updatedRetainedFileCountLimitValue, runtimeConfig.Runtime.Telemetry.File.RetainedFileCountLimit);
+ }
+
+ ///
+ /// Tests that running "dab configure --runtime.telemetry.file.file-size-limit-bytes" on a config with various values results
+ /// in runtime config update. Takes in updated value for file size limit bytes and
+ /// validates whether the runtime config reflects those updated values
+ ///
+ [DataTestMethod]
+ [DataRow(1048576, DisplayName = "Update file size limit to 1MB.")]
+ [DataRow(10485760, DisplayName = "Update file size limit to 10MB.")]
+ [DataRow(104857600, DisplayName = "Update file size limit to 100MB.")]
+ public void TestUpdateTelemetryFileFileSizeLimitBytes(int updatedFileSizeLimitBytesValue)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update file size limit bytes value
+ ConfigureOptions options = new(
+ runtimeTelemetryFileFileSizeLimitBytes: updatedFileSizeLimitBytesValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate the File Size Limit Bytes is updated
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File?.FileSizeLimitBytes);
+ Assert.AreEqual(updatedFileSizeLimitBytesValue, runtimeConfig.Runtime.Telemetry.File.FileSizeLimitBytes);
+ }
+
+ ///
+ /// Tests that validation fails when invalid values are provided for retained file count limit and file size limit
+ ///
+ [DataTestMethod]
+ [DataRow(0, "retained-file-count-limit", DisplayName = "Fail when retained file count limit is 0.")]
+ [DataRow(-1, "retained-file-count-limit", DisplayName = "Fail when retained file count limit is negative.")]
+ [DataRow(0, "file-size-limit-bytes", DisplayName = "Fail when file size limit is 0.")]
+ [DataRow(-1, "file-size-limit-bytes", DisplayName = "Fail when file size limit is negative.")]
+ public void TestTelemetryFileConfigurationValidationFailures(int invalidValue, string optionType)
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ ConfigureOptions options;
+ if (optionType == "retained-file-count-limit")
+ {
+ options = new ConfigureOptions(
+ runtimeTelemetryFileRetainedFileCountLimit: invalidValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ }
+ else
+ {
+ options = new ConfigureOptions(
+ runtimeTelemetryFileFileSizeLimitBytes: invalidValue,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ }
+
+ // Act: Attempts to update with invalid value
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate that configuration fails
+ Assert.IsFalse(isSuccess);
+ }
+
+ ///
+ /// Tests that multiple file sink telemetry options can be configured in a single command
+ ///
+ [TestMethod]
+ public void TestUpdateMultipleTelemetryFileOptions()
+ {
+ // Arrange -> all the setup which includes creating options.
+ SetupFileSystemWithInitialConfig(INITIAL_CONFIG);
+
+ // Act: Attempts to update multiple file options at once
+ ConfigureOptions options = new(
+ runtimeTelemetryFileEnabled: true,
+ runtimeTelemetryFilePath: "/var/log/custom-dab.log",
+ runtimeTelemetryFileRollingInterval: RollingInterval.Week,
+ runtimeTelemetryFileRetainedFileCountLimit: 14,
+ runtimeTelemetryFileFileSizeLimitBytes: 52428800,
+ config: TEST_RUNTIME_CONFIG_FILE
+ );
+ bool isSuccess = TryConfigureSettings(options, _runtimeConfigLoader!, _fileSystem!);
+
+ // Assert: Validate all options are updated correctly
+ Assert.IsTrue(isSuccess);
+ string updatedConfig = _fileSystem!.File.ReadAllText(TEST_RUNTIME_CONFIG_FILE);
+ Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(updatedConfig, out RuntimeConfig? runtimeConfig));
+
+ Assert.IsNotNull(runtimeConfig.Runtime?.Telemetry?.File);
+ var fileOptions = runtimeConfig.Runtime.Telemetry.File;
+
+ Assert.AreEqual(true, fileOptions.Enabled);
+ Assert.AreEqual("/var/log/custom-dab.log", fileOptions.Path);
+ Assert.AreEqual(RollingInterval.Week, fileOptions.RollingInterval);
+ Assert.AreEqual(14, fileOptions.RetainedFileCountLimit);
+ Assert.AreEqual(52428800, fileOptions.FileSizeLimitBytes);
+ }
}
}
diff --git a/src/Cli/Commands/ConfigureOptions.cs b/src/Cli/Commands/ConfigureOptions.cs
index a11d6b65f9..457701da15 100644
--- a/src/Cli/Commands/ConfigureOptions.cs
+++ b/src/Cli/Commands/ConfigureOptions.cs
@@ -42,6 +42,11 @@ public ConfigureOptions(
string? runtimeHostAuthenticationProvider = null,
string? runtimeHostAuthenticationJwtAudience = null,
string? runtimeHostAuthenticationJwtIssuer = null,
+ bool? runtimeTelemetryFileEnabled = null,
+ string? runtimeTelemetryFilePath = null,
+ RollingInterval? runtimeTelemetryFileRollingInterval = null,
+ int? runtimeTelemetryFileRetainedFileCountLimit = null,
+ int? runtimeTelemetryFileFileSizeLimitBytes = null,
string? config = null)
: base(config)
{
@@ -72,6 +77,12 @@ public ConfigureOptions(
RuntimeHostAuthenticationProvider = runtimeHostAuthenticationProvider;
RuntimeHostAuthenticationJwtAudience = runtimeHostAuthenticationJwtAudience;
RuntimeHostAuthenticationJwtIssuer = runtimeHostAuthenticationJwtIssuer;
+ // File Sink Telemetry
+ RuntimeTelemetryFileEnabled = runtimeTelemetryFileEnabled;
+ RuntimeTelemetryFilePath = runtimeTelemetryFilePath;
+ RuntimeTelemetryFileRollingInterval = runtimeTelemetryFileRollingInterval;
+ RuntimeTelemetryFileRetainedFileCountLimit = runtimeTelemetryFileRetainedFileCountLimit;
+ RuntimeTelemetryFileFileSizeLimitBytes = runtimeTelemetryFileFileSizeLimitBytes;
}
[Option("data-source.database-type", Required = false, HelpText = "Database type. Allowed values: MSSQL, PostgreSQL, CosmosDB_NoSQL, MySQL.")]
@@ -140,6 +151,21 @@ public ConfigureOptions(
[Option("runtime.host.authentication.jwt.issuer", Required = false, HelpText = "Configure the entity that issued the Jwt Token.")]
public string? RuntimeHostAuthenticationJwtIssuer { get; }
+ [Option("runtime.telemetry.file.enabled", Required = false, HelpText = "Enable/disable file sink telemetry logging. Default: false (boolean).")]
+ public bool? RuntimeTelemetryFileEnabled { get; }
+
+ [Option("runtime.telemetry.file.path", Required = false, HelpText = "File path for telemetry logs. Default: '/logs/dab-log.txt' (string).")]
+ public string? RuntimeTelemetryFilePath { get; }
+
+ [Option("runtime.telemetry.file.rolling-interval", Required = false, HelpText = "Rolling interval for log files. Default: Day. Allowed values: Hour, Day, Week.")]
+ public RollingInterval? RuntimeTelemetryFileRollingInterval { get; }
+
+ [Option("runtime.telemetry.file.retained-file-count-limit", Required = false, HelpText = "Maximum number of retained log files. Default: 1 (integer, minimum: 1).")]
+ public int? RuntimeTelemetryFileRetainedFileCountLimit { get; }
+
+ [Option("runtime.telemetry.file.file-size-limit-bytes", Required = false, HelpText = "Maximum file size in bytes before rolling. Default: 1048576 (integer, minimum: 1).")]
+ public int? RuntimeTelemetryFileFileSizeLimitBytes { get; }
+
public int Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem)
{
logger.LogInformation("{productName} {version}", PRODUCT_NAME, ProductInfo.GetProductVersion());
diff --git a/src/Cli/ConfigGenerator.cs b/src/Cli/ConfigGenerator.cs
index 7655b84cee..7fc0781224 100644
--- a/src/Cli/ConfigGenerator.cs
+++ b/src/Cli/ConfigGenerator.cs
@@ -773,6 +773,29 @@ private static bool TryUpdateConfiguredRuntimeOptions(
}
}
+ // Telemetry File: Enabled, Path, Rolling-Interval, Retained-File-Count-Limit, File-Size-Limit-Bytes
+ if (options.RuntimeTelemetryFileEnabled != null ||
+ options.RuntimeTelemetryFilePath != null ||
+ options.RuntimeTelemetryFileRollingInterval != null ||
+ options.RuntimeTelemetryFileRetainedFileCountLimit != null ||
+ options.RuntimeTelemetryFileFileSizeLimitBytes != null)
+ {
+ TelemetryOptions? currentTelemetryOptions = runtimeConfig?.Runtime?.Telemetry;
+ Azure.DataApiBuilder.Config.ObjectModel.FileOptions? updatedFileOptions = currentTelemetryOptions?.File ?? new();
+ bool status = TryUpdateConfiguredTelemetryFileValues(options, ref updatedFileOptions);
+ if (status)
+ {
+ TelemetryOptions updatedTelemetryOptions = currentTelemetryOptions is null
+ ? new TelemetryOptions(File: updatedFileOptions)
+ : currentTelemetryOptions with { File = updatedFileOptions };
+ runtimeConfig = runtimeConfig! with { Runtime = runtimeConfig.Runtime! with { Telemetry = updatedTelemetryOptions } };
+ }
+ else
+ {
+ return false;
+ }
+ }
+
return runtimeConfig != null;
}
@@ -1990,5 +2013,79 @@ public static bool TryAddTelemetry(AddTelemetryOptions options, FileSystemRuntim
return WriteRuntimeConfigToFile(runtimeConfigFile, runtimeConfig, fileSystem);
}
+
+ ///
+ /// Attempts to update the Config parameters in the Telemetry File runtime settings based on the provided value.
+ /// Validates that any user-provided parameter value is valid and then returns true if the updated File options
+ /// need to be overwritten on the existing config parameters
+ ///
+ /// options.
+ /// updatedFileOptions.
+ /// True if the value needs to be updated in the runtime config, else false
+ private static bool TryUpdateConfiguredTelemetryFileValues(
+ ConfigureOptions options,
+ ref Azure.DataApiBuilder.Config.ObjectModel.FileOptions? updatedFileOptions)
+ {
+ object? updatedValue;
+ try
+ {
+ // Runtime.Telemetry.File.Enabled
+ updatedValue = options?.RuntimeTelemetryFileEnabled;
+ if (updatedValue != null)
+ {
+ updatedFileOptions = updatedFileOptions! with { Enabled = (bool)updatedValue };
+ _logger.LogInformation("Updated RuntimeConfig with Runtime.Telemetry.File.Enabled as '{updatedValue}'", updatedValue);
+ }
+
+ // Runtime.Telemetry.File.Path
+ updatedValue = options?.RuntimeTelemetryFilePath;
+ if (updatedValue != null)
+ {
+ updatedFileOptions = updatedFileOptions! with { Path = (string)updatedValue };
+ _logger.LogInformation("Updated RuntimeConfig with Runtime.Telemetry.File.Path as '{updatedValue}'", updatedValue);
+ }
+
+ // Runtime.Telemetry.File.Rolling-Interval
+ updatedValue = options?.RuntimeTelemetryFileRollingInterval;
+ if (updatedValue != null)
+ {
+ updatedFileOptions = updatedFileOptions! with { RollingInterval = (RollingInterval)updatedValue };
+ _logger.LogInformation("Updated RuntimeConfig with Runtime.Telemetry.File.Rolling-Interval as '{updatedValue}'", updatedValue);
+ }
+
+ // Runtime.Telemetry.File.Retained-File-Count-Limit
+ updatedValue = options?.RuntimeTelemetryFileRetainedFileCountLimit;
+ if (updatedValue != null)
+ {
+ if ((int)updatedValue < 1)
+ {
+ _logger.LogError("Runtime.Telemetry.File.Retained-File-Count-Limit must be at least 1. Provided value: {updatedValue}", updatedValue);
+ return false;
+ }
+ updatedFileOptions = updatedFileOptions! with { RetainedFileCountLimit = (int)updatedValue };
+ _logger.LogInformation("Updated RuntimeConfig with Runtime.Telemetry.File.Retained-File-Count-Limit as '{updatedValue}'", updatedValue);
+ }
+
+ // Runtime.Telemetry.File.File-Size-Limit-Bytes
+ updatedValue = options?.RuntimeTelemetryFileFileSizeLimitBytes;
+ if (updatedValue != null)
+ {
+ if ((int)updatedValue < 1)
+ {
+ _logger.LogError("Runtime.Telemetry.File.File-Size-Limit-Bytes must be at least 1. Provided value: {updatedValue}", updatedValue);
+ return false;
+ }
+ updatedFileOptions = updatedFileOptions! with { FileSizeLimitBytes = (int)updatedValue };
+ _logger.LogInformation("Updated RuntimeConfig with Runtime.Telemetry.File.File-Size-Limit-Bytes as '{updatedValue}'", updatedValue);
+ }
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError("Failed to update RuntimeConfig.Telemetry.File with exception message: {exceptionMessage}.", ex.Message);
+ return false;
+ }
+ }
}
}
diff --git a/src/Config/ObjectModel/FileOptions.cs b/src/Config/ObjectModel/FileOptions.cs
new file mode 100644
index 0000000000..ef27920db7
--- /dev/null
+++ b/src/Config/ObjectModel/FileOptions.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using System.Text.Json.Serialization;
+
+namespace Azure.DataApiBuilder.Config.ObjectModel;
+
+///
+/// Represents the options for configuring file sink telemetry.
+///
+public record FileOptions(
+ bool Enabled = false,
+ string Path = "/logs/dab-log.txt",
+ RollingInterval RollingInterval = RollingInterval.Day,
+ int RetainedFileCountLimit = 1,
+ int FileSizeLimitBytes = 1048576)
+{
+ [JsonPropertyName("rolling-interval")]
+ public RollingInterval RollingInterval { get; init; } = RollingInterval;
+
+ [JsonPropertyName("retained-file-count-limit")]
+ public int RetainedFileCountLimit { get; init; } = RetainedFileCountLimit;
+
+ [JsonPropertyName("file-size-limit-bytes")]
+ public int FileSizeLimitBytes { get; init; } = FileSizeLimitBytes;
+}
+
+///
+/// Represents the rolling interval options for file sink.
+///
+[JsonConverter(typeof(JsonStringEnumConverter))]
+public enum RollingInterval
+{
+ Hour,
+ Day,
+ Week
+}
\ No newline at end of file
diff --git a/src/Config/ObjectModel/TelemetryOptions.cs b/src/Config/ObjectModel/TelemetryOptions.cs
index ed2099f2a4..68c3d17b37 100644
--- a/src/Config/ObjectModel/TelemetryOptions.cs
+++ b/src/Config/ObjectModel/TelemetryOptions.cs
@@ -9,7 +9,7 @@ namespace Azure.DataApiBuilder.Config.ObjectModel;
///
/// Represents the options for telemetry.
///
-public record TelemetryOptions(ApplicationInsightsOptions? ApplicationInsights = null, OpenTelemetryOptions? OpenTelemetry = null, Dictionary? LoggerLevel = null)
+public record TelemetryOptions(ApplicationInsightsOptions? ApplicationInsights = null, OpenTelemetryOptions? OpenTelemetry = null, FileOptions? File = null, Dictionary? LoggerLevel = null)
{
[JsonPropertyName("log-level")]
public Dictionary? LoggerLevel { get; init; } = LoggerLevel;