Refactor: Introduce declarative configuration layer#86
Conversation
stellargo
left a comment
There was a problem hiding this comment.
Looks great overall :) Still trying out the plugin to leave any comments from functional perspective, but leaving few minor comments
| public String serviceInstanceId = UUID.randomUUID().toString(); | ||
|
|
||
| @ConfigOption(env = "REMOTING_OTEL_METRIC_FILTER") | ||
| public Pattern metricsFilterPattern = Pattern.compile(".*"); |
There was a problem hiding this comment.
hey, you can define ".*" as a common constant
There was a problem hiding this comment.
It is possible, but overall it is an overkill when there is just one usage
| try { | ||
| configParser.parse(); | ||
| } catch (ConfigurationParseException e) { | ||
| LOGGER.log(Level.WARNING, "Failed to road configuration", e); |
There was a problem hiding this comment.
similarly, can define this string in common constants as well
There was a problem hiding this comment.
same. OTOH there is a typo
| LOGGER.log(Level.WARNING, "Failed to road configuration", e); | |
| LOGGER.log(Level.WARNING, "Failed to load configuration", e); |
| } | ||
|
|
||
| @Test | ||
| public void testInvalidConfigOption() throws Exception { |
There was a problem hiding this comment.
instead of asserting for boolean hasError you can do:
@Test(expected = ConfigurationParseException.class)
| import java.util.regex.Pattern; | ||
|
|
||
| public class PatternOptionHandlerTest { | ||
| static final String TEST_ENV1= "REMOTING_OTEL_TEST_ENV1"; |
oleg-nenashev
left a comment
There was a problem hiding this comment.
There is a typo that needs to be fixed. Also I would suggest adding documentation in the same pull request.
P.S: This framework might also be an overkill and may create issues if we ever try to package Jenkins agents as native images. It is not a problem in foreseeable future
| doParse(); | ||
| } catch (ConfigurationParseException e) { | ||
| throw e; | ||
| } catch (Throwable e) { |
There was a problem hiding this comment.
It is not the best practice in general, because it would catch 'Error's that should be fatal. In this case it leads to a failure
Preparation for #71 #39 .
Enable to load configurations like this.
It supports loading config from environment variables using a
envattribute.And I'm planning to add more attributes if needed to load configurations from files, system properties, etc...
Checklist