Example #1
0
            static Inner()
            {
                PassThroughOperationKind = CreateOperationKind("[Pass-Through]", false);

                var prefix = "PipExecutorCounter.";

                foreach (var counter in EnumTraits <PipExecutorCounter> .EnumerateValues())
                {
                    int trackedCacheCounterId = IsTrackedCacheCounter(counter) ? s_trackedCacheCounterKinds.Count : -1;

                    if (!CounterCollection <PipExecutorCounter> .IsStopwatch(counter))
                    {
                        s_pipExecutorCounterKinds.Add(Invalid);
                        continue;
                    }

                    var counterName = counter.ToString();
                    if (counterName.EndsWith(DurationSuffix, StringComparison.OrdinalIgnoreCase))
                    {
                        counterName = counterName.Substring(0, counterName.Length - DurationSuffix.Length);
                    }

                    counterName = prefix + counterName;

                    var operationKind = CreateOperationKind(counterName, /* hasPipTypeSpecialization */ IsPipTypeSpecificCounter(counter), trackedCacheCounterId: trackedCacheCounterId);
                    s_pipExecutorCounterKinds.Add(operationKind);

                    if (trackedCacheCounterId != -1)
                    {
                        s_trackedCacheCounterKinds.Add(operationKind);
                    }
                }

                prefix = "PipExecutionStep.";
                foreach (var counter in EnumTraits <PipExecutionStep> .EnumerateValues())
                {
                    var counterName = counter.ToString();
                    counterName = prefix + counterName;
                    var operationKind = CreateOperationKind(counterName, /* hasPipTypeSpecialization */ true);
                    s_pipExecutionStepKinds.Add(operationKind);
                }

                prefix = "Operation.";
                foreach (var counter in EnumTraits <OperationCounter> .EnumerateValues())
                {
                    var counterName = counter.ToString();
                    counterName = prefix + counterName;
                    var operationKind = CreateOperationKind(counterName, /* hasPipTypeSpecialization */ false);
                    s_operationCounterKinds.Add(operationKind);
                }
            }
Example #2
0
            /// <summary>
            /// Creates a new operation kind
            /// </summary>
            /// <param name="name">the name</param>
            /// <param name="hasPipTypeSpecialization">if the operation is different for distinct pip type kinds</param>
            /// <param name="trackedCacheCounterId">if the given operation is one of the tracked cache lookup counter</param>
            /// <returns>the created operation kind</returns>
            public static OperationKind CreateOperationKind(string name, bool hasPipTypeSpecialization, int trackedCacheCounterId = -1)
            {
                lock (s_addOperationLock)
                {
                    int   index = s_allOperations.Count;
                    short?pipTypeCounterStartIndex = hasPipTypeSpecialization ?
                                                     (short?)s_pipTypeSpecificOperations.Count : null;
                    var operation = new OperationKind((ushort)index, pipTypeCounterStartIndex, (short)trackedCacheCounterId);
                    s_allOperations.Add(operation);
                    s_names.Add(name);

                    if (hasPipTypeSpecialization)
                    {
                        foreach (var pipTypeSuffix in s_pipTypeSuffixes)
                        {
                            s_pipTypeSpecificOperations.Add(CreateOperationKind(name + pipTypeSuffix, /* hasPipTypeSpecialization */ false, trackedCacheCounterId));
                        }
                    }

                    return(operation);
                }
            }
Example #3
0
 /// <inheritdoc />
 public OperationContext StartOperation(OperationKind kind, LoggingContext loggingContext)
 {
     return(new OperationContext(loggingContext, operation: null));
 }