Closed guochen2 closed 2 years ago
TracingMongoClient在多次使用的情况下 (对TracingMongoClient进行Scope注入) 会有多次订阅mongodb事件的问题,建议对MongoClientSettings做单例处理,或者从外部传入一个MongoClientSettings,由外部调用方控制
扩展示例
public static class ClusterBuilderExt { public static ClusterBuilder AddOpenTracing(this ClusterBuilder builder, ITracer tracer, TracingOptions tracingOptions = null) { if (tracingOptions == null) { tracingOptions = new TracingOptions(); } var mongoEventListener = new MongoEventListener(tracer, tracingOptions); builder .Subscribe<CommandStartedEvent>(mongoEventListener.StartEventHandler) .Subscribe<CommandSucceededEvent>(mongoEventListener.SuccessEventHandler) .Subscribe<CommandFailedEvent>(mongoEventListener.ErrorEventHandler); return builder; } }
使用方式
clientSettings.ClusterConfigurator = cb => cb.AddOpenTracing(OpenTracing.Util.GlobalTracer.Instance);
Closing because of OpenTracing deprecation
TracingMongoClient在多次使用的情况下 (对TracingMongoClient进行Scope注入) 会有多次订阅mongodb事件的问题,建议对MongoClientSettings做单例处理,或者从外部传入一个MongoClientSettings,由外部调用方控制
扩展示例
使用方式