/// <summary> /// Create a new instance of <see cref="CloudTraceMiddleware"/>. /// </summary> /// <param name="next">The next request delegate. Cannot be null.</param> /// <param name="tracerFactory">A factory to create <see cref="IManagedTracer"/>s. Cannot be null.</param> /// <param name="accessor">Access to <see cref="HttpContext"/>. Cannot be null.</param> public CloudTraceMiddleware( RequestDelegate next, IManagedTracerFactory tracerFactory, IHttpContextAccessor accessor) { _next = GaxPreconditions.CheckNotNull(next, nameof(next)); _tracerFactory = GaxPreconditions.CheckNotNull(tracerFactory, nameof(tracerFactory)); _accessor = GaxPreconditions.CheckNotNull(accessor, nameof(accessor)); }
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()); }
private CloudTrace(string projectId, TraceOptions options = null, TraceServiceClient client = null, TraceDecisionPredicate traceFallbackPredicate = null) { GaxPreconditions.CheckNotNull(projectId, nameof(projectId)); // Create the default values if not set. client = client ?? TraceServiceClient.Create(); options = options ?? TraceOptions.Create(); _traceFallbackPredicate = traceFallbackPredicate ?? TraceDecisionPredicate.Default; _consumer = ConsumerFactory <TraceProto> .GetConsumer( new GrpcTraceConsumer(client), MessageSizer <TraceProto> .GetSize, options.BufferOptions); _tracerFactory = new ManagedTracerFactory(projectId, _consumer, RateLimitingTraceOptionsFactory.Create(options), TraceIdFactory.Create()); }
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()); }