summaryrefslogtreecommitdiff
path: root/src/accounting/Helpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/accounting/Helpers.cs')
-rw-r--r--src/accounting/Helpers.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/accounting/Helpers.cs b/src/accounting/Helpers.cs
new file mode 100644
index 0000000..d167aae
--- /dev/null
+++ b/src/accounting/Helpers.cs
@@ -0,0 +1,34 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+using System.Collections;
+
+namespace Accounting
+{
+ internal static class Helpers
+ {
+ private static List<string> RelevantPrefixes = ["DOTNET_", "CORECLR_", "OTEL_", "KAFKA_"];
+
+ public static IEnumerable<DictionaryEntry> FilterRelevant(this IDictionary envs)
+ {
+ foreach (DictionaryEntry env in envs)
+ {
+ foreach (var prefix in RelevantPrefixes)
+ {
+ if (env.Key.ToString()?.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase) ?? false)
+ {
+ yield return env;
+ }
+ }
+ }
+ }
+
+ public static void OutputInOrder(this IEnumerable<DictionaryEntry> envs)
+ {
+ foreach (var env in envs.OrderBy(x => x.Key))
+ {
+ Console.WriteLine(env);
+ }
+ }
+ }
+}