コード例 #1
0
        /// <summary>
        /// Initialize tracing for this application.
        /// </summary>
        /// <param name="projectId">The Google Cloud Platform project ID.</param>
        /// <param name="application">The Http application.</param>
        /// <param name="config">Optional trace configuration, if unset the default will be used.</param>
        /// <param name="client">Optional trace client, if unset the default will be used.</param>
        public static void Initialize(string projectId, HttpApplication application, TraceConfiguration config = null, Task <TraceServiceClient> client = null)
        {
            GaxPreconditions.CheckNotNull(application, nameof(application));
            CloudTrace trace = new CloudTrace(projectId, config, client);

            // Add event handlers to the application.
            application.BeginRequest += trace.BeginRequest;
            application.EndRequest   += trace.EndRequest;
        }
コード例 #2
0
        /// <summary>
        /// Initialize tracing for this application.
        /// </summary>
        /// <param name="projectId">The Google Cloud Platform project ID.</param>
        /// <param name="application">The Http application.</param>
        /// <param name="config">Optional trace configuration, if unset the default will be used.</param>
        /// <param name="client">Optional trace client, if unset the default will be used.</param>
        public static void Initialize(string projectId, HttpApplication application, TraceConfiguration config = null, TraceServiceClient client = null)
        {
            GaxPreconditions.CheckNotNull(application, nameof(application));
            CloudTrace trace = new CloudTrace(projectId, config, client);

            // Add event handlers to the application.
            application.BeginRequest += trace.BeginRequest;
            application.EndRequest   += trace.EndRequest;
            application.Disposed     += (object sender, EventArgs e) => { trace.Dispose(); };
        }
コード例 #3
0
        /// <summary>
        /// Initialize tracing for this application.
        /// </summary>
        /// <param name="application">The Http application.</param>
        /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine.
        ///     The Google Cloud Platform project ID. If unspecified and running on GAE or GCE the project ID will be
        ///     detected from the platform.</param>
        /// <param name="config">Optional trace configuration, if unset the default will be used.</param>
        /// <param name="client">Optional trace client, if unset the default will be used.</param>
        /// <param name="traceFallbackPredicate">Optional function to trace requests. If the trace header is not set
        ///     then this function will be called to determine if a given request should be traced.  This will
        ///     not override trace headers.</param>
        public static void Initialize(HttpApplication application, string projectId = null,
                                      TraceConfiguration config = null, TraceServiceClient client = null,
                                      TraceDecisionPredicate traceFallbackPredicate = null)
        {
            GaxPreconditions.CheckNotNull(application, nameof(application));

            projectId = CommonUtils.GetAndCheckProjectId(projectId);
            CloudTrace trace = new CloudTrace(projectId, config, client, traceFallbackPredicate);

            // Add event handlers to the application.
            application.BeginRequest += trace.BeginRequest;
            application.EndRequest   += trace.EndRequest;
            application.Disposed     += (object sender, EventArgs e) => { trace.Dispose(); };
        }
コード例 #4
0
        private CloudTrace(string projectId, TraceConfiguration config = null, Task <TraceServiceClient> client = null)
        {
            GaxPreconditions.CheckNotNull(projectId, nameof(projectId));

            // Create the default values if not set.
            client = client ?? TraceServiceClient.CreateAsync();
            config = config ?? TraceConfiguration.Create();

            var consumer = ConsumerFactory <TraceProto> .GetConsumer(
                new GrpcTraceConsumer(client), MessageSizer <TraceProto> .GetSize, config.BufferOptions);

            _tracerFactory = new ManagedTracerFactory(projectId, consumer,
                                                      RateLimitingTraceOptionsFactory.Create(config), TraceIdFactory.Create());
        }
コード例 #5
0
        private CloudTrace(string projectId, TraceConfiguration config = null, Task <TraceServiceClient> client = null)
        {
            _projectId = GaxPreconditions.CheckNotNull(projectId, nameof(projectId));

            // Create the default values if not set.
            client = client ?? TraceServiceClient.CreateAsync();
            config = config ?? TraceConfiguration.Create();

            _traceIdfactory = TraceIdFactory.Create();
            _consumer       = ConsumerFactory <TraceProto> .GetConsumer(
                new GrpcTraceConsumer(client), TraceSizer.Instance, config.BufferOptions);

            _rateFactory   = RateLimitingTraceOptionsFactory.Create(config);
            _headerFactory = TraceHeaderTraceOptionsFactory.Create();
        }
コード例 #6
0
        private CloudTrace(string projectId, TraceConfiguration config      = null, TraceServiceClient client = null,
                           Func <HttpRequest, bool?> traceFallbackPredicate = null)
        {
            GaxPreconditions.CheckNotNull(projectId, nameof(projectId));

            // Create the default values if not set.
            client = client ?? TraceServiceClient.Create();
            config = config ?? TraceConfiguration.Create();

            _traceFallbackPredicate = traceFallbackPredicate;

            _consumer = ConsumerFactory <TraceProto> .GetConsumer(
                new GrpcTraceConsumer(client), MessageSizer <TraceProto> .GetSize, config.BufferOptions);

            _tracerFactory = new ManagedTracerFactory(projectId, _consumer,
                                                      RateLimitingTraceOptionsFactory.Create(config), TraceIdFactory.Create());
        }
コード例 #7
0
 /// <summary>
 /// Create a new <see cref="RateLimitingTraceOptionsFactory"/>.
 /// </summary>
 /// <param name="config">Optional trace configuration, if unset the default will be used.</param>
 public static RateLimitingTraceOptionsFactory Create(TraceConfiguration config = null)
 {
     return(new RateLimitingTraceOptionsFactory(config ?? TraceConfiguration.Create()));
 }
コード例 #8
0
 private RateLimitingTraceOptionsFactory(TraceConfiguration config)
 {
     GaxPreconditions.CheckNotNull(config, nameof(config));
     _rateLimiter = RateLimiter.GetInstance(config.QpsSampleRate);
 }