-
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.
Merge pull request #1706 from lilai23/feature_opentelemetry
support install external agent in Sermant
- Loading branch information
Showing
30 changed files
with
1,020 additions
and
32 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
57 changes: 57 additions & 0 deletions
57
...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,57 @@ | ||
/* | ||
* 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.CommonConstant; | ||
import io.sermant.core.common.LoggerFactory; | ||
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.Level; | ||
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(); | ||
|
||
@Override | ||
public void execute(String args) { | ||
Map<String, String> agentArgsMap = DynamicAgentArgsManager.getAgentArgsMap(); | ||
String agentPath = agentArgsMap.get(CommonConstant.AGENT_FILE_KEY); | ||
if (StringUtils.isEmpty(agentPath)) { | ||
LOGGER.severe("Failed to install external agent: AGENT_FILE in command args is empty"); | ||
return; | ||
} | ||
|
||
try { | ||
ExternalAgentManager.installExternalAgent(true, args, agentPath, agentArgsMap, | ||
CommandProcessor.getInstrumentation()); | ||
} catch (IOException | NoSuchMethodException | ClassNotFoundException | InvocationTargetException | ||
| IllegalAccessException e) { | ||
LOGGER.log(Level.SEVERE, "Failed to install external agent: {0}. Error message: {1}", | ||
new String[]{args, 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
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.