Esempio n. 1
0
        /// <summary>
        /// Create a factory to generate an <see cref="IManagedTracer"/> from a <see cref="TraceHeaderContext"/>.
        /// </summary>
        /// <param name="projectId">The Google Cloud Platform project ID. Must not be null</param>
        /// <param name="consumer">The trace consumer.  Must not be null.</param>
        /// <param name="options">Trace options. Must not be null.</param>
        public static Func <TraceHeaderContext, IManagedTracer> CreateTracerFactory(string projectId, IConsumer <TraceProto> consumer, TraceOptions options)
        {
            GaxPreconditions.CheckNotNull(projectId, nameof(projectId));
            GaxPreconditions.CheckNotNull(consumer, nameof(consumer));
            GaxPreconditions.CheckNotNull(options, nameof(options));

            var factory = new ManagedTracerFactory(projectId, consumer,
                                                   RateLimitingTraceOptionsFactory.Create(options), TraceIdFactory.Create());

            return(factory.CreateTracer);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a trace consumer for a <see cref="TraceServiceClient"/> and options.
        /// </summary>
        /// <param name="client">The trace client. Must not be null.</param>
        /// <param name="options">Trace options. Must not be null.</param>
        public static IConsumer <TraceProto> CreateConsumer(TraceServiceClient client, TraceOptions options)
        {
            GaxPreconditions.CheckNotNull(client, nameof(client));
            GaxPreconditions.CheckNotNull(options, nameof(options));

            return(ConsumerFactory <TraceProto> .GetConsumer(
                       new GrpcTraceConsumer(client), MessageSizer <TraceProto> .GetSize,
                       options.BufferOptions, options.RetryOptions));
        }
 /// <summary>
 /// Create a new <see cref="RateLimitingTraceOptionsFactory"/>.
 /// </summary>
 /// <param name="options">Optional trace options, if unset the default will be used.</param>
 public static RateLimitingTraceOptionsFactory Create(TraceOptions options = null)
 {
     return(new RateLimitingTraceOptionsFactory(options ?? TraceOptions.Create()));
 }
Esempio n. 4
0
 public static Func <TraceHeaderContext, IManagedTracer> CreateTracerFactory(string projectId, IConsumer <TraceProto> consumer, TraceOptions options) =>
 CreateFactory(projectId, consumer, options);
 private RateLimitingTraceOptionsFactory(TraceOptions options)
 {
     GaxPreconditions.CheckNotNull(options, nameof(options));
     _rateLimiter = RateLimiter.GetInstance(options.QpsSampleRate);
 }