Example #1
0
        public SuperDumpRepository(
            IOptions <SuperDumpSettings> settings,
            BundleRepository bundleRepo,
            DumpRepository dumpRepo,
            AnalysisService analysisService,
            DownloadService downloadService,
            SymStoreService symStoreService,
            UnpackService unpackService,
            PathHelper pathHelper,
            IdenticalDumpRepository identicalRepository,
            IOneAgentSdk dynatraceSdk)
        {
            this.settings            = settings;
            this.bundleRepo          = bundleRepo;
            this.dumpRepo            = dumpRepo;
            this.analysisService     = analysisService;
            this.downloadService     = downloadService;
            this.symStoreService     = symStoreService;
            this.unpackService       = unpackService;
            this.pathHelper          = pathHelper;
            this.identicalRepository = identicalRepository;
            pathHelper.PrepareDirectories();

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "download", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
        }
Example #2
0
        public ElasticSearchService(DumpRepository dumpRepo, BundleRepository bundleRepo, PathHelper pathHelper, IOptions <SuperDumpSettings> settings,
                                    IOneAgentSdk dynatraceSdk)
        {
            this.dumpRepo   = dumpRepo ?? throw new NullReferenceException("DumpRepository must not be null!");
            this.bundleRepo = bundleRepo ?? throw new NullReferenceException("BundleRepository must not be null!");
            this.pathHelper = pathHelper ?? throw new NullReferenceException("PathHelper must not be null!");

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "elasticsearch", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);

            string host = settings.Value.ElasticSearchHost;

            if (string.IsNullOrEmpty(host))
            {
                elasticClient = null;
                return;
            }
            ConnectionSettings connSettings = new ConnectionSettings(new Uri(settings.Value.ElasticSearchHost));

            ((IConnectionSettingsValues)connSettings).DefaultIndices.Add(typeof(ElasticSDResult), RESULT_IDX);

            elasticClient = new ElasticClient(connSettings);

            if (!IndexExists())
            {
                CreateIndex();
            }
        }
Example #3
0
        public SimilarityService(DumpRepository dumpRepo, RelationshipRepository relationShipRepository, IOptions <SuperDumpSettings> settings,
                                 IOneAgentSdk dynatraceSdk)
        {
            this.dumpRepo         = dumpRepo;
            this.relationShipRepo = relationShipRepository;
            this.settings         = settings;

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "similarityanalysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
        }
        /// <summary>
        /// Consumes a message on a daemon thread using a blocking receive call
        /// (traced with the <see cref="IIncomingMessageReceiveTracer"/> and <see cref="IIncomingMessageProcessTracer"/>)
        /// The Dynatrace tag is transported along with the message
        /// </summary>
        public static void ConsumerDaemonExample()
        {
            string serverEndpoint = "messageserver.example.com:1234";
            string topic          = "my-topic";
            IMessagingSystemInfo messagingSystemInfo = SampleApplication.OneAgentSdk
                                                       .CreateMessagingSystemInfo(MessageSystemVendor.KAFKA, topic, MessageDestinationType.TOPIC, ChannelType.TCP_IP, serverEndpoint);

            IIncomingMessageReceiveTracer receiveTracer = SampleApplication.OneAgentSdk.TraceIncomingMessageReceive(messagingSystemInfo);

            receiveTracer.Start();
            try
            {
                // blocking call until message is available:
                ReceiveResult receiveResult = MyMessagingSystem.ReceiveMessage();
                Message       message       = receiveResult.Message;

                IIncomingMessageProcessTracer processTracer = SampleApplication.OneAgentSdk.TraceIncomingMessageProcess(messagingSystemInfo);

                // retrieve Dynatrace tag created using the outgoing message tracer to link both sides together:
                if (message.Headers.ContainsKey(OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME))
                {
                    processTracer.SetDynatraceByteTag(message.Headers[OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME]);
                }

                // start processing:
                processTracer.Start();
                processTracer.SetCorrelationId(message.CorrelationId);           // optional
                processTracer.SetVendorMessageId(receiveResult.VendorMessageId); // optional
                try
                {
                    ProcessMessage(message); // do the work ...
                }
                catch (Exception e)
                {
                    processTracer.Error(e);
                    // handle or rethrow
                    throw e;
                }
                finally
                {
                    processTracer.End();
                }
            }
            catch (Exception e)
            {
                receiveTracer.Error(e);
                // handle or rethrow
                throw e;
            }
            finally
            {
                receiveTracer.End();
            }
        }
Example #5
0
 public AnalysisService(
     DumpRepository dumpRepo,
     BundleRepository bundleRepo,
     PathHelper pathHelper,
     NotificationService notifications,
     AnalyzerPipeline analyzerPipeline,
     IOneAgentSdk dynatraceSdk
     )
 {
     this.dumpRepo         = dumpRepo;
     this.bundleRepo       = bundleRepo;
     this.pathHelper       = pathHelper;
     this.notifications    = notifications;
     this.analyzerPipeline = analyzerPipeline;
     this.dynatraceSdk     = dynatraceSdk;
     messagingSystemInfo   = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "analysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
 }
