コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OtlpTraceExporter"/> class.
        /// </summary>
        /// <param name="options">Configuration options for the exporter.</param>
        /// <param name="traceServiceClient"><see cref="OtlpCollector.TraceService.TraceServiceClient"/>.</param>
        internal OtlpTraceExporter(OtlpExporterOptions options, OtlpCollector.TraceService.ITraceServiceClient traceServiceClient = null)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            this.headers = options.Headers ?? throw new ArgumentException("Headers were not provided on options.", nameof(options));
            if (traceServiceClient != null)
            {
                this.traceClient = traceServiceClient;
            }
            else
            {
#if NETSTANDARD2_1
                this.channel = options.GrpcChannelOptions == default
                    ? GrpcChannel.ForAddress(options.Endpoint)
                    : GrpcChannel.ForAddress(options.Endpoint, options.GrpcChannelOptions);
#else
                this.channel = new Channel(options.Endpoint, options.Credentials, options.ChannelOptions);
#endif
                this.traceClient = new OtlpCollector.TraceService.TraceServiceClient(this.channel);
            }
        }
        public static Channel CreateChannel(this OtlpExporterOptions options)
#endif
        {
            if (options.Endpoint.Scheme != Uri.UriSchemeHttp && options.Endpoint.Scheme != Uri.UriSchemeHttps)
            {
                throw new NotSupportedException($"Endpoint URI scheme ({options.Endpoint.Scheme}) is not supported. Currently only \"http\" and \"https\" are supported.");
            }

#if NETSTANDARD2_1
            return(GrpcChannel.ForAddress(options.Endpoint));
#else
            ChannelCredentials channelCredentials;
            if (options.Endpoint.Scheme == Uri.UriSchemeHttps)
            {
                channelCredentials = new SslCredentials();
            }
            else
            {
                channelCredentials = ChannelCredentials.Insecure;
            }

            return(new Channel(options.Endpoint.Authority, channelCredentials));
#endif
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OtlpExporter"/> class.
 /// </summary>
 /// <param name="options">Configuration options for the exporter.</param>
 public OtlpExporter(OtlpExporterOptions options)
 {
     this.headers     = options?.Headers ?? throw new ArgumentNullException(nameof(options));
     this.channel     = new Channel(options.Endpoint, options.Credentials, options.ChannelOptions);
     this.traceClient = new OtlpCollector.TraceService.TraceServiceClient(this.channel);
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OtlpExporter"/> class.
 /// </summary>
 /// <param name="options">Configuration options for the exporter.</param>
 public OtlpExporter(OtlpExporterOptions options)
 {
     this.headers     = options.Headers;
     this.channel     = new Channel(options.Endpoint, options.Credentials);
     this.traceClient = new OtlpCollector.TraceService.TraceServiceClient(this.channel);
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OtlpExporter"/> class.
 /// </summary>
 /// <param name="options">Configuration options for the exporter.</param>
 public OtlpExporter(OtlpExporterOptions options)
     : this(options, null)
 {
 }
 public static GrpcChannel CreateChannel(this OtlpExporterOptions options)