Example #1
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();
        }
        private CloudTrace(string projectId, TraceConfiguration config   = null, TraceServiceClient client = null,
                           TraceDecisionPredicate traceFallbackPredicate = null)
        {
            GaxPreconditions.CheckNotNull(projectId, nameof(projectId));

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

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

            _tracerFactory = new ManagedTracerFactory(projectId, _consumer,
                                                      RateLimitingTraceOptionsFactory.Create(config), TraceIdFactory.Create());
        }