Exemplo n.º 1
0
 public bool CheckFilters(TraceTelemetry document, out CollectionConfigurationError[] errors)
 {
     return(DocumentStream.CheckFilters(this.traceFilterGroups, document, out errors));
 }
        private void CreateDocumentStreams(
            out CollectionConfigurationError[] errors,
            Clock timeProvider,
            IEnumerable <DocumentStream> previousDocumentStreams)
        {
            var errorList         = new List <CollectionConfigurationError>();
            var documentStreamIds = new HashSet <string>();

            // quota might be changing concurrently on the collection thread, but we don't need the exact value at any given time
            // we will try to carry over the last known values to this new configuration
            Dictionary <string, Tuple <float, float, float, float, float> > previousQuotasByStreamId =
                previousDocumentStreams.ToDictionary(
                    documentStream => documentStream.Id,
                    documentStream =>
                    Tuple.Create(
                        documentStream.RequestQuotaTracker.CurrentQuota,
                        documentStream.DependencyQuotaTracker.CurrentQuota,
                        documentStream.ExceptionQuotaTracker.CurrentQuota,
                        documentStream.EventQuotaTracker.CurrentQuota,
                        documentStream.TraceQuotaTracker.CurrentQuota));

            foreach (DocumentStreamInfo documentStreamInfo in this.info.DocumentStreams ?? new DocumentStreamInfo[0])
            {
                if (documentStreamIds.Contains(documentStreamInfo.Id))
                {
                    // there must not be streams with duplicate ids
                    errorList.Add(
                        CollectionConfigurationError.CreateError(
                            CollectionConfigurationErrorType.DocumentStreamDuplicateIds,
                            string.Format(CultureInfo.InvariantCulture, "Document stream with a duplicate id ignored: {0}", documentStreamInfo.Id),
                            null,
                            Tuple.Create("DocumentStreamId", documentStreamInfo.Id)));

                    continue;
                }

                CollectionConfigurationError[] localErrors = null;
                try
                {
                    Tuple <float, float, float, float, float> initialQuotas;
                    previousQuotasByStreamId.TryGetValue(documentStreamInfo.Id, out initialQuotas);

                    var documentStream = new DocumentStream(
                        documentStreamInfo,
                        out localErrors,
                        timeProvider,
                        initialRequestQuota: initialQuotas?.Item1,
                        initialDependencyQuota: initialQuotas?.Item2,
                        initialExceptionQuota: initialQuotas?.Item3,
                        initialEventQuota: initialQuotas?.Item4,
                        initialTraceQuota: initialQuotas?.Item5);

                    documentStreamIds.Add(documentStreamInfo.Id);
                    this.documentStreams.Add(documentStream);
                }
                catch (Exception e)
                {
                    errorList.Add(
                        CollectionConfigurationError.CreateError(
                            CollectionConfigurationErrorType.DocumentStreamFailureToCreate,
                            string.Format(CultureInfo.InvariantCulture, "Failed to create document stream {0}", documentStreamInfo),
                            e,
                            Tuple.Create("DocumentStreamId", documentStreamInfo.Id)));
                }

                if (localErrors != null)
                {
                    foreach (var error in localErrors)
                    {
                        error.Data["DocumentStreamId"] = documentStreamInfo.Id;
                    }

                    errorList.AddRange(localErrors);
                }
            }

            errors = errorList.ToArray();
        }
Exemplo n.º 3
0
 public bool CheckFilters(DependencyTelemetry document, out CollectionConfigurationError[] errors)
 {
     return(DocumentStream.CheckFilters(this.dependencyFilterGroups, document, out errors));
 }