Exemplo n.º 1
0
        public System.IDisposable RecieveActorMessage(
            System.Uri requestUri,
            string actorMethodName,
            FG.ServiceFabric.Actors.Remoting.Runtime.ActorMessageHeaders actorMessageHeaders,
            FG.ServiceFabric.Services.Remoting.FabricTransport.CustomServiceRequestHeader customServiceRequestHeader)
        {
            return(new ScopeWrapper(new IDisposable[]
            {
                ScopeWrapperWithAction.Wrap(() =>
                {
                    PersonActorServiceEventSource.Current.StartRecieveActorMessage(
                        _actor,
                        requestUri,
                        actorMethodName,
                        actorMessageHeaders,
                        customServiceRequestHeader
                        );

                    return new ScopeWrapperWithAction(() =>
                    {
                        PersonActorServiceEventSource.Current.StopRecieveActorMessage(
                            _actor,
                            requestUri,
                            actorMethodName,
                            actorMessageHeaders,
                            customServiceRequestHeader
                            );
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    var recieveActorMessageOperationHolder = _telemetryClient.StartOperation <RequestTelemetry>(requestUri.ToString() ?? "recieveActorMessage");
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ActorType", _actor.ActorType.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ApplicationTypeName", _actor.ApplicationTypeName);
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ApplicationName", _actor.ApplicationName);
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ServiceTypeName", _actor.ServiceTypeName);
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ServiceName", _actor.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("PartitionId", _actor.PartitionId.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ReplicaOrInstanceId", _actor.ReplicaOrInstanceId.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("NodeName", _actor.NodeName);
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("RequestUri", requestUri.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ActorMethodName", actorMethodName);
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("InterfaceId", (actorMessageHeaders?.InterfaceId ?? 0).ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("MethodId", (actorMessageHeaders?.MethodId ?? 0).ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("ActorId", actorMessageHeaders?.ActorId.ToString());
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("UserId", customServiceRequestHeader?.GetHeader("userId"));
                    recieveActorMessageOperationHolder.Telemetry.Properties.Add("CorrelationId", customServiceRequestHeader?.GetHeader("correlationId"));

                    return new ScopeWrapperWithAction(() =>
                    {
                        _telemetryClient.StopOperation <RequestTelemetry>(recieveActorMessageOperationHolder);
                    });
                }),
            }));
        }
Exemplo n.º 2
0
        public System.IDisposable CallActor(
            System.Uri requestUri,
            string actorMethodName,
            FG.ServiceFabric.Actors.Remoting.Runtime.ActorMessageHeaders actorMessageHeaders,
            FG.ServiceFabric.Services.Remoting.FabricTransport.CustomServiceRequestHeader customServiceRequestHeader)
        {
            return(new ScopeWrapper(new IDisposable[]
            {
                ScopeWrapperWithAction.Wrap(() =>
                {
                    WebApiServiceEventSource.Current.StartCallActor(
                        _context,
                        requestUri,
                        actorMethodName,
                        actorMessageHeaders,
                        customServiceRequestHeader
                        );

                    return new ScopeWrapperWithAction(() =>
                    {
                        WebApiServiceEventSource.Current.StopCallActor(
                            _context,
                            requestUri,
                            actorMethodName,
                            actorMessageHeaders,
                            customServiceRequestHeader
                            );
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    var callActorOperationHolder = _telemetryClient.StartOperation <DependencyTelemetry>(requestUri.ToString() ?? "callActor");
                    callActorOperationHolder.Telemetry.Properties.Add("ServiceName", _context.ServiceName.ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("ServiceTypeName", _context.ServiceTypeName);
                    callActorOperationHolder.Telemetry.Properties.Add("ReplicaOrInstanceId", _context.InstanceId.ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("PartitionId", _context.PartitionId.ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("ApplicationName", _context.CodePackageActivationContext.ApplicationName);
                    callActorOperationHolder.Telemetry.Properties.Add("ApplicationTypeName", _context.CodePackageActivationContext.ApplicationTypeName);
                    callActorOperationHolder.Telemetry.Properties.Add("NodeName", _context.NodeContext.NodeName);
                    callActorOperationHolder.Telemetry.Properties.Add("RequestUri", requestUri.ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("ActorMethodName", actorMethodName);
                    callActorOperationHolder.Telemetry.Properties.Add("InterfaceId", (actorMessageHeaders?.InterfaceId ?? 0).ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("MethodId", (actorMessageHeaders?.MethodId ?? 0).ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("ActorId", actorMessageHeaders?.ActorId.ToString());
                    callActorOperationHolder.Telemetry.Properties.Add("UserId", customServiceRequestHeader?.GetHeader("userId"));
                    callActorOperationHolder.Telemetry.Properties.Add("CorrelationId", customServiceRequestHeader?.GetHeader("correlationId"));

                    return new ScopeWrapperWithAction(() =>
                    {
                        _telemetryClient.StopOperation <DependencyTelemetry>(callActorOperationHolder);
                    });
                }),
            }));
        }
Exemplo n.º 3
0
        public System.IDisposable RecieveServiceMessage(
            System.Uri requestUri,
            string serviceMethodName,
            Microsoft.ServiceFabric.Services.Remoting.ServiceRemotingMessageHeaders serviceMessageHeaders,
            FG.ServiceFabric.Services.Remoting.FabricTransport.CustomServiceRequestHeader customServiceRequestHeader)
        {
            return(new ScopeWrapper(new IDisposable[]
            {
                ScopeWrapperWithAction.Wrap(() =>
                {
                    TitleActorServiceEventSource.Current.StartRecieveServiceMessage(
                        _context,
                        requestUri,
                        serviceMethodName,
                        serviceMessageHeaders,
                        customServiceRequestHeader
                        );

                    return new ScopeWrapperWithAction(() =>
                    {
                        TitleActorServiceEventSource.Current.StopRecieveServiceMessage(
                            _context,
                            requestUri,
                            serviceMethodName,
                            serviceMessageHeaders,
                            customServiceRequestHeader
                            );
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    var recieveServiceMessageOperationHolder = _telemetryClient.StartOperation <RequestTelemetry>(requestUri.ToString() ?? "recieveServiceMessage");
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ServiceName", _context.ServiceName.ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ServiceTypeName", _context.ServiceTypeName);
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ReplicaOrInstanceId", _context.ReplicaOrInstanceId.ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("PartitionId", _context.PartitionId.ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ApplicationName", _context.CodePackageActivationContext.ApplicationName);
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ApplicationTypeName", _context.CodePackageActivationContext.ApplicationTypeName);
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("NodeName", _context.NodeContext.NodeName);
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("RequestUri", requestUri.ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("ServiceMethodName", serviceMethodName);
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("InterfaceId", (serviceMessageHeaders?.InterfaceId ?? 0).ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("MethodId", (serviceMessageHeaders?.MethodId ?? 0).ToString());
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("UserId", customServiceRequestHeader?.GetHeader("userId"));
                    recieveServiceMessageOperationHolder.Telemetry.Properties.Add("CorrelationId", customServiceRequestHeader?.GetHeader("correlationId"));

                    return new ScopeWrapperWithAction(() =>
                    {
                        _telemetryClient.StopOperation <RequestTelemetry>(recieveServiceMessageOperationHolder);
                    });
                }),
            }));
        }
Exemplo n.º 4
0
        public void StopActorActive(
            )
        {
            PersonActorServiceEventSource.Current.StopActorActive(
                _actor
                );

            var actorActiveOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(actorActiveOperationHolder);
            actorActiveOperationHolder.Dispose();
        }
Exemplo n.º 5
0
        public void StopGetAll(
            )
        {
            WebApiServiceEventSource.Current.StopGetAll(
                _context
                );

            var getAllOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(getAllOperationHolder);
            getAllOperationHolder.Dispose();
        }
        public void StopActorMessageRecieved(
            string methodName,
            CodeEffect.ServiceFabric.Services.Remoting.FabricTransport.CustomServiceRequestHeader headers)
        {
            WebApiServiceEventSource.Current.StopActorMessageRecieved(
                _context,
                methodName,
                headers
                );
            var actorMessageRecievedOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(actorMessageRecievedOperationHolder);
            actorMessageRecievedOperationHolder.Dispose();
        }
        public void StopDependencyTrackingThrowsExceptionWithNullTelemetryClient()
        {
            var             operationItem = new AsyncLocalBasedOperationHolder <DependencyTelemetry>(this.telemetryClient, new DependencyTelemetry());
            TelemetryClient tc            = null;

            tc.StopOperation(operationItem);
        }
 public void StopRunAsyncLoop(
     )
 {
     DefaultEventSource.Current.StopRunAsyncLoop(
         _context
         );
     _telemetryClient.StopOperation(_runAsyncLoopOperationHolder);
     _runAsyncLoopOperationHolder.Dispose();
 }
Exemplo n.º 9
0
 public void StopLoop(
     )
 {
     DefaultEventSource.Current.StopLoop(
         _processId,
         _machineName,
         _actorId
         );
     _telemetryClient.StopOperation(_loopOperationHolder);
     _loopOperationHolder.Dispose();
 }
Exemplo n.º 10
0
        public void StopHello(
            )
        {
            Sample.Current.StopHello(

                );

            System.Diagnostics.Debug.WriteLine($"[Console] ERR: StopHello");

            _helloStopwatch.Stop();
            var helloOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(helloOperationHolder);
            helloOperationHolder.Dispose();
        }
Exemplo n.º 11
0
        public void StopLoop(
            )
        {
            Sample.Current.StopLoop(

                );

            System.Diagnostics.Debug.WriteLine($"[ConsoleRunner] ERR: StopLoop");

            _loopStopwatch.Stop();
            var loopOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(loopOperationHolder);
            loopOperationHolder.Dispose();
        }
Exemplo n.º 12
0
        public System.IDisposable RunAsyncLoop(
            )
        {
            return(new ScopeWrapper(new IDisposable[]
            {
                ScopeWrapperWithAction.Wrap(() =>
                {
                    PersonActorServiceEventSource.Current.StartRunAsyncLoop(
                        _actorService,
                        _context
                        );

                    return new ScopeWrapperWithAction(() =>
                    {
                        PersonActorServiceEventSource.Current.StopRunAsyncLoop(
                            _actorService,
                            _context
                            );
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    var runAsyncLoopOperationHolder = _telemetryClient.StartOperation <RequestTelemetry>(FG.ServiceFabric.Services.Remoting.FabricTransport.ServiceRequestContext.Current?["requestUri"] ?? "runAsyncLoop");
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ActorType", _actorService.ActorTypeInformation.ImplementationType.ToString());
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ApplicationTypeName", _actorService.Context.CodePackageActivationContext.ApplicationTypeName);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ApplicationName", _actorService.Context.CodePackageActivationContext.ApplicationName);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ServiceTypeName", _actorService.Context.ServiceTypeName);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ServiceName", _actorService.Context.ServiceName.ToString());
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("PartitionId", _actorService.Context.PartitionId.ToString());
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("ReplicaOrInstanceId", _actorService.Context.ReplicaId.ToString());
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("NodeName", _actorService.Context.NodeContext.NodeName);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("CorrelationId", FG.ServiceFabric.Services.Remoting.FabricTransport.ServiceRequestContext.Current?["correlationId"]);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("UserId", FG.ServiceFabric.Services.Remoting.FabricTransport.ServiceRequestContext.Current?["userId"]);
                    runAsyncLoopOperationHolder.Telemetry.Properties.Add("RequestUri", FG.ServiceFabric.Services.Remoting.FabricTransport.ServiceRequestContext.Current?["requestUri"]);

                    return new ScopeWrapperWithAction(() =>
                    {
                        _telemetryClient.StopOperation <RequestTelemetry>(runAsyncLoopOperationHolder);
                    });
                }),
            }));
        }
Exemplo n.º 13
0
        public void StopLoop(
            )
        {
            FGDiagnosticsAutoLoggerSamplesConsoleApplication1EventSource.Current.StopLoop(
                _autogenerated,
                _machineName
                );

            System.Diagnostics.Debug.WriteLine($"[ConsoleRunner] ERR: StopLoop");

            System.Diagnostics.Debug.WriteLine($"\t_autogenerated:\t{_autogenerated}");
            System.Diagnostics.Debug.WriteLine($"\tEnvironment.MachineName:\t{Environment.MachineName}");
            _loopStopwatch.Stop();

            var loopOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(loopOperationHolder);
            loopOperationHolder.Dispose();
        }
        public void StopHello(
            )
        {
            Sample.Current.StopHello(
                _actorId,
                _processId,
                _machineName
                );

            System.Diagnostics.Debug.WriteLine($"[Console] ERR: StopHello");

            System.Diagnostics.Debug.WriteLine($"\t_actorId.ToString():\t{_actorId.ToString()}");
            System.Diagnostics.Debug.WriteLine($"\t_actorId.Kind.ToString():\t{_actorId.Kind.ToString()}");
            System.Diagnostics.Debug.WriteLine($"\t_processId:\t{_processId}");
            System.Diagnostics.Debug.WriteLine($"\tEnvironment.MachineName:\t{Environment.MachineName}");
            _helloStopwatch.Stop();
            var helloOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(helloOperationHolder);
            helloOperationHolder.Dispose();
        }
        public void StopLoop(
            )
        {
            Sample.Current.StopLoop(
                _processId,
                _machineName,
                _actorId
                );

            System.Diagnostics.Debug.WriteLine($"[ConsoleRunner] ERR: StopLoop");

            System.Diagnostics.Debug.WriteLine($"\t_processId:\t{_processId}");
            System.Diagnostics.Debug.WriteLine($"\tEnvironment.MachineName:\t{Environment.MachineName}");
            System.Diagnostics.Debug.WriteLine($"\t_actorId.ToString():\t{_actorId.ToString()}");
            System.Diagnostics.Debug.WriteLine($"\t_actorId.Kind.ToString():\t{_actorId.Kind.ToString()}");
            _loopStopwatch.Stop();
            var loopOperationHolder = OperationHolder.StopOperation();

            _telemetryClient.StopOperation(loopOperationHolder);
            loopOperationHolder.Dispose();
        }
        public void StopOperationDoesNotFailOnNullOperation()
        {
            TelemetryClient tc = new TelemetryClient();

            tc.StopOperation <DependencyTelemetry>(null);
        }
Exemplo n.º 17
0
        // Create a CSV file and save to Blob storage with the Headers required for our Azure Function processing
        // A new request telemetry is created
        // The request is part of the parent request (since)
        public void CreateBlob(string fileName)
        {
            ///////////////////////////////////////////////////
            // Grab existing 
            ///////////////////////////////////////////////////
            Microsoft.ApplicationInsights.TelemetryClient telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
            telemetryClient.Context.User.AuthenticatedUserId = "*****@*****.**";

            string traceoperation = null;
            string traceparent = null;
            System.Console.WriteLine("telemetryClient.Context.Operation.Id: " + telemetryClient.Context.Operation.Id);
            System.Console.WriteLine("telemetryClient.Context.Session.Id: " + telemetryClient.Context.Session.Id);
            System.Console.WriteLine("telemetryClient.Context.Operation.ParentId: " + telemetryClient.Context.Operation.ParentId);

            Microsoft.ApplicationInsights.DataContracts.RequestTelemetry requestTelemetry = new Microsoft.ApplicationInsights.DataContracts.RequestTelemetry();
            requestTelemetry.Name = "Create Blob: " + fileName;
            //requestTelemetry.Source = requestContext.Replace("appId=",string.Empty);
            requestTelemetry.Timestamp = System.DateTimeOffset.Now;
            requestTelemetry.Context.Operation.Id = traceoperation;
            requestTelemetry.Context.Operation.ParentId = traceparent;
            requestTelemetry.Context.User.AuthenticatedUserId = "*****@*****.**";

            using (var requestBlock = telemetryClient.StartOperation<Microsoft.ApplicationInsights.DataContracts.RequestTelemetry>(requestTelemetry))
            {
                ///////////////////////////////////////////////////
                // Request Telemetry
                ///////////////////////////////////////////////////
                requestBlock.Telemetry.Context.User.AuthenticatedUserId = "*****@*****.**";

                if (!string.IsNullOrWhiteSpace(traceoperation))
                {
                    // Use the existing common operation id
                    requestBlock.Telemetry.Context.Operation.Id = traceoperation;
                    System.Console.WriteLine("[Use existing] traceoperation: " + traceoperation);
                }
                else
                {
                    // Set the traceoperation (we did not know it until now)
                    traceoperation = requestBlock.Telemetry.Context.Operation.Id;
                    System.Console.WriteLine("[Set the] traceoperation = requestBlock.Telemetry.Context.Operation.Id: " + traceoperation);
                }

                if (!string.IsNullOrWhiteSpace(traceparent))
                {
                    // Use the existing traceparent
                    requestBlock.Telemetry.Context.Operation.ParentId = traceparent;
                    System.Console.WriteLine("[Use existing] traceparent: " + traceparent);
                }
                else
                {
                    traceparent = requestBlock.Telemetry.Id;
                    System.Console.WriteLine("[Set the] traceparent = requestBlock.Telemetry.Id: " + traceparent);
                }
                // Store future parent id
                traceparent = requestBlock.Telemetry.Id;
                System.Console.WriteLine("traceparent = requestBlock.Telemetry.Id: " + traceparent);



                ///////////////////////////////////////////////////
                // Create Dependency for future Azure Function processing
                // NOTE: I trick it by giving a Start Time Offset of Now.AddSeconds(1), so it sorts correctly in the Azure Portal UI
                ///////////////////////////////////////////////////
                string operationName = "Dependency: Blob Event";
                // Set the target so it points to the "dependent" app insights account app id
                // string target = "03-disttrace-func-blob | cid-v1:676560d0-81fb-4e5b-bfdd-7da1ad11c866"
                string target = "03-disttrace-func-blob | cid-v1:" + System.Environment.GetEnvironmentVariable("ai_03_disttrace_web_app_appkey");
                string dependencyName = "Dependency Name: Azure Function Blob Trigger";
                Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry dependencyTelemetry =
                   new Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry(
                    operationName, target, dependencyName,
                    "02-disttrace-web-app", System.DateTimeOffset.Now.AddSeconds(1), System.TimeSpan.FromSeconds(2), "200", true);
                dependencyTelemetry.Context.Operation.Id = traceoperation;
                dependencyTelemetry.Context.Operation.ParentId = requestBlock.Telemetry.Id;
                // Store future parent id
                traceparent = dependencyTelemetry.Id;
                System.Console.WriteLine("traceparent = dependencyTelemetry.Id: " + traceparent);
                telemetryClient.TrackDependency(dependencyTelemetry);



                ///////////////////////////////////////////////////
                // Blob code
                ///////////////////////////////////////////////////
                string containerName = "appinsightstest";
                string storageConnectionString = System.Environment.GetEnvironmentVariable("ai_storage_key");
                CloudStorageAccount storageAccount = null;
                System.Console.WriteLine("storageConnectionString: " + storageConnectionString);

                CloudStorageAccount.TryParse(storageConnectionString, out storageAccount);

                System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

                list.Add("id,date");

                for (int i = 1; i <= 50000; i++)
                {
                    list.Add(i.ToString() + "," + string.Format("{0:MM/dd/yyyy}", System.DateTime.Now));
                }

                var text = string.Join("\n", list.ToArray());

                Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
                blobStorage.DefaultRequestOptions.RetryPolicy = new Microsoft.WindowsAzure.Storage.RetryPolicies.LinearRetry(System.TimeSpan.FromSeconds(1), 10);
                Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container = blobStorage.GetContainerReference(containerName);
                container.CreateIfNotExistsAsync().Wait();

                Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob blob = container.GetBlockBlobReference(fileName);

                ///////////////////////////////////////////////////
                // Set the blob's meta data
                // We need the values from the dependency
                ///////////////////////////////////////////////////
                // Request-Context: appId=cid-v1:{The App Id of the current App Insights Account}
                string requestContext = "appId=cid-v1:" + System.Environment.GetEnvironmentVariable("ai_02_disttrace_web_app_appkey");
                System.Console.WriteLine("Blob Metadata -> requestContext: " + requestContext);
                blob.Metadata.Add("RequestContext", requestContext);

                // Request-Id / traceparent: {parent request/operation id} (e.g. the Track Dependency)
                System.Console.WriteLine("Blob Metadata -> RequestId: " + traceparent);
                blob.Metadata.Add("RequestId", traceparent);
                System.Console.WriteLine("Blob Metadata -> traceparent: " + traceparent);
                blob.Metadata.Add("traceparent", traceparent);

                // Traceoperation {common operation id} (e.g. same operation id for all requests in this telemetry pipeline)
                System.Console.WriteLine("Blob Metadata -> traceoperation: " + traceoperation);
                blob.Metadata.Add("traceoperation", traceoperation);


                using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(text)))
                {
                    blob.UploadFromStreamAsync(memoryStream).Wait();
                }

                requestTelemetry.ResponseCode = "200";
                requestTelemetry.Success = true;
                telemetryClient.StopOperation(requestBlock);
            } // using

            ///////////////////////////////////////////////////
            // For Debugging
            ///////////////////////////////////////////////////
            telemetryClient.Flush();

        } // Create Blob
 public void StopOperationDoesNotFailOnNullOperation()
 {
     TelemetryClient tc = new TelemetryClient();
     tc.StopOperation<DependencyTelemetry>(null);
 }
Exemplo n.º 19
0
        public System.IDisposable CallExternalComponent(
            System.Uri requestName,
            string content)
        {
            return(new ScopeWrapper(new IDisposable[]
            {
                ScopeWrapperWithAction.Wrap(() =>
                {
                    FGDiagnosticsAutoLoggerSamplesConsoleApplication1EventSource.Current.StartCallExternalComponent(
                        _autogenerated,
                        _machineName,
                        requestName,
                        content
                        );

                    return new ScopeWrapperWithAction(() =>
                    {
                        FGDiagnosticsAutoLoggerSamplesConsoleApplication1EventSource.Current.StopCallExternalComponent(
                            _autogenerated,
                            _machineName,
                            requestName,
                            content
                            );
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    System.Diagnostics.Debug.WriteLine($"[Dependency] ERR: StartCallExternalComponent");

                    System.Diagnostics.Debug.WriteLine($"\t_autogenerated:\t{_autogenerated}");
                    System.Diagnostics.Debug.WriteLine($"\tEnvironment.MachineName:\t{Environment.MachineName}");
                    System.Diagnostics.Debug.WriteLine($"\trequestName.ToString():\t{requestName.ToString()}");
                    System.Diagnostics.Debug.WriteLine($"\tcontent:\t{content}");

                    return new ScopeWrapperWithAction(() =>
                    {
                        System.Diagnostics.Debug.WriteLine($"[Dependency] ERR: StopCallExternalComponent");

                        System.Diagnostics.Debug.WriteLine($"\t_autogenerated:\t{_autogenerated}");
                        System.Diagnostics.Debug.WriteLine($"\tEnvironment.MachineName:\t{Environment.MachineName}");
                        System.Diagnostics.Debug.WriteLine($"\trequestName.ToString():\t{requestName.ToString()}");
                        System.Diagnostics.Debug.WriteLine($"\tcontent:\t{content}");
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    _callExternalComponentStopwatch.Restart();

                    return new ScopeWrapperWithAction(() =>
                    {
                        _callExternalComponentStopwatch.Stop();
                    });
                }),


                ScopeWrapperWithAction.Wrap(() =>
                {
                    var callExternalComponentOperationHolder = _telemetryClient.StartOperation <DependencyTelemetry>(requestName.ToString() ?? "callExternalComponent");
                    callExternalComponentOperationHolder.Telemetry.Properties.Add("Autogenerated", _autogenerated.ToString());
                    callExternalComponentOperationHolder.Telemetry.Properties.Add("MachineName", Environment.MachineName);
                    callExternalComponentOperationHolder.Telemetry.Properties.Add("RequestName", requestName.ToString());
                    callExternalComponentOperationHolder.Telemetry.Properties.Add("Content", content);

                    return new ScopeWrapperWithAction(() =>
                    {
                        _telemetryClient.StopOperation <DependencyTelemetry>(callExternalComponentOperationHolder);
                    });
                }),
            }));
        }