From a03998835de919438cccf2a36e8f69f5f3f8ccce Mon Sep 17 00:00:00 2001 From: Ravishankar Date: Fri, 20 Dec 2024 20:25:22 +0530 Subject: [PATCH] Remove the config changes --- .../reference/config-blocks/livedebugging.md | 1 - internal/alloycli/cmd_run.go | 5 ++-- .../component/loki/process/process_test.go | 1 - .../service/livedebugging/livedebugging.go | 28 +++---------------- internal/service/livedebugging/service.go | 12 +------- internal/service/ui/ui.go | 7 ++--- internal/web/api/api.go | 15 +++++----- 7 files changed, 17 insertions(+), 52 deletions(-) diff --git a/docs/sources/reference/config-blocks/livedebugging.md b/docs/sources/reference/config-blocks/livedebugging.md index 33563a5119..af30cb4f2e 100644 --- a/docs/sources/reference/config-blocks/livedebugging.md +++ b/docs/sources/reference/config-blocks/livedebugging.md @@ -33,6 +33,5 @@ The following arguments are supported: | Name | Type | Description | Default | Required | | -------------------- | ----- | --------------------------------------------------------------- | ------- | -------- | | `enabled` | `bool`| Enables the live debugging feature. | `false` | no | -| `buffer_stream_size` | `int` | Buffer stream size used for buffering the live debugging entries | 1000 | no | [debug]: ../../../troubleshoot/debug/ diff --git a/internal/alloycli/cmd_run.go b/internal/alloycli/cmd_run.go index af8575dda3..7ef521ed19 100644 --- a/internal/alloycli/cmd_run.go +++ b/internal/alloycli/cmd_run.go @@ -316,9 +316,8 @@ func (fr *alloyRun) Run(cmd *cobra.Command, configPath string) error { liveDebuggingService := livedebugging.New() uiService := uiservice.New(uiservice.Options{ - UIPrefix: fr.uiPrefix, - CallbackManager: liveDebuggingService.Data().(livedebugging.CallbackManager), - LiveDebuggingConfig: liveDebuggingService.Data().(livedebugging.ConfigViewer), + UIPrefix: fr.uiPrefix, + CallbackManager: liveDebuggingService.Data().(livedebugging.CallbackManager), }) otelService := otel_service.New(l) diff --git a/internal/component/loki/process/process_test.go b/internal/component/loki/process/process_test.go index 80db22f6ed..7558b0fc6c 100644 --- a/internal/component/loki/process/process_test.go +++ b/internal/component/loki/process/process_test.go @@ -648,7 +648,6 @@ func getServiceDataWithLiveDebugging(log *testlivedebugging.Log) func(string) (i } ld.SetServiceHost(host) ld.SetEnabled(true) - ld.SetBufferStreamSize(1000) ld.AddCallback( "callback1", "", diff --git a/internal/service/livedebugging/livedebugging.go b/internal/service/livedebugging/livedebugging.go index 1a38757f1a..39bcec0805 100644 --- a/internal/service/livedebugging/livedebugging.go +++ b/internal/service/livedebugging/livedebugging.go @@ -28,23 +28,15 @@ type DebugDataPublisher interface { IsActive(componentID ComponentID) bool } -// ConfigViewer is used by components to access the configs of the live debugging -type ConfigViewer interface { - // returns the buffer stream size used by the UI service - GetBufferStreamSize() int -} - type liveDebugging struct { - loadMut sync.RWMutex - callbacks map[ComponentID]map[CallbackID]func(string) - host service.Host - enabled bool - bufferStreamSize int + loadMut sync.RWMutex + callbacks map[ComponentID]map[CallbackID]func(string) + host service.Host + enabled bool } var _ CallbackManager = &liveDebugging{} var _ DebugDataPublisher = &liveDebugging{} -var _ ConfigViewer = &liveDebugging{} // NewLiveDebugging creates a new instance of liveDebugging. func NewLiveDebugging() *liveDebugging { @@ -139,15 +131,3 @@ func (s *liveDebugging) SetEnabled(enabled bool) { defer s.loadMut.Unlock() s.enabled = enabled } - -func (s *liveDebugging) SetBufferStreamSize(size int) { - s.loadMut.Lock() - defer s.loadMut.Unlock() - s.bufferStreamSize = size -} - -func (s *liveDebugging) GetBufferStreamSize() int { - s.loadMut.RLock() - defer s.loadMut.RUnlock() - return s.bufferStreamSize -} diff --git a/internal/service/livedebugging/service.go b/internal/service/livedebugging/service.go index 78f8a3e6f5..75e0c08cd7 100644 --- a/internal/service/livedebugging/service.go +++ b/internal/service/livedebugging/service.go @@ -24,16 +24,7 @@ func New() *Service { } type Arguments struct { - Enabled bool `alloy:"enabled,attr,optional"` - BufferStreamSize int `alloy:"buffer_stream_size,attr,optional"` -} - -// SetToDefault implements syntax.Defaulter. -func (args *Arguments) SetToDefault() { - *args = Arguments{ - Enabled: false, - BufferStreamSize: 1000, - } + Enabled bool `alloy:"enabled,attr,optional"` } // Data implements service.Service. @@ -63,6 +54,5 @@ func (s *Service) Run(ctx context.Context, host service.Host) error { func (s *Service) Update(args any) error { newArgs := args.(Arguments) s.liveDebugging.SetEnabled(newArgs.Enabled) - s.liveDebugging.SetBufferStreamSize(newArgs.BufferStreamSize) return nil } diff --git a/internal/service/ui/ui.go b/internal/service/ui/ui.go index 38364f56ef..ea69448a82 100644 --- a/internal/service/ui/ui.go +++ b/internal/service/ui/ui.go @@ -23,9 +23,8 @@ const ServiceName = "ui" // Options are used to configure the UI service. Options are constant for the // lifetime of the UI service. type Options struct { - UIPrefix string // Path prefix to host the UI at. - CallbackManager livedebugging.CallbackManager // CallbackManager is used for live debugging in the UI. - LiveDebuggingConfig livedebugging.ConfigViewer // ConfigViewer is used to access the configs of liveDebugging + UIPrefix string // Path prefix to host the UI at. + CallbackManager livedebugging.CallbackManager // CallbackManager is used for live debugging in the UI. } // Service implements the UI service. @@ -79,7 +78,7 @@ func (s *Service) Data() any { func (s *Service) ServiceHandler(host service.Host) (base string, handler http.Handler) { r := mux.NewRouter() - fa := api.NewAlloyAPI(host, s.opts.CallbackManager, s.opts.LiveDebuggingConfig) + fa := api.NewAlloyAPI(host, s.opts.CallbackManager) fa.RegisterRoutes(path.Join(s.opts.UIPrefix, "/api/v0/web"), r) ui.RegisterRoutes(s.opts.UIPrefix, r) diff --git a/internal/web/api/api.go b/internal/web/api/api.go index 3283fc9518..5164f91854 100644 --- a/internal/web/api/api.go +++ b/internal/web/api/api.go @@ -25,14 +25,13 @@ import ( // AlloyAPI is a wrapper around the component API. type AlloyAPI struct { - alloy service.Host - CallbackManager livedebugging.CallbackManager - LiveDebuggingConfig livedebugging.ConfigViewer + alloy service.Host + CallbackManager livedebugging.CallbackManager } // NewAlloyAPI instantiates a new Alloy API. -func NewAlloyAPI(alloy service.Host, CallbackManager livedebugging.CallbackManager, LiveDebuggingConfig livedebugging.ConfigViewer) *AlloyAPI { - return &AlloyAPI{alloy: alloy, CallbackManager: CallbackManager, LiveDebuggingConfig: LiveDebuggingConfig} +func NewAlloyAPI(alloy service.Host, CallbackManager livedebugging.CallbackManager) *AlloyAPI { + return &AlloyAPI{alloy: alloy, CallbackManager: CallbackManager} } // RegisterRoutes registers all the API's routes. @@ -51,7 +50,7 @@ func (a *AlloyAPI) RegisterRoutes(urlPrefix string, r *mux.Router) { r.Handle(path.Join(urlPrefix, "/remotecfg/components/{id:.+}"), httputil.CompressionHandler{Handler: getComponentHandlerRemoteCfg(a.alloy)}) r.Handle(path.Join(urlPrefix, "/peers"), httputil.CompressionHandler{Handler: getClusteringPeersHandler(a.alloy)}) - r.Handle(path.Join(urlPrefix, "/debug/{id:.+}"), liveDebugging(a.alloy, a.CallbackManager, a.LiveDebuggingConfig)) + r.Handle(path.Join(urlPrefix, "/debug/{id:.+}"), liveDebugging(a.alloy, a.CallbackManager)) } func listComponentsHandler(host service.Host) http.HandlerFunc { @@ -167,12 +166,12 @@ func getClusteringPeersHandler(host service.Host) http.HandlerFunc { } } -func liveDebugging(_ service.Host, callbackManager livedebugging.CallbackManager, LiveDebuggingConfig livedebugging.ConfigViewer) http.HandlerFunc { +func liveDebugging(_ service.Host, callbackManager livedebugging.CallbackManager) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) componentID := livedebugging.ComponentID(vars["id"]) - dataCh := make(chan string, LiveDebuggingConfig.GetBufferStreamSize()) + dataCh := make(chan string, 1000) ctx := r.Context() sampleProb := setSampleProb(w, r.URL.Query().Get("sampleProb"))