private string InstrumentationUpdate(IDictionary <string, object> arguments)
        {
            if (arguments.TryGetValue("instrumentation", out var instrumentationSetObject))
            {
                if (instrumentationSetObject is JObject instrumentationSet)
                {
                    try
                    {
                        var instrumentationConfig = instrumentationSet.ToObject <ServerConfiguration.InstrumentationConfig>();
                        _instrumentationService.AddOrUpdateLiveInstrumentation(instrumentationConfig.Name, instrumentationConfig.Config);
                        _instrumentationService.ApplyInstrumentation();
                    }
                    catch (Exception e)
                    {
                        Log.Error(e);
                        return("The instrumentation update was malformed");
                    }
                }
                else
                {
                    return("The instrumentation update instrumentation set was empty");
                }
            }
            else
            {
                return("The instrumentation key was missing");
            }

            Log.Debug($"{Name} command complete.");
            return(null);
        }
        private void OnServerConfigurationUpdated(ServerConfigurationUpdatedEvent serverConfigurationUpdatedEvent)
        {
            var instrumentation = serverConfigurationUpdatedEvent.Configuration.Instrumentation;

            if (instrumentation != null && !instrumentation.IsEmpty())
            {
                if (_configuration.CustomInstrumentationEditorEnabled)
                {
                    try
                    {
                        foreach (var instrumentationSet in instrumentation)
                        {
                            _instrumentationService.AddOrUpdateLiveInstrumentation(instrumentationSet.Name, instrumentationSet.Config);
                        }

                        Log.InfoFormat("Applying live instrumentation from Custom Instrumentation Editor.");

                        // We want to apply custom instrumentation regardless of whether or not any was received on
                        // this connect because we may have received instrumentation on a previous connect.
                        _instrumentationService.ApplyInstrumentation();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                    }
                }
                else
                {
                    Log.WarnFormat("Live instrumentation received from server Custom Instrumentation Editor not applied due to configuration.");
                    var liveInstrumentationCleared = _instrumentationService.ClearLiveInstrumentation();
                    if (liveInstrumentationCleared)
                    {
                        Log.Info("Clearing out existing live instrumentation because the configuration was previously enabled, but it is now disabled.");
                        _instrumentationService.ApplyInstrumentation();
                    }
                }
            }
        }