Beispiel #1
0
 /// <summary>
 /// Creates a new <see cref="ManagedTracerFactory"/>.
 /// </summary>
 /// <param name="projectId">The Google Cloud Platform project ID. Cannot be null.</param>
 /// <param name="consumer">A trace consumer for the tracer. Cannot be null.</param>
 /// <param name="optionsFactory">An options factory to fall back to if the
 ///     <see cref="TraceHeaderContext"/> does not provide enough context. Cannot be null.</param>
 /// <param name="traceIdFactory">A trace Id factory. Cannot be null.</param>
 internal ManagedTracerFactory(
     string projectId,
     IConsumer <TraceProto> consumer,
     ITraceOptionsFactory optionsFactory,
     TraceIdFactory traceIdFactory
     )
 {
     _projectId      = GaxPreconditions.CheckNotNull(projectId, nameof(projectId));
     _consumer       = GaxPreconditions.CheckNotNull(consumer, nameof(consumer));
     _optionsFactory = GaxPreconditions.CheckNotNull(optionsFactory, nameof(optionsFactory));
     _traceIdFactory = GaxPreconditions.CheckNotNull(traceIdFactory, nameof(traceIdFactory));
 }
        /// <summary>
        /// Create a factory to generate an <see cref="IManagedTracer"/> from an <see cref="ITraceContext"/>.
        /// </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 <ITraceContext, IManagedTracer> CreateFactory(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);
        }