public void Initialize(ITraceProvider traceProvider) { TcpChannel channel = new TcpChannel(_server, _port, _bindIP, traceProvider); channel.Formatter = GetChannelFormatter(); RequestManager requestManager = new RequestManager(channel, _channelDisconnected); channel.Connect(); _requestManager = requestManager; try { initialized = InitializeInternal(); } catch (Exception) { channel.Disconnect(); _requestManager = null; throw; } if (!initialized) { channel.Disconnect(); _requestManager = null; } }
public void Initialize(ITraceProvider traceProvider) { TcpChannel channel = new TcpChannel(_server, _port, _bindIP, traceProvider); channel.Formatter = GetChannelFormatter(); RequestManager requestManager = new RequestManager(channel); channel.Connect(); _requestManager = requestManager; bool initialized = false; try { initialized = InitializeInternal(); } catch (Exception) { channel.Disconnect(); _requestManager = null; throw; } if (!initialized) { channel.Disconnect(); _requestManager = null; } }
private void TestCreateCompletelyNewIndex(ITraceProvider trace) { var parentDocument = ParentDocument(); _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelOne), new ElasticsearchMappingChildDocumentForParent()); _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelTwo), new ElasticsearchMappingChildDocumentForParent()); using ( var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration( _elasticsearchMappingResolver, SaveChildObjectsAsWellAsParent, ProcessChildDocumentsAsSeparateChildIndex))) { context.TraceProvider = trace; context.AddUpdateDocument(parentDocument, parentDocument.Id); // Save to Elasticsearch var ret = context.SaveChangesAndInitMappings(); Assert.AreEqual(ret.Status, HttpStatusCode.OK); context.GetDocument <ParentDocument>(parentDocument.Id); } }
public ZipkinClient(ITraceProvider traceProvider, string requestName, IMDLogger logger, IZipkinConfig zipkinConfig, ISpanCollectorBuilder spanCollectorBuilder) { this.logger = logger; isTraceOn = true; if (logger == null || IsConfigValuesNull(zipkinConfig) || !IsConfigValuesValid(zipkinConfig) || !IsTraceProviderValidAndSamplingOn(traceProvider)) { isTraceOn = false; } if (isTraceOn) { try { spanCollector = spanCollectorBuilder.Build(zipkinConfig.ZipkinServerName, int.Parse(zipkinConfig.ZipkinServerPort), int.Parse(zipkinConfig.SpanProcessorBatchSize)); spanCollector.Start(); spanTracer = new SpanTracer(spanCollector, zipkinConfig.ServiceName, new ServiceEndpoint()); this.requestName = requestName; this.traceProvider = traceProvider; } catch (Exception ex) { logger.Error("Error Building Zipkin Client Provider", ex); isTraceOn = false; } } }
public ZipkinClient(ITraceProvider traceProvider, string requestName, IMDLogger logger, IZipkinConfig zipkinConfig, ISpanCollectorBuilder spanCollectorBuilder) { this.logger = logger; isTraceOn = true; if ( logger == null || IsConfigValuesNull(zipkinConfig) || !IsConfigValuesValid(zipkinConfig) || !IsTraceProviderValidAndSamplingOn(traceProvider)) { isTraceOn = false; } if (isTraceOn) { try { spanCollector = spanCollectorBuilder.Build(zipkinConfig.ZipkinServerName, int.Parse(zipkinConfig.ZipkinServerPort), int.Parse(zipkinConfig.SpanProcessorBatchSize)); spanCollector.Start(); spanTracer = new SpanTracer(spanCollector, zipkinConfig.ServiceName, new ServiceEndpoint()); this.requestName = requestName; this.traceProvider = traceProvider; } catch (Exception ex) { logger.Error("Error Building Zipkin Client Provider", ex); isTraceOn = false; } } }
public ElasticsearchContextWarmer(ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource, ElasticsearchSerializerConfiguration elasticsearchSerializerConfiguration, HttpClient client, string connectionString) { _traceProvider = traceProvider; _cancellationTokenSource = cancellationTokenSource; _elasticsearchSerializerConfiguration = elasticsearchSerializerConfiguration; _client = client; _connectionString = connectionString; }
public ElasticsearchSerializer(ITraceProvider traceProvider, ElasticsearchSerializerConfiguration elasticsearchSerializerConfiguration, bool saveChangesAndInitMappingsForChildDocuments) { _elasticsearchSerializerConfiguration = elasticsearchSerializerConfiguration; _saveChangesAndInitMappingsForChildDocuments = saveChangesAndInitMappingsForChildDocuments; _traceProvider = traceProvider; _indexMappings = new IndexMappings(_traceProvider, _elasticsearchSerializerConfiguration); _elasticSerializationResult.IndexMappings = _indexMappings; }
public ElasticsearchContextExists(ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource, ElasticsearchSerializerConfiguration elasticsearchSerializerConfiguration, HttpClient client, string connectionString) { _traceProvider = traceProvider; _elasticsearchSerializerConfiguration = elasticsearchSerializerConfiguration; _connectionString = connectionString; ExistsHeadRequest = new Exists(_traceProvider, cancellationTokenSource, client); }
public void Init() { fixture = new Fixture(); spanCollectorBuilder = MockRepository.GenerateStub<ISpanCollectorBuilder>(); zipkinEndpoint = MockRepository.GenerateStub<ServiceEndpoint>(); traceProvider = MockRepository.GenerateStub<ITraceProvider>(); logger = MockRepository.GenerateStub<IMDLogger>(); requestName = fixture.Create<string>(); }
public ElasticsearchContextAddDeleteUpdate(ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource, ElasticsearchSerializerConfiguration elasticsearchSerializerConfiguration, HttpClient client, string connectionString) { _traceProvider = traceProvider; _cancellationTokenSource = cancellationTokenSource; _elasticsearchSerializerConfiguration = elasticsearchSerializerConfiguration; _client = client; _connectionString = connectionString; _elasticsearchUrlBatch = new Uri(new Uri(connectionString), BatchOperationPath); }
public InternalGet(ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource, ElasticSerializerConfiguration elasticSerializerConfiguration, HttpClient client, string connectionString) { _traceProvider = traceProvider; _cancellationTokenSource = cancellationTokenSource; _elasticSerializerConfiguration = elasticSerializerConfiguration; _client = client; _connectionString = connectionString; }
public void Init() { fixture = new Fixture(); spanCollectorBuilder = MockRepository.GenerateStub <ISpanCollectorBuilder>(); zipkinEndpoint = MockRepository.GenerateStub <ServiceEndpoint>(); traceProvider = MockRepository.GenerateStub <ITraceProvider>(); logger = MockRepository.GenerateStub <IMDLogger>(); requestName = fixture.Create <string>(); }
public TcpChannel(string serverIP, int port,string bindingIP,ITraceProvider traceProvider) { if (string.IsNullOrEmpty(serverIP)) throw new ArgumentNullException("serverIP"); _serverIP = serverIP; _port = port; _bindIP = bindingIP; _traceProvider = traceProvider; }
public ClientSessionManager(IDatabaseEngineFactory databaseEngineFactory) { _databaseEngineFactory = databaseEngineFactory; _clientSessions = new HashVector <string, ClientSession>(); SetLocalAddress(); _traceProvider = new TraceProvider(); _channelFormatter = new DbEngineFormatter(); _threadPool = new ClrThreadPool(); _threadPool.Initialize(); }
public static IDisposable StartHttpTrace(this ITraceProvider traceProvider, HttpWebRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var requestTrace = SetHttpHeadersAndCreateTrace(traceProvider?.CurrentTrace, request.RequestUri, (k, v) => request.Headers[k] = v); requestTrace?.SetTag(TraceTagNames.HttpMethod, request.Method); return(requestTrace); }
public TcpChannel(string serverIP, int port, string bindingIP, ITraceProvider traceProvider) { if (string.IsNullOrEmpty(serverIP)) { throw new ArgumentNullException("serverIP"); } _serverIP = serverIP; _port = port; _bindIP = bindingIP; _traceProvider = traceProvider; }
/// <summary> /// 构建一个跟踪提供程序 /// </summary> /// <param name="option"></param> /// <returns></returns> public static ITraceProvider Create(TraceOptions option) { lock (_lock) { if (provider == null) { provider = new TraceProvider(option); } } return(provider); }
public async Task<ResultDetails<string>> Execute(HttpClient client, string baseUrl, ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource) { var resultDetails = new ResultDetails<string> { Status = HttpStatusCode.InternalServerError }; foreach (var command in Commands) { var content = new StringContent(command.Content + "\n"); traceProvider.Trace(TraceEventType.Verbose, "{1}: sending init mappings request: {0}", command, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", command.Url, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT content: {0}", command.Content, "InitMappings"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response; if (command.RequestType == "POST") { response = await client.PostAsync(baseUrl + command.Url, content, cancellationTokenSource.Token).ConfigureAwait(true); } else { response = await client.PutAsync(baseUrl + command.Url, content, cancellationTokenSource.Token).ConfigureAwait(true); } if (response.StatusCode == HttpStatusCode.BadRequest ) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); var responseObject = JObject.Parse(errorInfo); var source = responseObject["error"]; throw new ElasticsearchCrudException("IndexMappings: Execute Request POST BadRequest: " + source); } //resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created) { traceProvider.Trace(TraceEventType.Warning, "{2}: SaveChangesAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "InitMappings"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return resultDetails; } return resultDetails; } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); traceProvider.Trace(TraceEventType.Verbose, "{1}: response: {0}", responseString, "InitMappings"); } // no errors resultDetails.Status = HttpStatusCode.OK; return resultDetails; }
public ShardConfigurationSession(ConfigurationServer service, string cluster, string shard, ServerNode server) { this.service = service; this.cluster = cluster; this.shard = shard; this.server = server; this.sessionStartTime = DateTime.Now; this.sessionId = Guid.NewGuid().ToString(); this.ConfigurationProvider = new ConfigurationProvider(); this._traceProvider = new TraceProvider(); }
public TcpChannel(string serverIP, int port, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider) { if (string.IsNullOrEmpty(serverIP)) { throw new ArgumentNullException("serverIP"); } _serverIP = serverIP; _port = port; _bindIP = bindingIP; _sessionType = sessionType; _traceProvider = traceProvider; _sourceAddress = new Address(serverIP, port); }
public void Init() { fixture = new Fixture(); traceProvider = MockRepository.GenerateStub <ITraceProvider>(); logger = MockRepository.GenerateStub <ILog>(); owinContext = MockRepository.GenerateStub <IOwinContext>(); owinContext.Stub(x => x.Environment).Return(new Dictionary <string, object>()); var request = MockRepository.GenerateStub <IOwinRequest>(); owinContext.Stub(x => x.Request).Return(request); headers = new Dictionary <string, string[]>(); request.Stub(x => x.Headers).Return(new HeaderDictionary(headers)); }
private bool IsTraceProviderValidAndSamplingOn(ITraceProvider traceProvider) { if (traceProvider == null) { logger.Error("traceProvider value is null"); return(false); } else if (string.IsNullOrEmpty(traceProvider.TraceId) || !traceProvider.IsSampled) { return(false); } return(true); }
public TcpChannel(IConnection connection, string serverIP, int port, string bindingIP, ITraceProvider traceProvider) { if (string.IsNullOrEmpty(serverIP)) { throw new ArgumentNullException("serverIP"); } _connection = connection; _connection.SetDataListener(this); _serverIP = serverIP; _port = port; _bindIP = bindingIP; _traceProvider = traceProvider; _sourceAddress = new Address(serverIP, port); }
public MainViewModel() { ProgressBarIsVisible = false; traceProvider = new TraceProvider(); parser = new HeaderDataParser(); actorSystem = ActorSystem.Create("trace-data-system"); var props = Props.Create(() => new TraceDataPersistenceActor(this)).WithRouter(new SmallestMailboxPool(1)); var actor = actorSystem.ActorOf(props, "traceData"); traceDataActorPath = actor.Path.ToStringWithAddress(); var parserProps = Props.Create(() => new TraceDataParserActor()).WithRouter(new SmallestMailboxPool(10)); var parserActor = actorSystem.ActorOf(parserProps, "parseTraceData"); parserActorPath = parserActor.Path.ToStringWithAddress(); }
/// <summary> /// Emits a trace event at the <see cref="EventSeverity.Info"/> level. /// </summary> /// <param name="provider">The trace provider being used.</param> /// <param name="message">Message.</param> /// <param name="codePoint">Code point.</param> /// <param name="data">Data.</param> /// <param name="callerMemberName">Caller member name.</param> /// <param name="callerFilePath">Caller file path.</param> /// <param name="callerLineNumber">Caller line number.</param> /// <returns>A value indicating if the emission of the trace event was successful.</returns> public static bool Info( this ITraceProvider provider, string message, string codePoint = null, Dictionary <string, string> data = null, [CallerMemberName] string callerMemberName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) => provider.Trace( EventSeverity.Info, message, codePoint, data, callerMemberName, callerFilePath, callerLineNumber);
/// <summary> /// 添加跟踪 /// </summary> /// <param name="build"></param> /// <param name="action"></param> /// <returns></returns> public static IApplicationBuilder UseTrace(this IApplicationBuilder build, Action <TraceOptions> action) { var option = new TraceOptions(); action(option); var env = build.ApplicationServices.GetService <IHostingEnvironment>(); var lifetime = build.ApplicationServices.GetService <IApplicationLifetime>(); //注册应用启动停止事件 lifetime.ApplicationStarted.Register(() => { provider = TraceBuild.Create(option); }); lifetime.ApplicationStopped.Register(() => provider?.Dispose()); //添加具体的跟踪 build.Use(async(context, next) => { var dic = new System.Collections.Generic.Dictionary <string, string>(); var request = context.Request; foreach (var kv in request.Headers) { dic.Add(kv.Key, kv.Value); } provider?.Create(dic); using (var serverTrace = new local.ServerTrace(env.ApplicationName, request.Method, request.Host.Port ?? 80)) { serverTrace.Record("http.host", request.Host.ToString()) .Record("http.uri", $"{request.Scheme}://{request.Host}{request.Path}") .Record("http.path", request.Path); await serverTrace.TracedActionAsync(next()); } }); return(build); }
public TraceDataPersistenceActor(IUpdateProgress updater) { progressUpdater = updater; traceProvider = new TraceProvider(); traces = new List <TraceData>(); Receive <SaveTraceCommand>(async trace => { int batchTotal = 100; try { if (traces.Count < batchTotal) { traces.Add(trace.TraceData); totalSize += trace.Size; } else { await traceProvider.SaveBatchTraceDataAsync(traces); //traceProvider.SaveBatchTraceData(traces); progressUpdater.UpdateProgressCounter(totalSize, batchTotal); traces = new List <TraceData>(); totalSize = 0; } } catch (Exception ex) { traces = new List <TraceData>(); totalSize = 0; progressUpdater.UpdateErrorMessage(ex.Message); } }); Receive <CompleteProcessingCommand>(async(c) => { await traceProvider.SaveBatchTraceDataAsync(traces); progressUpdater.UpdateProgressCounter(totalSize, traces.Count()); traces = new List <TraceData>(); totalSize = 0; }); }
public Span StartClientTrace(Uri remoteUri, string methodName, ITraceProvider trace) { if (!IsTraceOn) { return(null); } try { return(spanTracer.SendClientSpan( methodName.ToLower(), trace.TraceId, trace.ParentSpanId, trace.SpanId, remoteUri)); } catch (Exception ex) { return(null); } }
public Span StartClientTrace(Uri remoteUri, string methodName, ITraceProvider trace) { if (!IsTraceOn) { return(null); } try { return(spanTracer.SendClientSpan( methodName.ToLower(), trace.TraceId, trace.ParentSpanId, trace.SpanId, remoteUri)); } catch (Exception ex) { logger.Log(LogLevel.Error, () => "Error Starting Client Trace", ex); return(null); } }
public bool Initialize(ShardConfiguration configuration) { if (configuration == null) { return(false); } this.Name = configuration.Name; IPAddress localIP = GetLocalAddress(); if (context != null) { context.LocalAddress = new Common.Net.Address(localIP, configuration.Port); } _membershipManager = new MembershipManager(this, context, _clusterConfigMgr); lock (_mutexOnnodeRole) { if (NodeRole != NodeRole.Intermediate) { NodeRole = NodeRole.None; } } this._shardPeersList = GetPeersList(configuration.Servers.Nodes.Values.ToArray(), configuration.Port); //an old copy of the membership is required at the time when the node joins for comparison purposes. //_oldMembership = context.ConfigurationSession.GetMembershipInfo(context.ClusterName, context.LocalShardName); //this._shardPeersList = GetRunningPeersList(configuration.Port); //this._shardPeersList = GetRunningPeersList(_oldMembership.Servers, configuration.Port); this._traceProvider = new TraceProvider(); _resolveDispute = new ResolveChannelDispute(context, this); return(true); }
public void AddTraceProvider(ITraceProvider provider) { this.traceProviders.Add(provider); }
public IndexMappings(ITraceProvider traceProvider, ElasticsearchSerializerConfiguration elasticsearchSerializerConfiguration) { _elasticsearchSerializerConfiguration = elasticsearchSerializerConfiguration; _traceProvider = traceProvider; }
public ZipkinClient(ITraceProvider tracerProvider, string requestName, IMDLogger logger) : this(tracerProvider, requestName, logger, new ZipkinConfig(), new SpanCollectorBuilder()) { }
private bool IsTraceProviderValidAndSamplingOn(ITraceProvider traceProvider) { if (traceProvider == null) { logger.Error("traceProvider value is null"); return false; } else if (string.IsNullOrEmpty(traceProvider.TraceId) || !traceProvider.IsSampled) { return false; } return true; }
IRequestResponseChannel IChannelFactory.GetChannel(IConnection connection, string peerIP, int peerPort, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider, IChannelFormatter channelFormatter) { return(new DualChannel(connection, peerIP, peerPort, bindingIP, sessionType, traceProvider, channelFormatter, _requestTimeout)); }
public DualChannel(IConnection connection, string peerIP, int peerPort, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider, IChannelFormatter channelFormatter, int requestTimeout = 90) { //================================== tcpChannel = new TcpChannel(connection, peerIP, peerPort, bindingIP, traceProvider); tcpChannel.Formatter = channelFormatter; requestManager = new RequestManager(tcpChannel, false, requestTimeout); _peerAddress = new Address(peerIP, peerPort); DualChannelListener _lisetner = new DualChannelListener(tcpChannel.UsesAsynchronousIO ? null : new ClrThreadPool()); _lisetner.RegisterRequestListener(this); _lisetner.RegisterResponseListener(requestManager); tcpChannel.RegisterEventListener(_lisetner); //================================= }
public ViewStatePersister(Page page, ICache cache, ITraceProvider trace) : base(page) { this.cache = cache; this.trace = trace; _hiddenFiledPagePersister = new HiddenFieldPageStatePersister(page); }
public ViewStatePersister(Page page, ICache cache, ITraceProvider trace): base(page) { this.cache = cache; this.trace = trace; _hiddenFiledPagePersister = new HiddenFieldPageStatePersister(page); }
private void TestCreateCompletelyNewIndex(ITraceProvider trace) { var parentDocument = ParentDocument(); _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelOne), new ElasticsearchMappingChildDocumentForParent()); _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelTwo), new ElasticsearchMappingChildDocumentForParent()); using ( var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration( _elasticsearchMappingResolver, SaveChildObjectsAsWellAsParent, ProcessChildDocumentsAsSeparateChildIndex))) { context.TraceProvider = trace; context.AddUpdateDocument(parentDocument, parentDocument.Id); // Save to Elasticsearch var ret = context.SaveChangesAndInitMappings(); Assert.AreEqual(ret.Status, HttpStatusCode.OK); context.GetDocument<ParentDocument>(parentDocument.Id); } }
public Exists(ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource, HttpClient client) { _traceProvider = traceProvider; _cancellationTokenSource = cancellationTokenSource; _client = client; }