Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Activity.cs
Go to the documentation of this file.
3using System.Text;
5
6namespace System.Diagnostics;
7
8public class Activity : IDisposable
9{
10 private sealed class BaggageLinkedList : IEnumerable<KeyValuePair<string, string>>, IEnumerable
11 {
13
15
17 {
18 _first = ((set && firstValue.Value == null) ? null : new DiagNode<KeyValuePair<string, string>>(firstValue));
19 }
20
30
32 {
33 if (value.Value == null)
34 {
35 Remove(value.Key);
36 return;
37 }
38 lock (this)
39 {
41 {
42 if (diagNode.Value.Key == value.Key)
43 {
44 diagNode.Value = value;
45 return;
46 }
47 }
49 diagNode2.Next = _first;
51 }
52 }
53
54 public void Remove(string key)
55 {
56 lock (this)
57 {
58 if (_first == null)
59 {
60 return;
61 }
62 if (_first.Value.Key == key)
63 {
65 return;
66 }
68 while (diagNode.Next != null)
69 {
70 if (diagNode.Next.Value.Key == key)
71 {
72 diagNode.Next = diagNode.Next.Next;
73 break;
74 }
75 diagNode = diagNode.Next;
76 }
77 }
78 }
79
84
89
94 }
95
96 private sealed class TagsLinkedList : IEnumerable<KeyValuePair<string, object>>, IEnumerable
97 {
99
101
103
105 {
106 _last = (_first = ((set && firstValue.Value == null) ? null : new DiagNode<KeyValuePair<string, object>>(firstValue)));
107 }
108
110 {
112 while (e.MoveNext())
113 {
114 _last.Next = new DiagNode<KeyValuePair<string, object>>(e.Current);
115 _last = _last.Next;
116 }
117 }
118
123
125 {
127 if (enumerator.MoveNext())
128 {
129 if (_first == null)
130 {
132 }
133 else
134 {
135 _last.Next = new DiagNode<KeyValuePair<string, object>>(enumerator.Current);
136 _last = _last.Next;
137 }
138 while (enumerator.MoveNext())
139 {
140 _last.Next = new DiagNode<KeyValuePair<string, object>>(enumerator.Current);
141 _last = _last.Next;
142 }
143 }
144 }
145
147 {
149 lock (this)
150 {
151 if (_first == null)
152 {
153 _first = (_last = diagNode);
154 return;
155 }
156 _last.Next = diagNode;
157 _last = diagNode;
158 }
159 }
160
161 public object Get(string key)
162 {
164 {
165 if (diagNode.Value.Key == key)
166 {
167 return diagNode.Value.Value;
168 }
169 }
170 return null;
171 }
172
173 public void Remove(string key)
174 {
175 lock (this)
176 {
177 if (_first == null)
178 {
179 return;
180 }
181 if (_first.Value.Key == key)
182 {
184 if (_first == null)
185 {
186 _last = null;
187 }
188 return;
189 }
191 while (diagNode.Next != null)
192 {
193 if (diagNode.Next.Value.Key == key)
194 {
195 if (_last == diagNode.Next)
196 {
197 _last = diagNode;
198 }
199 diagNode.Next = diagNode.Next.Next;
200 break;
201 }
202 diagNode = diagNode.Next;
203 }
204 }
205 }
206
208 {
209 if (value.Value == null)
210 {
211 Remove(value.Key);
212 return;
213 }
214 lock (this)
215 {
217 {
218 if (diagNode.Value.Key == value.Key)
219 {
220 diagNode.Value = value;
221 return;
222 }
223 }
225 if (_first == null)
226 {
227 _first = (_last = diagNode2);
228 return;
229 }
230 _last.Next = diagNode2;
232 }
233 }
234
239
244
249
251 {
252 for (DiagNode<KeyValuePair<string, object>> current = _first; current != null; current = current.Next)
253 {
254 if (current.Value.Value is string || current.Value.Value == null)
255 {
256 yield return new KeyValuePair<string, string>(current.Value.Key, (string)current.Value.Value);
257 }
258 }
259 }
260
261 public override string ToString()
262 {
263 lock (this)
264 {
265 if (_first == null)
266 {
267 return string.Empty;
268 }
269 if (_stringBuilder == null)
270 {
272 }
276 for (DiagNode<KeyValuePair<string, object>> next = _first.Next; next != null; next = next.Next)
277 {
279 _stringBuilder.Append(next.Value.Key);
281 _stringBuilder.Append(next.Value.Value);
282 }
283 string result = _stringBuilder.ToString();
285 return result;
286 }
287 }
288 }
289
290 [Flags]
291 private enum State : byte
292 {
293 None = 0,
294 FormatUnknown = 0,
296 FormatW3C = 2,
297 FormatFlags = 3,
298 IsFinished = 0x80
299 }
300
302
304
305 private static readonly IEnumerable<ActivityLink> s_emptyLinks = new ActivityLink[0];
306
308
309 private static readonly ActivitySource s_defaultSource = new ActivitySource(string.Empty);
310
311 private static readonly string s_uniqSuffix = "-" + GetRandomNumber().ToString("x") + ".";
312
313 private static long s_currentRootId = (uint)GetRandomNumber();
314
316
317 private string _traceState;
318
319 private State _state;
320
321 private int _currentChildId;
322
323 private string _id;
324
325 private string _rootId;
326
327 private string _parentId;
328
329 private string _parentSpanId;
330
331 private string _traceId;
332
333 private string _spanId;
334
335 private byte _w3CIdFlags;
336
337 private byte _parentTraceFlags;
338
340
342
344
346
348
349 private string _displayName;
350
352
353 private string _statusDescription;
354
356
357 private static readonly AsyncLocal<Activity> s_current = new AsyncLocal<Activity>();
358
359 public static bool ForceDefaultIdFormat { get; set; }
360
362
364
365 public ActivityKind Kind { get; private set; }
366
367 public string OperationName { get; }
368
369 public string DisplayName
370 {
371 get
372 {
373 return _displayName ?? OperationName;
374 }
375 set
376 {
377 _displayName = value ?? throw new ArgumentNullException("value");
378 }
379 }
380
381 public ActivitySource Source { get; private set; }
382
383 public Activity? Parent { get; private set; }
384
385 public TimeSpan Duration { get; private set; }
386
387 public DateTime StartTimeUtc { get; private set; }
388
389 public string? Id
390 {
391 get
392 {
393 if (_id == null && _spanId != null)
394 {
395 Span<char> buffer = stackalloc char[2];
397 string value = "00-" + _traceId + "-" + _spanId + "-" + buffer;
399 }
400 return _id;
401 }
402 }
403
404 public string? ParentId
405 {
406 get
407 {
408 if (_parentId == null)
409 {
410 if (_parentSpanId != null)
411 {
412 Span<char> buffer = stackalloc char[2];
414 string value = "00-" + _traceId + "-" + _parentSpanId + "-" + buffer;
416 }
417 else if (Parent != null)
418 {
420 }
421 }
422 return _parentId;
423 }
424 }
425
426 public string? RootId
427 {
428 get
429 {
430 if (_rootId == null)
431 {
432 string text = null;
433 if (Id != null)
434 {
435 text = GetRootId(Id);
436 }
437 else if (ParentId != null)
438 {
440 }
441 if (text != null)
442 {
444 }
445 }
446 return _rootId;
447 }
448 }
449
451
453 {
454 get
455 {
457 return tags ?? s_emptyTagObjects;
458 }
459 }
460
462 {
463 get
464 {
466 return events ?? s_emptyEvents;
467 }
468 }
469
471 {
472 get
473 {
475 return links ?? s_emptyLinks;
476 }
477 }
478
480 {
481 get
482 {
483 for (Activity activity2 = this; activity2 != null; activity2 = activity2.Parent)
484 {
485 if (activity2._baggage != null)
486 {
487 return Iterate(activity2);
488 }
489 }
490 return s_emptyBaggageTags;
492 {
493 do
494 {
495 if (activity._baggage != null)
496 {
497 for (DiagNode<KeyValuePair<string, string>> current = activity._baggage.First; current != null; current = current.Next)
498 {
499 yield return current.Value;
500 }
501 }
502 activity = activity.Parent;
503 }
504 while (activity != null);
505 }
506 }
507 }
508
510
511 public string? TraceStateString
512 {
513 get
514 {
515 for (Activity activity = this; activity != null; activity = activity.Parent)
516 {
517 string traceState = activity._traceState;
518 if (traceState != null)
519 {
520 return traceState;
521 }
522 }
523 return null;
524 }
525 set
526 {
528 }
529 }
530
532 {
533 get
534 {
535 if (_spanId == null && _id != null && IdFormat == ActivityIdFormat.W3C)
536 {
537 string value = ActivitySpanId.CreateFromString(_id.AsSpan(36, 16)).ToHexString();
539 }
540 return new ActivitySpanId(_spanId);
541 }
542 }
543
545 {
546 get
547 {
548 if (_traceId == null)
549 {
551 }
552 return new ActivityTraceId(_traceId);
553 }
554 }
555
556 public bool Recorded => (ActivityTraceFlags & ActivityTraceFlags.Recorded) != 0;
557
558 public bool IsAllDataRequested { get; set; }
559
561 {
562 get
563 {
564 if (!W3CIdFlagsSet)
565 {
567 }
568 return (ActivityTraceFlags)(-129 & (int)_w3CIdFlags);
569 }
570 set
571 {
572 _w3CIdFlags = (byte)(0x80u | (byte)value);
573 }
574 }
575
577 {
578 get
579 {
580 if (_parentSpanId == null)
581 {
582 string text = null;
583 if (_parentId != null && IsW3CId(_parentId))
584 {
585 try
586 {
587 text = ActivitySpanId.CreateFromString(_parentId.AsSpan(36, 16)).ToHexString();
588 }
589 catch
590 {
591 }
592 }
593 else if (Parent != null && Parent.IdFormat == ActivityIdFormat.W3C)
594 {
596 }
597 if (text != null)
598 {
600 }
601 }
602 return new ActivitySpanId(_parentSpanId);
603 }
604 }
605
606 public static Func<ActivityTraceId>? TraceIdGenerator { get; set; }
607
609 {
610 get
611 {
612 if (s_defaultIdFormat == ActivityIdFormat.Unknown)
613 {
614 s_defaultIdFormat = (System.LocalAppContextSwitches.DefaultActivityIdFormatIsHierarchial ? ActivityIdFormat.Hierarchical : ActivityIdFormat.W3C);
615 }
616 return s_defaultIdFormat;
617 }
618 set
619 {
620 if (ActivityIdFormat.Hierarchical > value || value > ActivityIdFormat.W3C)
621 {
623 }
625 }
626 }
627
628 private bool W3CIdFlagsSet => (_w3CIdFlags & 0x80) != 0;
629
630 private bool IsFinished
631 {
632 get
633 {
634 return (_state & State.IsFinished) != 0;
635 }
636 set
637 {
638 if (value)
639 {
640 _state |= State.IsFinished;
641 }
642 else
643 {
644 _state &= ~State.IsFinished;
645 }
646 }
647 }
648
650 {
651 get
652 {
653 return (ActivityIdFormat)(_state & State.FormatFlags);
654 }
655 private set
656 {
657 _state = (_state & ~State.FormatFlags) | (State)((byte)value & 3u);
658 }
659 }
660
661 public static Activity? Current
662 {
663 get
664 {
665 return s_current.Value;
666 }
667 set
668 {
670 {
672 }
673 }
674 }
675
676 public Activity SetStatus(ActivityStatusCode code, string? description = null)
677 {
679 _statusDescription = ((code == ActivityStatusCode.Error) ? description : null);
680 return this;
681 }
682
683 public string? GetBaggageItem(string key)
684 {
686 {
687 if (key == item.Key)
688 {
689 return item.Value;
690 }
691 }
692 return null;
693 }
694
695 public object? GetTagItem(string key)
696 {
697 return _tags?.Get(key) ?? null;
698 }
699
700 public Activity(string operationName)
701 {
703 IsAllDataRequested = true;
704 if (string.IsNullOrEmpty(operationName))
705 {
707 }
709 }
710
711 public Activity AddTag(string key, string? value)
712 {
713 return AddTag(key, (object?)value);
714 }
715
716 public Activity AddTag(string key, object? value)
717 {
719 if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(keyValuePair), null) != null)
720 {
722 }
723 return this;
724 }
725
726 public Activity SetTag(string key, object? value)
727 {
729 if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(keyValuePair, set: true), null) != null)
730 {
732 }
733 return this;
734 }
735
737 {
738 if (_events != null || Interlocked.CompareExchange(ref _events, new DiagLinkedList<ActivityEvent>(e), null) != null)
739 {
740 _events.Add(e);
741 }
742 return this;
743 }
744
745 public Activity AddBaggage(string key, string? value)
746 {
749 {
751 }
752 return this;
753 }
754
755 public Activity SetBaggage(string key, string? value)
756 {
758 if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(keyValuePair, set: true), null) != null)
759 {
761 }
762 return this;
763 }
764
766 {
767 if (Parent != null)
768 {
770 }
771 else if (ParentId != null || _parentSpanId != null)
772 {
774 }
775 else if (string.IsNullOrEmpty(parentId))
776 {
778 }
779 else
780 {
782 }
783 return this;
784 }
785
805
807 {
808 if (startTimeUtc.Kind != DateTimeKind.Utc)
809 {
811 }
812 else
813 {
815 }
816 return this;
817 }
818
820 {
821 if (endTimeUtc.Kind != DateTimeKind.Utc)
822 {
824 }
825 else
826 {
828 if (Duration.Ticks <= 0)
829 {
830 Duration = new TimeSpan(1L);
831 }
832 }
833 return this;
834 }
835
837 {
838 if (_id != null || _spanId != null)
839 {
841 }
842 else
843 {
845 if (_parentId == null && _parentSpanId == null && _previousActiveActivity != null)
846 {
848 }
849 if (StartTimeUtc == default(DateTime))
850 {
852 }
853 if (IdFormat == ActivityIdFormat.Unknown)
854 {
856 }
857 if (IdFormat == ActivityIdFormat.W3C)
858 {
860 }
861 else
862 {
864 }
865 SetCurrent(this);
867 }
868 return this;
869 }
870
871 public void Stop()
872 {
873 if (_id == null && _spanId == null)
874 {
876 }
877 else if (!IsFinished)
878 {
879 IsFinished = true;
880 if (Duration == TimeSpan.Zero)
881 {
883 }
886 }
887 }
888
890 {
891 if (_id != null || _spanId != null)
892 {
894 }
895 else
896 {
898 }
899 return this;
900 }
901
902 private static bool IsW3CId(string id)
903 {
904 if (id.Length == 55 && (('0' <= id[0] && id[0] <= '9') || ('a' <= id[0] && id[0] <= 'f')) && (('0' <= id[1] && id[1] <= '9') || ('a' <= id[1] && id[1] <= 'f')))
905 {
906 if (id[0] == 'f')
907 {
908 return id[1] != 'f';
909 }
910 return true;
911 }
912 return false;
913 }
914
915 internal static bool TryConvertIdToContext(string traceParent, string traceState, out ActivityContext context)
916 {
917 context = default(ActivityContext);
918 if (!IsW3CId(traceParent))
919 {
920 return false;
921 }
922 ReadOnlySpan<char> idData = traceParent.AsSpan(3, 32);
923 ReadOnlySpan<char> idData2 = traceParent.AsSpan(36, 16);
925 {
926 return false;
927 }
929 return true;
930 }
931
932 public void Dispose()
933 {
934 if (!IsFinished)
935 {
936 Stop();
937 }
938 Dispose(disposing: true);
939 GC.SuppressFinalize(this);
940 }
941
942 protected virtual void Dispose(bool disposing)
943 {
944 }
945
946 public void SetCustomProperty(string propertyName, object? propertyValue)
947 {
948 if (_customProperties == null)
949 {
951 }
953 {
954 if (propertyValue == null)
955 {
957 }
958 else
959 {
961 }
962 }
963 }
964
965 public object? GetCustomProperty(string propertyName)
966 {
967 if (_customProperties == null)
968 {
969 return null;
970 }
972 {
973 object value;
975 }
976 }
977
979 {
980 Activity activity = new Activity(name);
981 activity.Source = source;
982 activity.Kind = kind;
983 activity.IdFormat = idFormat;
984 if (links != null)
985 {
987 if (enumerator.MoveNext())
988 {
989 activity._links = new DiagLinkedList<ActivityLink>(enumerator);
990 }
991 }
992 if (tags != null)
993 {
995 if (enumerator2.MoveNext())
996 {
997 activity._tags = new TagsLinkedList(enumerator2);
998 }
999 }
1000 if (samplerTags != null)
1001 {
1002 if (activity._tags == null)
1003 {
1004 activity._tags = new TagsLinkedList(samplerTags);
1005 }
1006 else
1007 {
1008 activity._tags.Add(samplerTags);
1009 }
1010 }
1011 if (parentId != null)
1012 {
1013 activity._parentId = parentId;
1014 }
1015 else if (parentContext != default(ActivityContext))
1016 {
1017 activity._traceId = parentContext.TraceId.ToString();
1018 if (parentContext.SpanId != default(ActivitySpanId))
1019 {
1020 activity._parentSpanId = parentContext.SpanId.ToString();
1021 }
1022 activity.ActivityTraceFlags = parentContext.TraceFlags;
1023 activity._parentTraceFlags = (byte)parentContext.TraceFlags;
1024 activity._traceState = parentContext.TraceState;
1025 }
1026 activity.IsAllDataRequested = request == ActivitySamplingResult.AllData || request == ActivitySamplingResult.AllDataAndRecorded;
1027 if (request == ActivitySamplingResult.AllDataAndRecorded)
1028 {
1029 activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded;
1030 }
1031 if (startTime != default(DateTimeOffset))
1032 {
1033 activity.StartTimeUtc = startTime.UtcDateTime;
1034 }
1035 if (startIt)
1036 {
1037 activity.Start();
1038 }
1039 return activity;
1040 }
1041
1042 private void GenerateW3CId()
1043 {
1044 if (_traceId == null && !TrySetTraceIdFromParent())
1045 {
1046 _traceId = (TraceIdGenerator?.Invoke() ?? ActivityTraceId.CreateRandom()).ToHexString();
1047 }
1048 if (!W3CIdFlagsSet)
1049 {
1051 }
1052 _spanId = ActivitySpanId.CreateRandom().ToHexString();
1053 }
1054
1055 private static void NotifyError(Exception exception)
1056 {
1057 try
1058 {
1059 throw exception;
1060 }
1061 catch
1062 {
1063 }
1064 }
1065
1066 private string GenerateHierarchicalId()
1067 {
1068 if (Parent != null)
1069 {
1071 }
1072 if (ParentId != null)
1073 {
1074 string text = ((ParentId[0] == '|') ? ParentId : ("|" + ParentId));
1075 char c = text[text.Length - 1];
1076 if (c != '.' && c != '_')
1077 {
1078 text += ".";
1079 }
1080 return AppendSuffix(text, Interlocked.Increment(ref s_currentRootId).ToString("x"), '_');
1081 }
1082 return GenerateRootId();
1083 }
1084
1085 private string GetRootId(string id)
1086 {
1087 if (IdFormat == ActivityIdFormat.W3C)
1088 {
1089 return id.Substring(3, 32);
1090 }
1091 int num = id.IndexOf('.');
1092 if (num < 0)
1093 {
1094 num = id.Length;
1095 }
1096 int num2 = ((id[0] == '|') ? 1 : 0);
1097 return id.Substring(num2, num - num2);
1098 }
1099
1100 private string AppendSuffix(string parentId, string suffix, char delimiter)
1101 {
1102 if (parentId.Length + suffix.Length < 1024)
1103 {
1104 return parentId + suffix + delimiter;
1105 }
1106 int num = 1015;
1107 while (num > 1 && parentId[num - 1] != '.' && parentId[num - 1] != '_')
1108 {
1109 num--;
1110 }
1111 if (num == 1)
1112 {
1113 return GenerateRootId();
1114 }
1115 string text = ((int)GetRandomNumber()).ToString("x8");
1116 return parentId.Substring(0, num) + text + "#";
1117 }
1118
1119 private unsafe static long GetRandomNumber()
1120 {
1121 Guid guid = Guid.NewGuid();
1122 return *(long*)(&guid);
1123 }
1124
1126 {
1127 bool flag = activity == null || (activity.Id != null && !activity.IsFinished);
1128 if (!flag)
1129 {
1131 }
1132 return flag;
1133 }
1134
1136 {
1137 if (Parent != null && Parent.IdFormat == ActivityIdFormat.W3C)
1138 {
1140 }
1141 else if (_parentId != null && IsW3CId(_parentId))
1142 {
1143 try
1144 {
1145 _traceId = ActivityTraceId.CreateFromString(_parentId.AsSpan(3, 32)).ToHexString();
1146 }
1147 catch
1148 {
1149 }
1150 }
1151 return _traceId != null;
1152 }
1153
1155 {
1156 if (W3CIdFlagsSet)
1157 {
1158 return;
1159 }
1160 if (Parent != null)
1161 {
1163 }
1164 else if (_parentId != null && IsW3CId(_parentId))
1165 {
1167 {
1169 }
1170 else
1171 {
1172 _w3CIdFlags = 128;
1173 }
1174 }
1175 }
1176
1177 private static void SetCurrent(Activity activity)
1178 {
1179 s_current.Value = activity;
1180 }
1181
1182 internal static DateTime GetUtcNow()
1183 {
1184 return DateTime.UtcNow;
1185 }
1186
1187 private static string GenerateRootId()
1188 {
1189 Span<char> span = stackalloc char[17 + s_uniqSuffix.Length];
1190 span[0] = '|';
1191 int charsWritten;
1192 bool flag = Interlocked.Increment(ref s_currentRootId).TryFormat(span.Slice(1), out charsWritten, "x");
1193 s_uniqSuffix.AsSpan().CopyTo(span.Slice(1 + charsWritten));
1194 return new string(span.Slice(0, 1 + charsWritten + s_uniqSuffix.Length));
1195 }
1196}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
void NotifyActivityStart(Activity activity)
void NotifyActivityStop(Activity activity)
BaggageLinkedList(KeyValuePair< string, string > firstValue, bool set=false)
Definition Activity.cs:16
DiagNode< KeyValuePair< string, string > > First
Definition Activity.cs:14
Enumerator< KeyValuePair< string, string > > GetEnumerator()
Definition Activity.cs:80
DiagNode< KeyValuePair< string, string > > _first
Definition Activity.cs:12
void Set(KeyValuePair< string, string > value)
Definition Activity.cs:31
void Add(KeyValuePair< string, string > value)
Definition Activity.cs:21
void Set(KeyValuePair< string, object > value)
Definition Activity.cs:207
TagsLinkedList(IEnumerable< KeyValuePair< string, object > > list)
Definition Activity.cs:119
void Add(IEnumerable< KeyValuePair< string, object > > list)
Definition Activity.cs:124
DiagNode< KeyValuePair< string, object > > _last
Definition Activity.cs:100
IEnumerable< KeyValuePair< string, string > > EnumerateStringValues()
Definition Activity.cs:250
TagsLinkedList(KeyValuePair< string, object > firstValue, bool set=false)
Definition Activity.cs:104
void Add(KeyValuePair< string, object > value)
Definition Activity.cs:146
Enumerator< KeyValuePair< string, object > > GetEnumerator()
Definition Activity.cs:235
DiagNode< KeyValuePair< string, object > > _first
Definition Activity.cs:98
TagsLinkedList(IEnumerator< KeyValuePair< string, object > > e)
Definition Activity.cs:109
IEnumerable< KeyValuePair< string, string?> > Baggage
Definition Activity.cs:480
Activity AddTag(string key, string? value)
Definition Activity.cs:711
Activity AddTag(string key, object? value)
Definition Activity.cs:716
static bool TryConvertIdToContext(string traceParent, string traceState, out ActivityContext context)
Definition Activity.cs:915
IEnumerable< ActivityLink > Links
Definition Activity.cs:471
static readonly AsyncLocal< Activity > s_current
Definition Activity.cs:357
Activity(string operationName)
Definition Activity.cs:700
Activity SetStartTime(DateTime startTimeUtc)
Definition Activity.cs:806
Activity SetParentId(string parentId)
Definition Activity.cs:765
IEnumerable< KeyValuePair< string, object?> > TagObjects
Definition Activity.cs:453
string GetRootId(string id)
Definition Activity.cs:1085
static readonly ActivitySource s_defaultSource
Definition Activity.cs:309
ActivityStatusCode _statusCode
Definition Activity.cs:351
DiagLinkedList< ActivityLink > _links
Definition Activity.cs:343
static readonly IEnumerable< KeyValuePair< string, object > > s_emptyTagObjects
Definition Activity.cs:303
Activity AddBaggage(string key, string? value)
Definition Activity.cs:745
ActivityIdFormat IdFormat
Definition Activity.cs:650
static void SetCurrent(Activity activity)
Definition Activity.cs:1177
ActivityContext Context
Definition Activity.cs:509
Activity SetBaggage(string key, string? value)
Definition Activity.cs:755
static unsafe long GetRandomNumber()
Definition Activity.cs:1119
virtual void Dispose(bool disposing)
Definition Activity.cs:942
Dictionary< string, object > _customProperties
Definition Activity.cs:347
static readonly IEnumerable< KeyValuePair< string, string > > s_emptyBaggageTags
Definition Activity.cs:301
Activity SetStatus(ActivityStatusCode code, string? description=null)
Definition Activity.cs:676
object? GetCustomProperty(string propertyName)
Definition Activity.cs:965
static string GenerateRootId()
Definition Activity.cs:1187
ActivityTraceId TraceId
Definition Activity.cs:545
Activity SetEndTime(DateTime endTimeUtc)
Definition Activity.cs:819
Activity SetIdFormat(ActivityIdFormat format)
Definition Activity.cs:889
static bool ForceDefaultIdFormat
Definition Activity.cs:359
static readonly IEnumerable< ActivityLink > s_emptyLinks
Definition Activity.cs:305
void SetCustomProperty(string propertyName, object? propertyValue)
Definition Activity.cs:946
static Activity Create(ActivitySource source, string name, ActivityKind kind, string parentId, ActivityContext parentContext, IEnumerable< KeyValuePair< string, object > > tags, IEnumerable< ActivityLink > links, DateTimeOffset startTime, ActivityTagsCollection samplerTags, ActivitySamplingResult request, bool startIt, ActivityIdFormat idFormat)
Definition Activity.cs:978
ActivityStatusCode Status
Definition Activity.cs:361
static void NotifyError(Exception exception)
Definition Activity.cs:1055
Activity SetTag(string key, object? value)
Definition Activity.cs:726
static bool ValidateSetCurrent(Activity activity)
Definition Activity.cs:1125
string AppendSuffix(string parentId, string suffix, char delimiter)
Definition Activity.cs:1100
static bool IsW3CId(string id)
Definition Activity.cs:902
static readonly string s_uniqSuffix
Definition Activity.cs:311
object? GetTagItem(string key)
Definition Activity.cs:695
DiagLinkedList< ActivityEvent > _events
Definition Activity.cs:345
static readonly IEnumerable< ActivityEvent > s_emptyEvents
Definition Activity.cs:307
Activity SetParentId(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags=ActivityTraceFlags.None)
Definition Activity.cs:786
static ActivityIdFormat s_defaultIdFormat
Definition Activity.cs:315
string? GetBaggageItem(string key)
Definition Activity.cs:683
static ? Activity Current
Definition Activity.cs:662
IEnumerable< KeyValuePair< string, string?> > Tags
Definition Activity.cs:450
Activity AddEvent(ActivityEvent e)
Definition Activity.cs:736
ActivitySpanId ParentSpanId
Definition Activity.cs:577
ActivityTraceFlags ActivityTraceFlags
Definition Activity.cs:561
static DateTime GetUtcNow()
Definition Activity.cs:1182
static ActivityIdFormat DefaultIdFormat
Definition Activity.cs:609
static ? Func< ActivityTraceId > TraceIdGenerator
Definition Activity.cs:606
BaggageLinkedList _baggage
Definition Activity.cs:341
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
static bool IsHexLowerChar(int c)
static void ToCharsBuffer(byte value, Span< char > buffer, int startingIndex=0, Casing casing=Casing.Upper)
static string ActivityNotStarted
Definition SR.cs:18
static string SetFormatOnStartedActivity
Definition SR.cs:30
static string ActivityStartAlreadyStarted
Definition SR.cs:20
static string ActivityIdFormatInvalid
Definition SR.cs:14
static string ParentIdInvalid
Definition SR.cs:28
static string EndTimeNotUtc
Definition SR.cs:22
static string ActivityNotRunning
Definition SR.cs:16
static string SetParentIdOnActivityWithParent
Definition SR.cs:32
static string ParentIdAlreadySet
Definition SR.cs:26
static string StartTimeNotUtc
Definition SR.cs:34
static string OperationNameInvalid
Definition SR.cs:24
Definition SR.cs:7
override string ToString()
StringBuilder Append(char value, int repeatCount)
static int CompareExchange(ref int location1, int value, int comparand)
static int Increment(ref int location)
new IEnumerator< T > GetEnumerator()
static unsafe DateTime UtcNow
Definition DateTime.cs:142
static unsafe ActivitySpanId CreateRandom()
static ActivitySpanId CreateFromString(ReadOnlySpan< char > idData)
static ActivityTraceId CreateFromString(ReadOnlySpan< char > idData)
static ActivityTraceId CreateRandom()
static bool IsLowerCaseHexAndNotAllZeros(ReadOnlySpan< char > idData)
static byte HexByteFromChars(char char1, char char2)
static Guid NewGuid()
Definition Guid.cs:1283
static readonly TimeSpan Zero
Definition TimeSpan.cs:21