public int CacheSql(DefaultParsingResult parsingResult) { var result = this.apiCache.put(parsingResult.Sql); parsingResult.Id = result.Id; if (result.NewValue) { var sqlMetaData = new TSqlMetaData(); sqlMetaData.AgentId = AgentId; sqlMetaData.AgentStartTime = AgentStartTime; sqlMetaData.SqlId = parsingResult.Id; sqlMetaData.Sql = parsingResult.Sql; RequestPacket request = null; using (var serializer = new HeaderTBaseSerializer()) { request = new RequestPacket(IdGenerator.SequenceId(), serializer.serialize(sqlMetaData)); this.enhancedDataSender.Send(request.ToBuffer()); } } return(result.Id); }
public int CacheApi(MethodDescriptor methodDescriptor) { var fullName = methodDescriptor.GetFullName(); var result = this.apiCache.put(fullName); methodDescriptor.ApiId = result.Id; if (result.NewValue) { var apiMetadata = new TApiMetaData(); apiMetadata.AgentId = agentId; apiMetadata.AgentStartTime = agentStartTime; apiMetadata.ApiId = result.Id; apiMetadata.ApiInfo = methodDescriptor.ApiDescriptor; apiMetadata.Line = methodDescriptor.LineNumber; apiMetadata.Type = methodDescriptor.Type; RequestPacket request = null; using (var serializer = new HeaderTBaseSerializer()) { request = new RequestPacket(IdGenerator.SequenceId(), serializer.serialize(apiMetadata)); this.enhancedDataSender.Send(request.ToBuffer()); } } return(result.Id); }
public void FlushMsg(object state) { if (!flushMsgThreadSignal.WaitOne(5)) { return; } flushMsgThreadSignal.Reset(); try { TBase msg = null; using (var serializer = new HeaderTBaseSerializer()) { while (cachedQueue.TryDequeue(out msg)) { var data = serializer.serialize(msg); server.SendTo(data, ipep); } } } catch (Exception ex) { Common.Logger.Current.Error(ex.ToString()); } flushMsgThreadSignal.Set(); }
private void SendAgentInfo() { var agentConfig = TinyIoCContainer.Current.Resolve <AgentConfig>(); while (true) { var agentInfo = new TAgentInfo { AgentId = agentConfig.AgentId, Hostname = agentConfig.HostName, ApplicationName = agentConfig.ApplicationName, AgentVersion = agentConfig.AgentVersion, VmVersion = "1.8.0_121", ServiceType = 1010, StartTimestamp = agentConfig.AgentStartTime, JvmInfo = new TJvmInfo() { Version = 0, VmVersion = "1.8.0_121", GcType = TJvmGcType.PARALLEL } }; try { using (var serializer = new HeaderTBaseSerializer()) { var payload = serializer.serialize(agentInfo); var request = new RequestPacket(IdGenerator.SequenceId(), payload); tcpClient.Send(request.ToBuffer()); } } catch (Exception ex) { Logger.Current.Error(ex.ToString()); } Thread.Sleep(5 * 60 * 1000); } }
private void SendAgentStatInfo() { var agentConfig = TinyIoCContainer.Current.Resolve <AgentConfig>(); var pinpointConfig = TinyIoCContainer.Current.Resolve <PinpointConfig>(); while (true) { IPEndPoint ip = new IPEndPoint(IPAddress.Parse(pinpointConfig.CollectorIp), pinpointConfig.UdpStatListenPort); Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); #region assemble agent stat batch entity var agentStatBatch = new TAgentStatBatch(); agentStatBatch.AgentId = agentConfig.AgentId; agentStatBatch.StartTimestamp = agentConfig.AgentStartTime; agentStatBatch.AgentStats = new List <TAgentStat>(); #endregion #region assemble agent stat entity var agentStat = new TAgentStat(); agentStat.AgentId = agentConfig.AgentId; agentStat.StartTimestamp = agentConfig.AgentStartTime; agentStat.Timestamp = TimeUtils.GetCurrentTimestamp(); agentStat.CollectInterval = 5000; agentStat.Gc = new TJvmGc() { Type = TJvmGcType.PARALLEL, JvmMemoryHeapUsed = 73842768, JvmMemoryHeapMax = 436207616, JvmMemoryNonHeapUsed = 196555576, JvmMemoryNonHeapMax = -1, JvmGcOldCount = 5, JvmGcOldTime = 945, JvmGcDetailed = new TJvmGcDetailed() { JvmGcNewCount = 110, JvmGcNewTime = 1666, JvmPoolCodeCacheUsed = 0.22167689005533855, JvmPoolNewGenUsed = 0.025880894190828566, JvmPoolOldGenUsed = 0.20353155869704026, JvmPoolSurvivorSpaceUsed = 0.4635740007672991, JvmPoolMetaspaceUsed = 0.9706939329583961 } }; agentStat.CpuLoad = new TCpuLoad() { JvmCpuLoad = 0.002008032128514056, SystemCpuLoad = AgentStat.GetCpuLoad() }; agentStat.Transaction = new TTransaction() { SampledNewCount = 0, SampledContinuationCount = 0, UnsampledContinuationCount = 0, UnsampledNewCount = 0 }; agentStat.ActiveTrace = new TActiveTrace() { Histogram = new TActiveTraceHistogram() { Version = 0, HistogramSchemaType = 2, ActiveTraceCount = new List <int>() { 0, 0, 0, 0 } } }; agentStat.DataSourceList = new TDataSourceList() { DataSourceList = new List <TDataSource>() { new TDataSource() { Id = 1, DatabaseName = "test", ServiceTypeCode = 6050, Url = "jdbc:mysql://192.168.1.1:3306/test", MaxConnectionSize = 8 } } }; #endregion for (var i = 0; i < 6; i++) { agentStat.Timestamp -= 5000; agentStatBatch.AgentStats.Add(agentStat); } try { using (var serializer = new HeaderTBaseSerializer()) { var data = serializer.serialize(agentStatBatch); server.SendTo(data, ip); } } catch (Exception ex) { Logger.Current.Error(ex.ToString()); } Thread.Sleep(5 * 60 * 1000); } }