private DistributedTraceInformation CorrelateFromMessage <T>(GrainMessage <T> message)
        {
            var dti = new DistributedTraceInformation();

            dti.ParentSpanId = long.Parse(message.Headers[TracingConstants.ExternalParentSpanIdHeader]);
            dti.TraceId      = long.Parse(message.Headers[TracingConstants.ExternalTraceIdHeader]);
            return(dti);
        }
        public Task <string> GreetMe(GrainMessage <string> nameMessage)
        {
            return(Task.Run <string>(() => {
                using (var span = CustomSpan.CreateEntry(this, () => { return CorrelateFromMessage <string>(nameMessage); }))
                {
                    span.SetData("name", nameMessage.Content);
                    span.SetTag("service", this.GetType().Name);

                    return $"Hello {nameMessage.Content}";
                }
            }));
        }
Пример #3
0
 private static async Task DoClientWork(IClusterClient client)
 {
     await Task.Run(async() =>
     {
         using (var span = CustomSpan.CreateEntry(null, (ISpanContext)null))
         {
             span.SetTag("service", "OrleansExampleClient");
             // example of calling grains from the initialized client
             var friend  = client.GetGrain <IHelloGrain>(0);
             var message = new GrainMessage <string>("Oliver Twist");
             using (var exitSpan = CustomSpan.CreateExit(friend, (name, value) => { message.Headers.Add(name, value); }))
             {
                 exitSpan.SetTag("service", "OrleansExampleClient");
                 var response = await friend.GreetMe(message);
                 Console.WriteLine("\n\n{0}\n\n", response);
             }
         }
     });
 }