-
Notifications
You must be signed in to change notification settings - Fork 170
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
Application usage statistics #2387
base: master
Are you sure you want to change the base?
Conversation
|
||
@Controller | ||
@Path("/statistic/") | ||
@ConditionalOnProperty(value = "audit.trail.enabled", havingValue = "true") |
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.
If Audit Trail feature is not enabled the Controller is not efficient
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 the intent here to make the /statistic/
end-point available based on the audit.trail.enabled
property? Seems a little confusing to make an endpoint conditional vs. having it always available and to have it return based on the status of the configuration of the application.
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 personally see no problem that some of the endpoints are not available if an appropriate configuration is not at place
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 agree with @anthonysena, it is confusing because people will look at api docs and think they can call an endpoint, but it won't exist, which is confusing.
I don't see any documentation that describes that this end-piont doesn't exist when the configuration is not set.
We have rules about opt-in flags for default behavior (such as logging should be turned on/off, or auditing is enabled/distables) but the invocation of a end-point is the opt-in request of the user. If it's not enabled, it would be better to raise an error message saying 'auditing is not enabled' then return a 404 that a conditional-endpoint does not exist.
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.
Changed as suggested
private StatisticService service; | ||
|
||
public enum ResponseFormat { | ||
CSV, JSON |
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.
Both CSV and JSON output formats should be supported
src/main/java/org/ohdsi/webapi/statistic/controller/StatisticController.java
Show resolved
Hide resolved
} | ||
} | ||
|
||
private void updateExecutionStatisticsHeader(boolean showUserInformation) { |
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.
Both methods to be replaced by extra two static constants!
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.
When will this be replaced?
private String sourceName; | ||
private String executionName; | ||
private String executionDate; | ||
private String userID; |
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.
userId
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.
When do you plan to change this?
protected final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
|
||
@Value("${audit.trail.log.file}") | ||
// TODO remove value |
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.
To be configured via properties
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.
So will you remove this then?
@@ -0,0 +1,2 @@ | |||
UPDATE ${ohdsiSchema}.sec_permission SET value='statistic:executions:post' |
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 may combine both scripts into one
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.
Yes, please do and make sure the prefix of the file is v2.15...
|
||
@Controller | ||
@Path("/statistic/") | ||
@ConditionalOnProperty(value = "audit.trail.enabled", havingValue = "true") |
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 the intent here to make the /statistic/
end-point available based on the audit.trail.enabled
property? Seems a little confusing to make an endpoint conditional vs. having it always available and to have it return based on the status of the configuration of the application.
src/main/java/org/ohdsi/webapi/statistic/controller/StatisticController.java
Show resolved
Hide resolved
} | ||
} | ||
|
||
private void updateExecutionStatisticsHeader(boolean showUserInformation) { |
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.
When will this be replaced?
private String sourceName; | ||
private String executionName; | ||
private String executionDate; | ||
private String userID; |
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.
When do you plan to change this?
protected final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
|
||
@Value("${audit.trail.log.file}") | ||
// TODO remove value |
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.
So will you remove this then?
@@ -0,0 +1,2 @@ | |||
UPDATE ${ohdsiSchema}.sec_permission SET value='statistic:executions:post' |
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.
Yes, please do and make sure the prefix of the file is v2.15...
Docker build fails due to (presumably) a JDK 11 docker config. We discussed and possible least-friction solution is to check the stream syntax on regex Matcher in the stream API. Failing that, may need to find an ARM compatible JDK 8 for docker. |
…der collections are stateless, hard-coded constants deleted relying on the application configuration file Migration scripts combined
831e3e7
to
1a431c3
Compare
fixed issue with an invalid method reference exception during docker build, rebased. |
…with a 404 Not Found instead when the Audit Trail property is not switched on
@@ -92,6 +98,9 @@ public Response executionStatistics(ExecutionStatisticsRequest executionStatisti | |||
@Produces(MediaType.APPLICATION_JSON) | |||
@Consumes(MediaType.APPLICATION_JSON) | |||
public Response accessStatistics(AccessTrendsStatisticsRequest accessTrendsStatisticsRequest) { | |||
if (!auditTrailEnabled) { | |||
throw new NotFoundException("Audit Trail functionality should be enabled (audit.trail.enabled) to serve this endpoint"); |
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.
NotFound results in a 404, correct? We said that it would be confusing if someone looked at an api and attempted to call an endpoint and it was not found. I think we mentioned raising an error, such that it could return an HTTP 500 or some other HTTP code that represents an error other than 'not found'?
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 misread your passage, corrected to the internal server error
Addressing #2329
Business logic is based on parsing Audit Trail log entries. As some of the Analysis Execution entries were identified as duplicates a filter has been introduced to count each Analysis Execution precisely once
Usage examples (for the second one {} is used in the 'urlPattern' parameter to indicated a dynamic part of the URL):