Skip to content

Commit 8ea24db

Browse files
Change property name of log-type to dab-identifier for Azure Log Analytics (#2805)
## Why make this change? - This change closes issue #2804 The property `log-type` had a change in function, which also means that there needs to be a change in name. ## What is this change? Only changes the name of the property from `log-type` to `dab-identifier` since the changes in logic related to the changes in function were already implemented beforehand. ## How was this tested? - [ ] Integration Tests - [ ] Unit Tests - [X] Manual Tests Tested if the new property is serialized and deserialized correctly and if `configure` command works as expected with new property, while leaving no traces of the old property. ## Sample Request(s) --runtime.telemetry.azure-log-analytics.dab-identifier
1 parent 75d9381 commit 8ea24db

File tree

11 files changed

+46
-46
lines changed

11 files changed

+46
-46
lines changed

schemas/dab.draft.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@
437437
}
438438
}
439439
},
440-
"log-type": {
440+
"dab-identifier": {
441441
"type": "string",
442-
"description": "Custom log table name in Log Analytics",
442+
"description": "Identifier passed on to Log Analytics",
443443
"default": "DabLogs"
444444
},
445445
"flush-interval-seconds": {

src/Cli.Tests/ConfigureOptionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void TestAddAzureLogAnalyticsOptions()
162162
// Act: Attempts to add Azure Log Analytics options
163163
ConfigureOptions options = new(
164164
azureLogAnalyticsEnabled: CliBool.True,
165-
azureLogAnalyticsLogType: "log-type-test",
165+
azureLogAnalyticsDabIdentifier: "dab-identifier-test",
166166
azureLogAnalyticsFlushIntervalSeconds: 1,
167167
azureLogAnalyticsCustomTableName: "custom-table-name-test",
168168
azureLogAnalyticsDcrImmutableId: "dcr-immutable-id-test",
@@ -180,7 +180,7 @@ public void TestAddAzureLogAnalyticsOptions()
180180
Assert.IsNotNull(config.Runtime.Telemetry);
181181
Assert.IsNotNull(config.Runtime.Telemetry.AzureLogAnalytics);
182182
Assert.AreEqual(true, config.Runtime.Telemetry.AzureLogAnalytics.Enabled);
183-
Assert.AreEqual("log-type-test", config.Runtime.Telemetry.AzureLogAnalytics.LogType);
183+
Assert.AreEqual("dab-identifier-test", config.Runtime.Telemetry.AzureLogAnalytics.DabIdentifier);
184184
Assert.AreEqual(1, config.Runtime.Telemetry.AzureLogAnalytics.FlushIntervalSeconds);
185185
Assert.IsNotNull(config.Runtime.Telemetry.AzureLogAnalytics.Auth);
186186
Assert.AreEqual("custom-table-name-test", config.Runtime.Telemetry.AzureLogAnalytics.Auth.CustomTableName);

src/Cli.Tests/ValidateConfigTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public async Task TestValidateAzureLogAnalyticsOptionsWithoutAuthFails()
332332
// Act: Attempts to add Azure Log Analytics options without Auth options
333333
ConfigureOptions options = new(
334334
azureLogAnalyticsEnabled: CliBool.True,
335-
azureLogAnalyticsLogType: "log-type-test",
335+
azureLogAnalyticsDabIdentifier: "dab-identifier-test",
336336
azureLogAnalyticsFlushIntervalSeconds: 1,
337337
config: TEST_RUNTIME_CONFIG_FILE
338338
);

src/Cli/Commands/ConfigureOptions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public ConfigureOptions(
4949
int? azureKeyVaultRetryPolicyMaxDelaySeconds = null,
5050
int? azureKeyVaultRetryPolicyNetworkTimeoutSeconds = null,
5151
CliBool? azureLogAnalyticsEnabled = null,
52-
string? azureLogAnalyticsLogType = null,
52+
string? azureLogAnalyticsDabIdentifier = null,
5353
int? azureLogAnalyticsFlushIntervalSeconds = null,
5454
string? azureLogAnalyticsCustomTableName = null,
5555
string? azureLogAnalyticsDcrImmutableId = null,
@@ -93,7 +93,7 @@ public ConfigureOptions(
9393
AzureKeyVaultRetryPolicyNetworkTimeoutSeconds = azureKeyVaultRetryPolicyNetworkTimeoutSeconds;
9494
// Azure Log Analytics
9595
AzureLogAnalyticsEnabled = azureLogAnalyticsEnabled;
96-
AzureLogAnalyticsLogType = azureLogAnalyticsLogType;
96+
AzureLogAnalyticsDabIdentifier = azureLogAnalyticsDabIdentifier;
9797
AzureLogAnalyticsFlushIntervalSeconds = azureLogAnalyticsFlushIntervalSeconds;
9898
AzureLogAnalyticsCustomTableName = azureLogAnalyticsCustomTableName;
9999
AzureLogAnalyticsDcrImmutableId = azureLogAnalyticsDcrImmutableId;
@@ -187,8 +187,8 @@ public ConfigureOptions(
187187
[Option("runtime.telemetry.azure-log-analytics.enabled", Required = false, HelpText = "Enable/Disable Azure Log Analytics. Default: False (boolean)")]
188188
public CliBool? AzureLogAnalyticsEnabled { get; }
189189

190-
[Option("runtime.telemetry.azure-log-analytics.log-type", Required = false, HelpText = "Configure Log Type for Azure Log Analytics to find table to send telemetry data. Default: DABLogs")]
191-
public string? AzureLogAnalyticsLogType { get; }
190+
[Option("runtime.telemetry.azure-log-analytics.dab-identifier", Required = false, HelpText = "Configure DAB Identifier to allow user to differentiate which logs come from DAB in Azure Log Analytics . Default: DABLogs")]
191+
public string? AzureLogAnalyticsDabIdentifier { get; }
192192

193193
[Option("runtime.telemetry.azure-log-analytics.flush-interval-seconds", Required = false, HelpText = "Configure Flush Interval in seconds for Azure Log Analytics to specify the time interval to send the telemetry data. Default: 5")]
194194
public int? AzureLogAnalyticsFlushIntervalSeconds { get; }

src/Cli/ConfigGenerator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ private static bool TryUpdateConfiguredRuntimeOptions(
780780

781781
// Telemetry: Azure Log Analytics
782782
if (options.AzureLogAnalyticsEnabled is not null ||
783-
options.AzureLogAnalyticsLogType is not null ||
783+
options.AzureLogAnalyticsDabIdentifier is not null ||
784784
options.AzureLogAnalyticsFlushIntervalSeconds is not null ||
785785
options.AzureLogAnalyticsCustomTableName is not null ||
786786
options.AzureLogAnalyticsDcrImmutableId is not null ||
@@ -1137,11 +1137,11 @@ private static bool TryUpdateConfiguredAzureLogAnalyticsOptions(
11371137
_logger.LogInformation($"Updated configuration with runtime.telemetry.azure-log-analytics.enabled as '{options.AzureLogAnalyticsEnabled}'");
11381138
}
11391139

1140-
// Runtime.Telemetry.AzureLogAnalytics.LogType
1141-
if (options.AzureLogAnalyticsLogType is not null)
1140+
// Runtime.Telemetry.AzureLogAnalytics.DabIdentifier
1141+
if (options.AzureLogAnalyticsDabIdentifier is not null)
11421142
{
1143-
azureLogAnalyticsOptions = azureLogAnalyticsOptions with { LogType = options.AzureLogAnalyticsLogType, UserProvidedLogType = true };
1144-
_logger.LogInformation($"Updated configuration with runtime.telemetry.azure-log-analytics.log-type as '{options.AzureLogAnalyticsLogType}'");
1143+
azureLogAnalyticsOptions = azureLogAnalyticsOptions with { DabIdentifier = options.AzureLogAnalyticsDabIdentifier, UserProvidedDabIdentifier = true };
1144+
_logger.LogInformation($"Updated configuration with runtime.telemetry.azure-log-analytics.dab-identifier as '{options.AzureLogAnalyticsDabIdentifier}'");
11451145
}
11461146

11471147
// Runtime.Telemetry.AzureLogAnalytics.FlushIntervalSeconds

src/Config/Converters/AzureLogAnalyticsOptionsConverterFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal AzureLogAnalyticsOptionsConverter(bool replaceEnvVar)
8888
auth = authOptionsConverter.Read(ref reader, typeToConvert, options);
8989
break;
9090

91-
case "log-type":
91+
case "dab-identifier":
9292
if (reader.TokenType is not JsonTokenType.Null)
9393
{
9494
logType = reader.DeserializeString(_replaceEnvVar);
@@ -150,10 +150,10 @@ public override void Write(Utf8JsonWriter writer, AzureLogAnalyticsOptions value
150150
authOptionsConverter.Write(writer, value.Auth, options);
151151
}
152152

153-
if (value?.UserProvidedLogType is true)
153+
if (value?.UserProvidedDabIdentifier is true)
154154
{
155-
writer.WritePropertyName("log-type");
156-
JsonSerializer.Serialize(writer, value.LogType, options);
155+
writer.WritePropertyName("dab-identifier");
156+
JsonSerializer.Serialize(writer, value.DabIdentifier, options);
157157
}
158158

159159
if (value?.UserProvidedFlushIntervalSeconds is true)

src/Config/ObjectModel/AzureLogAnalyticsLogs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public class AzureLogAnalyticsLogs
1212
public string LogLevel { get; set; }
1313
public string? Message { get; set; }
1414
public string? Component { get; set; }
15-
public string? LogType { get; set; }
15+
public string? Identifier { get; set; }
1616

17-
public AzureLogAnalyticsLogs(string time, string logLevel, string? message, string? component, string? logType = null)
17+
public AzureLogAnalyticsLogs(string time, string logLevel, string? message, string? component, string? identifier = null)
1818
{
1919
Time = time;
2020
LogLevel = logLevel;
2121
Message = message;
2222
Component = component;
23-
LogType = logType;
23+
Identifier = identifier;
2424
}
2525
}

src/Config/ObjectModel/AzureLogAnalyticsOptions.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public record AzureLogAnalyticsOptions
2121
/// <summary>
2222
/// Default log type for Azure Log Analytics.
2323
/// </summary>
24-
public const string DEFAULT_LOG_TYPE = "DabLogs";
24+
public const string DEFAULT_DAB_IDENTIFIER = "DabLogs";
2525

2626
/// <summary>
2727
/// Default flush interval in seconds.
@@ -39,17 +39,17 @@ public record AzureLogAnalyticsOptions
3939
public AzureLogAnalyticsAuthOptions? Auth { get; init; }
4040

4141
/// <summary>
42-
/// Custom log table name in Log Analytics.
42+
/// Custom identifier name to send to Log Analytics.
4343
/// </summary>
44-
public string? LogType { get; init; }
44+
public string? DabIdentifier { get; init; }
4545

4646
/// <summary>
4747
/// Interval between log batch pushes (in seconds).
4848
/// </summary>
4949
public int? FlushIntervalSeconds { get; init; }
5050

5151
[JsonConstructor]
52-
public AzureLogAnalyticsOptions(bool? enabled = null, AzureLogAnalyticsAuthOptions? auth = null, string? logType = null, int? flushIntervalSeconds = null)
52+
public AzureLogAnalyticsOptions(bool? enabled = null, AzureLogAnalyticsAuthOptions? auth = null, string? dabIdentifier = null, int? flushIntervalSeconds = null)
5353
{
5454
Auth = auth;
5555

@@ -63,14 +63,14 @@ public AzureLogAnalyticsOptions(bool? enabled = null, AzureLogAnalyticsAuthOptio
6363
Enabled = DEFAULT_ENABLED;
6464
}
6565

66-
if (logType is not null)
66+
if (dabIdentifier is not null)
6767
{
68-
LogType = logType;
69-
UserProvidedLogType = true;
68+
DabIdentifier = dabIdentifier;
69+
UserProvidedDabIdentifier = true;
7070
}
7171
else
7272
{
73-
LogType = DEFAULT_LOG_TYPE;
73+
DabIdentifier = DEFAULT_DAB_IDENTIFIER;
7474
}
7575

7676
if (flushIntervalSeconds is not null)
@@ -95,14 +95,14 @@ public AzureLogAnalyticsOptions(bool? enabled = null, AzureLogAnalyticsAuthOptio
9595
public bool UserProvidedEnabled { get; init; } = false;
9696

9797
/// <summary>
98-
/// Flag which informs CLI and JSON serializer whether to write log-type
98+
/// Flag which informs CLI and JSON serializer whether to write dab-identifier
9999
/// property and value to the runtime config file.
100-
/// When user doesn't provide the log-type property/value, which signals DAB to use the default,
100+
/// When user doesn't provide the dab-identifier property/value, which signals DAB to use the default,
101101
/// the DAB CLI should not write the default value to a serialized config.
102102
/// </summary>
103103
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
104-
[MemberNotNullWhen(true, nameof(LogType))]
105-
public bool UserProvidedLogType { get; init; } = false;
104+
[MemberNotNullWhen(true, nameof(DabIdentifier))]
105+
public bool UserProvidedDabIdentifier { get; init; } = false;
106106

107107
/// <summary>
108108
/// Flag which informs CLI and JSON serializer whether to write flush-interval-seconds

src/Service.Tests/Configuration/ConfigurationTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,22 +4080,22 @@ public void AzureLogAnalyticsSerialization(
40804080
string? customTableName,
40814081
string? dcrImmutableId,
40824082
string? dceEndpoint,
4083-
string? logType,
4083+
string? dabIdentifier,
40844084
int? flushIntSec,
40854085
bool expectedEnabled,
4086-
string expectedLogType,
4086+
string expectedDabIdentifier,
40874087
int expectedFlushIntSec)
40884088
{
40894089
//Check if auth property and its values are expected to exist
40904090
bool expectedExistEnabled = enabled is not null;
4091-
bool expectedExistLogType = logType is not null;
4091+
bool expectedExistDabIdentifier = dabIdentifier is not null;
40924092
bool expectedExistFlushIntSec = flushIntSec is not null;
40934093
bool expectedExistCustomTableName = customTableName is not null;
40944094
bool expectedExistDcrImmutableId = dcrImmutableId is not null;
40954095
bool expectedExistDceEndpoint = dceEndpoint is not null;
40964096

40974097
AzureLogAnalyticsAuthOptions authOptions = new(customTableName, dcrImmutableId, dceEndpoint);
4098-
AzureLogAnalyticsOptions azureLogAnalyticsOptions = new(enabled, authOptions, logType, flushIntSec);
4098+
AzureLogAnalyticsOptions azureLogAnalyticsOptions = new(enabled, authOptions, dabIdentifier, flushIntSec);
40994099
RuntimeConfig configWithCustomLogLevel = InitializeRuntimeWithAzureLogAnalytics(azureLogAnalyticsOptions);
41004100
string configWithCustomLogLevelJson = configWithCustomLogLevel.ToJson();
41014101
Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(configWithCustomLogLevelJson, out RuntimeConfig? deserializedRuntimeConfig));
@@ -4120,11 +4120,11 @@ public void AzureLogAnalyticsSerialization(
41204120
Assert.AreEqual(expectedEnabled, enabledElement.GetBoolean());
41214121
}
41224122

4123-
bool logTypeExists = azureLogAnalyticsElement.TryGetProperty("log-type", out JsonElement logTypeElement);
4124-
Assert.AreEqual(expected: expectedExistLogType, actual: logTypeExists);
4125-
if (logTypeExists)
4123+
bool dabIdentifierExists = azureLogAnalyticsElement.TryGetProperty("dab-identifier", out JsonElement dabIdentifierElement);
4124+
Assert.AreEqual(expected: expectedExistDabIdentifier, actual: dabIdentifierExists);
4125+
if (dabIdentifierExists)
41264126
{
4127-
Assert.AreEqual(expectedLogType, logTypeElement.GetString());
4127+
Assert.AreEqual(expectedDabIdentifier, dabIdentifierElement.GetString());
41284128
}
41294129

41304130
bool flushIntSecExists = azureLogAnalyticsElement.TryGetProperty("flush-interval-seconds", out JsonElement flushIntSecElement);

src/Service/Telemetry/AzureLogAnalyticsCustomLogCollector.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Azure.DataApiBuilder.Service.Telemetry;
1717
public interface ICustomLogCollector
1818
{
1919
Task LogAsync(string message, LogLevel loggingLevel, string? source = null);
20-
Task<List<AzureLogAnalyticsLogs>> DequeueAllAsync(string logType, int flushIntervalSeconds);
20+
Task<List<AzureLogAnalyticsLogs>> DequeueAllAsync(string dabIdentifier, int flushIntervalSeconds);
2121
}
2222

2323
/// <summary>
@@ -47,10 +47,10 @@ await _logs.Writer.WriteAsync(
4747
/// <summary>
4848
/// Creates a list periodically from the logs that are currently saved.
4949
/// </summary>
50-
/// <param name="logType">Custom name to distinguish the logs sent from DAB to Azure Log Analytics.</param>
50+
/// <param name="dabIdentifier">Custom name to distinguish the logs sent from DAB to Azure Log Analytics.</param>
5151
/// <param name="flushIntervalSeconds">Period of time between each list of logs is sent.</param>
5252
/// <returns>List of logs structured to be sent to Azure Log Analytics.</returns>
53-
public async Task<List<AzureLogAnalyticsLogs>> DequeueAllAsync(string logType, int flushIntervalSeconds)
53+
public async Task<List<AzureLogAnalyticsLogs>> DequeueAllAsync(string dabIdentifier, int flushIntervalSeconds)
5454
{
5555
List<AzureLogAnalyticsLogs> list = new();
5656
Stopwatch time = Stopwatch.StartNew();
@@ -59,7 +59,7 @@ public async Task<List<AzureLogAnalyticsLogs>> DequeueAllAsync(string logType, i
5959
{
6060
while (_logs.Reader.TryRead(out AzureLogAnalyticsLogs? item))
6161
{
62-
item.LogType = logType;
62+
item.Identifier = dabIdentifier;
6363
list.Add(item);
6464

6565
if (time.Elapsed >= TimeSpan.FromSeconds(flushIntervalSeconds))

0 commit comments

Comments
 (0)