Skip to content

Commit cc6e4f0

Browse files
committed
fix: Move TLS version tagging to after connection establishment and add error handling
1 parent dcffed1 commit cc6e4f0

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/AlbusKavaliro.TraceableLdapClient/TraceableLdapConnection.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,6 @@ private void SetNetworkTags(Activity activity)
556556

557557
activity.SetTag(OtelTags.ConnectionType, isLdaps ? "ldaps" : isEncrypted ? "starttls" : "plain");
558558
activity.SetTag(OtelTags.ConnectionEncrypted, isEncrypted);
559-
560-
// Add TLS version if available and encrypted
561-
if (isEncrypted && SessionOptions.SslInformation?.Protocol != null)
562-
{
563-
activity.SetTag(OtelTags.TlsVersion, SessionOptions.SslInformation.Protocol.ToString());
564-
}
565559
}
566560
}
567561

@@ -626,6 +620,19 @@ private void SetResponseAttributes(Activity? activity, DirectoryResponse respons
626620
activity.SetTag(OtelTags.Referrals, string.Join(',', response.Referral.Select(u => u.ToString())));
627621
}
628622

623+
// Add TLS version if available and encrypted (now that connection is established)
624+
try
625+
{
626+
if (SessionOptions.SslInformation?.Protocol != null)
627+
{
628+
activity.SetTag(OtelTags.TlsVersion, SessionOptions.SslInformation.Protocol.ToString());
629+
}
630+
}
631+
catch (Exception)
632+
{
633+
// Ignore errors when accessing SSL information
634+
}
635+
629636
SetResponseSpecificAttributes(activity, response);
630637
}
631638

0 commit comments

Comments
 (0)