static void Main(string[] args)
 {
     while (true)
     {
         // let's start with a simple entry-span
         using (var entrySpan = CustomSpan.CreateEntryForNewTrace(null).AsMessageReceiveFrom("out_of_nowhere"))
         {
             // now let's do some work.
             Worker w = new Worker();
             w.DoSomeWork("Please do something!");
         }
         Console.WriteLine("Hit <enter> to repeat, enter 'q' to quit>");
         var input = Console.ReadLine();
         if (input == "q")
         {
             break;
         }
     }
 }
        public void ExecuteJob(string input, Dictionary <string, object> stepResults)
        {
            // let's create the root for our trace. A trace always starts with an entry
            // (something enters a system, which leads to a reaction)
            using (var traceRoot = CustomSpan.CreateEntryForNewTrace(this))
            {
                // since we want to collect errors happening during the process, we
                // wrap the call, so that any exception will be automatically collected
                // and added to our trace, at the call where it happened.
                traceRoot.WrapAction(() =>
                {
                    string mutatedInput = input;
                    Guid jobId          = Guid.NewGuid();
                    // add some tags to our trace, so that we can identify it later
                    // based on our own data, not instana internals
                    traceRoot.SetTag(new string[] { "JobId" }, jobId.ToString());
                    traceRoot.SetTag(new string[] { "Pipeline-Length" }, _pipelineSteps.Count.ToString());
                    traceRoot.SetTag(new string[] { "Input" }, input);

                    // execute each step in the pipeline.
                    // we're pretending to have an exit-call for every step
                    // (it _could_ be a remote-service, but in this example it isn't...)
                    foreach (IStep step in _pipelineSteps)
                    {
                        using (var exit = CustomSpan.CreateExit(this, null))
                        {
                            // each step could throw an exception, so wrap the call
                            // to extract the error-information and let it automatically be
                            // added to our trace...
                            // after collecting the exception, bubble it up
                            exit.WrapAction(() =>
                            {
                                mutatedInput = step.Execute(mutatedInput, stepResults);
                            }, true);
                        }
                    }
                }, true);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Custom Messaging System v1.0");
            Console.WriteLine("----------------------------");
            MessageClient client = new MessageClient();

            client.Connect("awesome-topic");
            while (true)
            {
                Console.Write("Enter message > ");
                string message = Console.ReadLine();
                using (var rootSpan = CustomSpan.CreateEntryForNewTrace(null))
                {
                    client.Send(new Message()
                    {
                        Topic = "awesome-topic", Body = message
                    });
                }

                Thread.Sleep(500);
            }
        }