コード例 #1
0
 /// <summary>
 /// Creates an instance of <see cref="HttpPipeline"/> populated with default policies, customer provided policies from <paramref name="options"/> and client provided per call policies.
 /// </summary>
 /// <param name="options">The customer provided client options object.</param>
 /// <param name="perRetryPolicies">Client provided per-call policies.</param>
 /// <returns>A new instance of <see cref="HttpPipeline"/></returns>
 public static HttpPipeline Build(ClientOptions options, params HttpPipelinePolicy[] perRetryPolicies)
 {
     return(Build(options, Array.Empty <HttpPipelinePolicy>(), perRetryPolicies, new ResponseClassifier()));
 }
コード例 #2
0
 public ClientDiagnostics(ClientOptions options) : base(
         options.GetType().Namespace !,
コード例 #3
0
 public ClientDiagnostics(ClientOptions options) : this(options.GetType().Namespace, options.Diagnostics.IsDistributedTracingEnabled)
 {
 }
コード例 #4
0
        /// <summary>
        /// Creates an instance of <see cref="HttpPipeline"/> populated with default policies, customer provided policies from <paramref name="options"/> and client provided per call policies.
        /// </summary>
        /// <param name="options">The customer provided client options object.</param>
        /// <param name="perCallPolicies">Client provided per-call policies.</param>
        /// <param name="perRetryPolicies">Client provided per-retry policies.</param>
        /// <param name="responseClassifier">The client provided response classifier.</param>
        /// <returns>A new instance of <see cref="HttpPipeline"/></returns>
        public static HttpPipeline Build(ClientOptions options, HttpPipelinePolicy[] perCallPolicies, HttpPipelinePolicy[] perRetryPolicies, ResponseClassifier responseClassifier)
        {
            if (perCallPolicies == null)
            {
                throw new ArgumentNullException(nameof(perCallPolicies));
            }

            if (perRetryPolicies == null)
            {
                throw new ArgumentNullException(nameof(perRetryPolicies));
            }

            var policies = new List <HttpPipelinePolicy>(8 +
                                                         (options.Policies?.Count ?? 0) +
                                                         perCallPolicies.Length +
                                                         perRetryPolicies.Length);

            void AddCustomerPolicies(HttpPipelinePosition position)
            {
                if (options.Policies != null)
                {
                    foreach (var policy in options.Policies)
                    {
                        if (policy.Position == position)
                        {
                            policies.Add(policy.Policy);
                        }
                    }
                }
            }

            DiagnosticsOptions diagnostics = options.Diagnostics;

            var sanitizer = new HttpMessageSanitizer(diagnostics.LoggedHeaderNames.ToArray(), diagnostics.LoggedQueryParameters.ToArray());

            bool isDistributedTracingEnabled = options.Diagnostics.IsDistributedTracingEnabled;

            policies.Add(ReadClientRequestIdPolicy.Shared);

            policies.AddRange(perCallPolicies);

            AddCustomerPolicies(HttpPipelinePosition.PerCall);

            policies.Add(ClientRequestIdPolicy.Shared);

            if (diagnostics.IsTelemetryEnabled)
            {
                policies.Add(CreateTelemetryPolicy(options));
            }

            RetryOptions retryOptions = options.Retry;

            policies.Add(new RetryPolicy(retryOptions.Mode, retryOptions.Delay, retryOptions.MaxDelay, retryOptions.MaxRetries));

            policies.Add(RedirectPolicy.Shared);

            policies.AddRange(perRetryPolicies);

            AddCustomerPolicies(HttpPipelinePosition.PerRetry);

            if (diagnostics.IsLoggingEnabled)
            {
                string assemblyName = options.GetType().Assembly !.GetName().Name !;

                policies.Add(new LoggingPolicy(diagnostics.IsLoggingContentEnabled, diagnostics.LoggedContentSizeLimit, sanitizer, assemblyName));
            }

            policies.Add(new ResponseBodyPolicy(options.Retry.NetworkTimeout));

            policies.Add(new RequestActivityPolicy(isDistributedTracingEnabled, ClientDiagnostics.GetResourceProviderNamespace(options.GetType().Assembly), sanitizer));

            AddCustomerPolicies(HttpPipelinePosition.BeforeTransport);

            policies.RemoveAll(static policy => policy == null);
コード例 #5
0
 public ClientDiagnostics(ClientOptions options, bool?suppressNestedClientActivities = null)
     : this(options.GetType().Namespace !,
コード例 #6
0
 public ClientDiagnostics(ClientOptions options) : this(
         options.GetType().Namespace,
         GetResourceProviderNamespace(options.GetType().Assembly),
         options.Diagnostics.IsDistributedTracingEnabled)
 {
 }
コード例 #7
0
 public CommunicationClientDiagnostics(ClientOptions options) : base(options)
 {
 }