Beispiel #1
0
        public async Task <IActionResult> PostAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            IMyActor proxy = ActorProxy.Create <IMyActor>(ActorId.CreateRandom(), new Uri(serviceUri));

            // Create and start a new activity representing the beginning of this outgoing request
            Activity activity = new Activity("HttpOut");

            activity.Start();

            DateTimeOffset startTime = DateTimeOffset.UtcNow;

            // Extract the request id and correlation context headers so they can be passed to the callee, which
            // will create the correlation
            Activity currentActivity = Activity.Current;

            string requestId = currentActivity.Id;
            Dictionary <string, string> correlationContextHeader = new Dictionary <string, string>();

            foreach (var pair in currentActivity.Baggage)
            {
                correlationContextHeader.Add(pair.Key, pair.Value);
            }

            try
            {
                await proxy.StartProcessingAsync(requestId, correlationContextHeader, CancellationToken.None);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //always stop activity if it was started
                if (activity != null)
                {
                    activity.Stop();
                }
                DateTimeOffset      endTime   = DateTimeOffset.UtcNow;
                DependencyTelemetry telemetry = new DependencyTelemetry(
                    "HTTP",               // dependencyTypeName
                    serviceUri,           // target
                    "POST " + serviceUri, // dependencyName
                    serviceUri,           // data
                    startTime,            // startTime
                    endTime - startTime,  // duration
                    "OK",                 // resultCode
                    true);                // success
                telemetry.Id = activity.Id;
                TelemetryClient client = new TelemetryClient(TelemetryConfiguration.Active);
                client.TrackDependency(telemetry);
            }

            return(this.Json(true));
        }
Beispiel #2
0
        public async Task <IActionResult> PostAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            IMyActor proxy = ActorProxy.Create <IMyActor>(ActorId.CreateRandom(), new Uri(serviceUri));

            await proxy.StartProcessingAsync(CancellationToken.None);

            return(this.Json(true));
        }
        public async Task <IActionResult> PostAsync(string actorType)
        {
            switch (actorType)
            {
            case "netcore":
                string        serviceUriNetCore = _serviceContext.CodePackageActivationContext.ApplicationName + "/" + _configSettings.ActorBackendServiceNetCoreName;
                INetCoreActor proxyNetCore      = ActorProxy.Create <INetCoreActor>(ActorId.CreateRandom(), new Uri(serviceUriNetCore));
                long          x = await proxyNetCore.GetCountAsync(CancellationToken.None);

                // await proxyNetCore.StartProcessingAsync(CancellationToken.None);
                break;

            default:
                string   serviceUri = _serviceContext.CodePackageActivationContext.ApplicationName + "/" + _configSettings.ActorBackendServiceName;
                IMyActor proxy      = ActorProxy.Create <IMyActor>(ActorId.CreateRandom(), new Uri(serviceUri));
                await proxy.StartProcessingAsync(CancellationToken.None);

                break;
            }

            return(Json(true));
        }