Example #6
0
 public AnalysisService(
     IDumpStorage dumpStorage,
     DumpRepository dumpRepo,
     BundleRepository bundleRepo,
     PathHelper pathHelper,
     IOptions <SuperDumpSettings> settings,
     NotificationService notifications,
     ElasticSearchService elasticSearch,
     SimilarityService similarityService,
     IOneAgentSdk dynatraceSdk
     )
 {
     this.dumpStorage       = dumpStorage;
     this.dumpRepo          = dumpRepo;
     this.bundleRepo        = bundleRepo;
     this.pathHelper        = pathHelper;
     this.settings          = settings;
     this.notifications     = notifications;
     this.elasticSearch     = elasticSearch;
     this.similarityService = similarityService;
     this.dynatraceSdk      = dynatraceSdk;
     messagingSystemInfo    = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "analysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
 }
        /// <summary>
        /// Produces a message (traced with the <see cref="IOutgoingMessageTracer"/>)
        /// The Dynatrace tag is transported along with the message
        /// </summary>
        public static void ProducerExample()
        {
            string serverEndpoint = "messageserver.example.com:1234";
            string topic          = "my-topic";
            IMessagingSystemInfo messagingSystemInfo = SampleApplication.OneAgentSdk
                                                       .CreateMessagingSystemInfo(MessageSystemVendor.KAFKA, topic, MessageDestinationType.TOPIC, ChannelType.TCP_IP, serverEndpoint);

            IOutgoingMessageTracer outgoingMessageTracer = SampleApplication.OneAgentSdk.TraceOutgoingMessage(messagingSystemInfo);

            outgoingMessageTracer.Start();
            try
            {
                Message message = new Message
                {
                    CorrelationId = "my-correlation-id-1234" // optional, determined by application
                };

                // transport the Dynatrace tag along with the message to allow the outgoing message tracer to be linked
                // together with the message processing tracer on the receiving side
                message.Headers[OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME] = outgoingMessageTracer.GetDynatraceByteTag();

                SendResult result = MyMessagingSystem.SendMessage(message);

                outgoingMessageTracer.SetCorrelationId(message.CorrelationId);    // optional
                outgoingMessageTracer.SetVendorMessageId(result.VendorMessageId); // optional
            }
            catch (Exception e)
            {
                outgoingMessageTracer.Error(e);
                // handle or rethrow
                throw e;
            }
            finally
            {
                outgoingMessageTracer.End();
            }
        }
Example #8
0
 public IIncomingMessageProcessTracer TraceIncomingMessageProcess(IMessagingSystemInfo messagingSystem)
 => dummyIncomingMessageProcessTracer;
Example #9
0
 public IIncomingMessageReceiveTracer TraceIncomingMessageReceive(IMessagingSystemInfo messagingSystem)
 => dummyIncomingMessageReceiveTracer;
Example #10
0
 public IOutgoingMessageTracer TraceOutgoingMessage(IMessagingSystemInfo messagingSystem)
 => dummyOutgoingMessageTracer;
        /// <summary>
        /// Produces a message (traced with the <see cref="IOutgoingMessageTracer"/>) and consumes it
        /// (traced with the <see cref="IIncomingMessageReceiveTracer"/> and <see cref="IIncomingMessageProcessTracer"/>)
        /// The Dynatrace tag is transported along with the message
        /// </summary>
        public static void ProducerConsumerExample()
        {
            string serverEndpoint = "messageserver.example.com:1234";
            string topic          = "my-topic";
            IMessagingSystemInfo messagingSystemInfo = SampleApplication.OneAgentSdk
                                                       .CreateMessagingSystemInfo(MessageSystemVendor.KAFKA, topic, MessageDestinationType.TOPIC, ChannelType.TCP_IP, serverEndpoint);

            IOutgoingMessageTracer outgoingTracer = SampleApplication.OneAgentSdk.TraceOutgoingMessage(messagingSystemInfo);

            outgoingTracer.Start();
            try
            {
                Message message = new Message
                {
                    CorrelationId = "my-correlation-id-1234" // optional, determined by application
                };

                // transport the Dynatrace tag along with the message to allow the outgoing message tracer to be linked
                // together with the message processing tracer on the receiving side
                message.Headers[OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME] = outgoingTracer.GetDynatraceByteTag();

                SendResult result = MyMessagingSystem.SendMessage(message);

                outgoingTracer.SetCorrelationId(message.CorrelationId);    // optional
                outgoingTracer.SetVendorMessageId(result.VendorMessageId); // optional
            }
            catch (Exception e)
            {
                outgoingTracer.Error(e);
                // handle or rethrow
                throw e;
            }
            finally
            {
                outgoingTracer.End();
            }

            // represents server side processing
            Thread server = new Thread(() =>
            {
                IIncomingMessageReceiveTracer receiveTracer = SampleApplication.OneAgentSdk.TraceIncomingMessageReceive(messagingSystemInfo);

                receiveTracer.Start();
                try
                {
                    // blocking call until message is available:
                    ReceiveResult receiveResult = MyMessagingSystem.ReceiveMessage();
                    Message message             = receiveResult.Message;

                    IIncomingMessageProcessTracer processTracer = SampleApplication.OneAgentSdk.TraceIncomingMessageProcess(messagingSystemInfo);

                    // retrieve Dynatrace tag created using the outgoing message tracer to link both sides together:
                    if (message.Headers.ContainsKey(OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME))
                    {
                        processTracer.SetDynatraceByteTag(message.Headers[OneAgentSdkConstants.DYNATRACE_MESSAGE_PROPERTYNAME]);
                    }

                    // start processing:
                    processTracer.Start();
                    processTracer.SetCorrelationId(message.CorrelationId);           // optional
                    processTracer.SetVendorMessageId(receiveResult.VendorMessageId); // optional
                    try
                    {
                        ProcessMessage(message); // do the work ...
                    }
                    catch (Exception e)
                    {
                        processTracer.Error(e);
                        // handle or rethrow
                        throw e;
                    }
                    finally
                    {
                        processTracer.End();
                    }
                }
                catch (Exception e)
                {
                    receiveTracer.Error(e);
                    // handle or rethrow
                    throw e;
                }
                finally
                {
                    receiveTracer.End();
                }
            });

            server.Start();
            server.Join();
        }