Skip to content

Commit ac4cc33

Browse files
joeldicksondicko2
andauthored
Add tags for is QA (#45)
* Add tags for is QA * make changes * refactor --------- Co-authored-by: jdickson <[email protected]>
1 parent 4050870 commit ac4cc33

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/Agoda.DevFeedback.AspNetStartup/TimedStartupPublisher.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using Agoda.DevFeedback.Common;
22
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Linq;
36
using System.Reflection;
47

58
namespace Agoda.DevFeedback.AspNetStartup
@@ -8,14 +11,28 @@ internal static class TimedStartupPublisher
811
{
912
public static void Publish(string type, TimeSpan timeTaken)
1013
{
14+
const string TagPrefix = "DEVFEEDBACK_TAG_";
15+
1116
var gitContext = GitContextReader.GetGitContext();
1217

18+
// Use LINQ and dictionary comprehension for cleaner tag collection
19+
var tags = Environment.GetEnvironmentVariables()
20+
.Cast<DictionaryEntry>()
21+
.Select(entry => (Key: entry.Key.ToString()!, Value: entry.Value?.ToString()))
22+
.Where(entry => entry.Key.StartsWith(TagPrefix, StringComparison.OrdinalIgnoreCase)
23+
&& !string.IsNullOrEmpty(entry.Value))
24+
.ToDictionary(
25+
entry => entry.Key[TagPrefix.Length..].ToLowerInvariant(),
26+
entry => entry.Value!
27+
);
28+
1329
var result = new DevFeedbackData(
1430
metricsVersion: Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
1531
type: type,
1632
projectName: Assembly.GetEntryAssembly()?.GetName().Name,
1733
timeTaken: timeTaken.TotalMilliseconds.ToString(),
18-
gitContext: gitContext
34+
gitContext: gitContext,
35+
tags: tags
1936
);
2037

2138
DevFeedbackPublisher.Publish(apiEndpoint: null, result, DevLocalDataType.Build);

src/Agoda.DevFeedback.Common/DevFeedbackData.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using Newtonsoft.Json;
34

45
namespace Agoda.DevFeedback.Common
@@ -47,13 +48,16 @@ public class DevFeedbackData
4748
[JsonProperty("date")]
4849
public DateTime Date { get; set; }
4950

51+
[JsonProperty("tags")]
52+
public Dictionary<string,string> Tags { get; set; }
53+
5054
public DevFeedbackData(
5155
string metricsVersion,
5256
string type,
5357
string projectName,
5458
string timeTaken,
55-
GitContext gitContext
56-
)
59+
GitContext gitContext,
60+
Dictionary<string,string> tags = null)
5761
{
5862
Id = Guid.NewGuid();
5963
Type = type;
@@ -69,6 +73,7 @@ GitContext gitContext
6973
RepositoryName = gitContext.RepositoryName;
7074
Branch = gitContext.BranchName;
7175
Date = DateTime.UtcNow;
76+
Tags = tags;
7277
}
7378
}
7479
}

0 commit comments

Comments
 (0)