-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support install Otel agent in Sermant
Signed-off-by: lilai <[email protected]>
- Loading branch information
Showing
21 changed files
with
892 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...tcore-core/src/main/java/io/sermant/core/command/ExternalAgentInstallCommandExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.command; | ||
|
||
import io.sermant.core.common.LoggerFactory; | ||
import io.sermant.core.event.collector.FrameworkEventCollector; | ||
import io.sermant.core.event.collector.FrameworkEventDefinitions; | ||
import io.sermant.core.ext.ExternalAgentManager; | ||
import io.sermant.core.utils.StringUtils; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.Map; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* The command executor of external agent installation | ||
* | ||
* @author lilai | ||
* @since 2024-12-14 | ||
*/ | ||
public class ExternalAgentInstallCommandExecutor implements CommandExecutor { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(); | ||
|
||
private static final String AGENT_FILE_KEY = "AGENT_FILE"; | ||
|
||
@Override | ||
public void execute(String args) { | ||
Map<String, String> agentArgsMap = DynamicAgentArgsManager.getAgentArgsMap(); | ||
String agentPath = agentArgsMap.get(AGENT_FILE_KEY); | ||
if (StringUtils.isEmpty(agentPath)) { | ||
LOGGER.severe("Failed to install external agent: AGENT_FILE in command args is empty"); | ||
return; | ||
} | ||
|
||
try { | ||
ExternalAgentManager.handleAgentInstallation(true, args, agentPath, agentArgsMap, | ||
CommandProcessor.getInstrumentation()); | ||
FrameworkEventCollector.getInstance() | ||
.collectdHotPluggingEvent(FrameworkEventDefinitions.EXTERNAL_AGENT_INSTALL, | ||
"Hot plugging command[INSTALL-EXTERNAL-AGENT] has been processed"); | ||
} catch (IOException | NoSuchMethodException | ClassNotFoundException | InvocationTargetException | ||
| IllegalAccessException e) { | ||
LOGGER.severe("Failed to install external agent: " + e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.