-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set the configuration file from the classpath of runtime attachment #2581
Conversation
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
InputStream configContentAsInputStream = | ||
ApplicationInsights.class.getResourceAsStream("/applicationinsights.json"); | ||
ApplicationInsights.class.getResourceAsStream("/" + fileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update smoke test for runtime attach to test this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but we would have to add the following kind of code to the current test:
public static void main(String[] args) {
System.setProperty("applicationinsights.runtime-attach.configuration.file", "applicationinsights-test.json");
ApplicationInsights.attach();
SpringApplication.run(SpringBootApp.class, args);
}
The users would instead add a system property with -Dapplicationinsights.runtime-attach.configuration.file=applicationinsights-test.json
. So, the test would not represent the typical way of configuring the file name. And so, the test would not document the standard way of configuring the file name.
Another option could be to rewrite a test to be able to add -Dapplicationinsights.runtime-attach.configuration.file=applicationinsights-test.json
. However, this would require a significant time for an added code pretty simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a todo for now? it's not required for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there some other form of test coverage that may be simpler (but still useful)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An approach could be to change the visibility of some methods to be able to test them. However, I don't recommend doing this. The major drawback of this approach is that we are testing implementation details, not a user use case. So, since the test is tied to implementation details, refactoring (changing the code without changing the behavior) could break it (because we remove a method, for example), adding a cost to test maintenance and slowing down and discouraging future refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a work item for the smoke test and we can discuss if/how to implement it in the future
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
…pplied with a property Apply code guideline
...ntime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java
Outdated
Show resolved
Hide resolved
…sights/attach/ApplicationInsights.java
Fix #2576