@@ -184,7 +184,7 @@ class MockOpAMPServer {
184184 this . _port = opts . port ?? DEFAULT_PORT ;
185185 this . _endpointPath = DEFAULT_ENDPOINT_PATH ;
186186 if ( opts . agentConfigMap ) {
187- this . _setAgentConfigMap ( opts . agentConfigMap ) ;
187+ this . setAgentConfigMap ( opts . agentConfigMap ) ;
188188 }
189189 this . _server = http . createServer ( this . _onRequest . bind ( this ) ) ;
190190 this . _started = false ;
@@ -210,7 +210,32 @@ class MockOpAMPServer {
210210 }
211211 }
212212
213- _setAgentConfigMap ( agentConfigMap ) {
213+ /**
214+ * Set the data used by the server to provide `remoteConfig` to agents.
215+ *
216+ * `agentConfigMap` is of the form:
217+ * {
218+ * configMap: {
219+ * // Zero or more entries in `configMap`.
220+ * 'some-key': {
221+ * body: <Uint8Array of config file content>,
222+ * contentType: <string>
223+ * }
224+ * }
225+ * }
226+ *
227+ * Example usage:
228+ * const config = { deactivate_all_instrumentations: 'true' };
229+ * opampServer.setAgentConfigMap({
230+ * configMap: {
231+ * elastic: {
232+ * body: Buffer.from(JSON.stringify(config), 'utf8'),
233+ * contentType: 'application/json',
234+ * }
235+ * }
236+ * });
237+ */
238+ setAgentConfigMap ( agentConfigMap ) {
214239 this . _agentConfigMap = agentConfigMap ;
215240 this . _agentConfigMapHash = hashAgentConfigMap ( agentConfigMap ) ;
216241 }
@@ -362,7 +387,7 @@ class MockOpAMPServer {
362387 let agentConfigMap = { configMap : { } } ;
363388 const finish = ( ) => {
364389 log . trace ( { agentConfigMap} , 'SetAgentConfigMap' ) ;
365- this . _setAgentConfigMap ( agentConfigMap ) ;
390+ this . setAgentConfigMap ( agentConfigMap ) ;
366391 res . writeHead ( 204 ) ;
367392 res . end ( ) ;
368393 log . debug ( { req, res} , 'test API request: SetAgentConfigMap' ) ;
0 commit comments