Skip to content

Commit 7ae6dfe

Browse files
committed
change lineage variable names
1 parent 84abfca commit 7ae6dfe

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/OpenTelemetry.Extensions.AWS/Trace/AWSXRayPropagator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class AWSXRayPropagator : TextMapPropagator
4141
private const string LineageKey = "Lineage";
4242
private const char LineageDelimiter = ':';
4343
private const int LineageHashLength = 8;
44-
private const int LineageMaxRequestCounter = 255;
45-
private const int LineageMaxLoopCounter = 32767;
44+
private const int LineageMaxCounter1 = 32767;
45+
private const int LineageMaxCounter2 = 255;
4646

4747
/// <inheritdoc/>
4848
public override ISet<string> Fields => new HashSet<string>() { AWSXRayTraceHeaderKey };
@@ -340,23 +340,23 @@ internal static bool IsLineageIdValid(string lineageId)
340340
return false;
341341
}
342342

343-
if (!int.TryParse(lineageSubstrings[0], out var requestCounter))
343+
if (!int.TryParse(lineageSubstrings[0], out var lineageCounter1))
344344
{
345345
return false;
346346
}
347347

348-
var hashedResourceId = lineageSubstrings[1];
348+
var hashedString = lineageSubstrings[1];
349349

350-
if (!int.TryParse(lineageSubstrings[2], out var loopCounter))
350+
if (!int.TryParse(lineageSubstrings[2], out var lineageCounter2))
351351
{
352352
return false;
353353
}
354354

355-
var isValidKey = hashedResourceId.Length == LineageHashLength && Regex.IsMatch(hashedResourceId, "^[0-9a-fA-F]+$");
356-
var isValidRequestCounter = requestCounter >= 0 && requestCounter <= LineageMaxRequestCounter;
357-
var isValidLoopCounter = loopCounter >= 0 && loopCounter <= LineageMaxLoopCounter;
355+
var isValidHash = hashedString.Length == LineageHashLength && Regex.IsMatch(hashedString, "^[0-9a-fA-F]+$");
356+
var isValidCounter1 = lineageCounter1 >= 0 && lineageCounter1 <= LineageMaxCounter1;
357+
var isValidCounter2 = lineageCounter2 >= 0 && lineageCounter2 <= LineageMaxCounter2;
358358

359-
return isValidKey && isValidRequestCounter && isValidLoopCounter;
359+
return isValidHash && isValidCounter1 && isValidCounter2;
360360
}
361361

362362
internal static string ToXRayTraceIdFormat(string traceId)

test/OpenTelemetry.Extensions.AWS.Tests/Trace/AWSXRayPropagatorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ public void TestExtractTraceHeaderWithInvalidLineage()
202202
"1::1",
203203
"1:badc0de:13",
204204
":fbadc0de:13",
205-
"65535:fbadc0de:255",
205+
"32768:fbadc0de:1",
206+
"1:fbadc0de:256",
206207
};
207208

208209
foreach (var invalidLineage in invalidLineages)

0 commit comments

Comments
 (0)