-
Notifications
You must be signed in to change notification settings - Fork 29
Re-Add debug logging for ds listing #8251
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f0b1b2f
add debug logging for dataset list route
82690ac
add extensive logging to listGrouped method of DatasetController
ed69e48
Merge branch 'master' into add-debug-logging-for-ds-listing
fm3 4c75c97
dont log full objects
fe47da7
Merge branch 'add-debug-logging-for-ds-listing' of github.com:scalabl…
b6e432b
Merge branch 'master' into add-debug-logging-for-ds-listing
fm3 6295857
restore logging full object except for user objects
2179355
Merge branch 'add-debug-logging-for-ds-listing' of github.com:scalabl…
d7bebd7
Merge branch 'master' of github.com:scalableminds/webknossos into add…
08678ab
re add extensive logging for debugging
5723c74
Merge branches 'add-debug-logging-for-ds-listing' and 'master' of git…
932c473
re add global access context to finding organizations in DSController…
d19bb41
Merge branch 'master' into add-debug-logging-for-ds-listing
fm3 abab9a8
Merge branch 'master' into add-debug-logging-for-ds-listing
MichaelBuessemeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -176,70 +176,91 @@ class DatasetController @Inject()(userService: UserService, | |
// Change output format to return only a compact list with essential information on the datasets | ||
compact: Option[Boolean] | ||
): Action[AnyContent] = sil.UserAwareAction.async { implicit request => | ||
for { | ||
folderIdValidated <- Fox.runOptional(folderId)(ObjectId.fromString) | ||
uploaderIdValidated <- Fox.runOptional(uploaderId)(ObjectId.fromString) | ||
organizationIdOpt = if (onlyMyOrganization.getOrElse(false)) | ||
request.identity.map(_._organization) | ||
else | ||
organizationId | ||
js <- if (compact.getOrElse(false)) { | ||
for { | ||
datasetInfos <- datasetDAO.findAllCompactWithSearch( | ||
isActive, | ||
isUnreported, | ||
organizationIdOpt, | ||
folderIdValidated, | ||
uploaderIdValidated, | ||
searchQuery, | ||
request.identity.map(_._id), | ||
recursive.getOrElse(false), | ||
limitOpt = limit | ||
) | ||
} yield Json.toJson(datasetInfos) | ||
} else { | ||
for { | ||
datasets <- datasetDAO.findAllWithSearch(isActive, | ||
isUnreported, | ||
organizationIdOpt, | ||
folderIdValidated, | ||
uploaderIdValidated, | ||
searchQuery, | ||
recursive.getOrElse(false), | ||
limit) ?~> "dataset.list.failed" | ||
js <- listGrouped(datasets, request.identity) ?~> "dataset.list.failed" | ||
} yield Json.toJson(js) | ||
} | ||
_ = Fox.runOptional(request.identity)(user => userDAO.updateLastActivity(user._id)) | ||
} yield addRemoteOriginHeaders(Ok(js)) | ||
log() { | ||
for { | ||
folderIdValidated <- Fox.runOptional(folderId)(ObjectId.fromString) | ||
uploaderIdValidated <- Fox.runOptional(uploaderId)(ObjectId.fromString) | ||
organizationIdOpt = if (onlyMyOrganization.getOrElse(false)) | ||
request.identity.map(_._organization) | ||
else | ||
organizationId | ||
js <- if (compact.getOrElse(false)) { | ||
for { | ||
datasetInfos <- datasetDAO.findAllCompactWithSearch( | ||
isActive, | ||
isUnreported, | ||
organizationIdOpt, | ||
folderIdValidated, | ||
uploaderIdValidated, | ||
searchQuery, | ||
request.identity.map(_._id), | ||
recursive.getOrElse(false), | ||
limitOpt = limit | ||
) | ||
} yield Json.toJson(datasetInfos) | ||
} else { | ||
for { | ||
_ <- Fox.successful(()) | ||
_ = logger.info( | ||
s"Requesting listing datasets with isActive '$isActive', isUnreported '$isUnreported', organizationId '$organizationIdOpt', folderId '$folderIdValidated', uploaderId '$uploaderIdValidated', searchQuery '$searchQuery', recursive '$recursive', limit '$limit'") | ||
datasets <- datasetDAO.findAllWithSearch(isActive, | ||
isUnreported, | ||
organizationIdOpt, | ||
folderIdValidated, | ||
uploaderIdValidated, | ||
searchQuery, | ||
recursive.getOrElse(false), | ||
limit) ?~> "dataset.list.failed" ?~> "Dataset listing failed" | ||
_ = logger.info(s"Found ${datasets.size} datasets successfully") | ||
js <- listGrouped(datasets, request.identity) ?~> "dataset.list.failed" ?~> "Grouping datasets failed" | ||
} yield Json.toJson(js) | ||
} | ||
_ = Fox.runOptional(request.identity)(user => userDAO.updateLastActivity(user._id)) | ||
} yield addRemoteOriginHeaders(Ok(js)) | ||
} | ||
} | ||
|
||
private def listGrouped(datasets: List[Dataset], requestingUser: Option[User])( | ||
implicit ctx: DBAccessContext, | ||
m: MessagesProvider): Fox[List[JsObject]] = | ||
for { | ||
_ <- Fox.successful(()) | ||
_ = logger.info(s"datasets: $datasets, requestingUser: ${requestingUser.map(_._id)}") | ||
Comment on lines
+227
to
+228
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid logging sensitive information The logging statements include sensitive information like user IDs and dataset details. Consider:
- _ = logger.info(s"datasets: $datasets, requestingUser: ${requestingUser.map(_._id)}")
+ _ = logger.debug("Processing datasets",
+ "datasetCount" -> datasets.size,
+ "hasRequestingUser" -> requestingUser.isDefined)
- _ = logger.info(s"byOrgaTuple orga: ${byOrgaTuple._1}, datasets: ${byOrgaTuple._2}")
+ _ = logger.debug("Processing organization datasets",
+ "organizationId" -> byOrgaTuple._1,
+ "datasetCount" -> byOrgaTuple._2.size)
- logger.info(s"datastore: ${byDataStoreTuple._1}, datasets: ${byDataStoreTuple._2}")
+ logger.debug("Processing datastore datasets",
+ "datastoreName" -> byDataStoreTuple._1,
+ "datasetCount" -> byDataStoreTuple._2.size) Also applies to: 238-239, 244-244 |
||
requestingUserTeamManagerMemberships <- Fox.runOptional(requestingUser)(user => | ||
userService.teamManagerMembershipsFor(user._id)) | ||
userService | ||
.teamManagerMembershipsFor(user._id)) ?~> s"Could not find team manager memberships for user ${requestingUser | ||
.map(_._id)}" | ||
_ = logger.info( | ||
s"requestingUserTeamManagerMemberships: ${requestingUserTeamManagerMemberships.map(_.map(_.toString))}") | ||
groupedByOrga = datasets.groupBy(_._organization).toList | ||
js <- Fox.serialCombined(groupedByOrga) { byOrgaTuple: (String, List[Dataset]) => | ||
for { | ||
organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext) | ||
_ <- Fox.successful(()) | ||
_ = logger.info(s"byOrgaTuple orga: ${byOrgaTuple._1}, datasets: ${byOrgaTuple._2}") | ||
organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext) ?~> s"Could not find organization ${byOrgaTuple._1}" | ||
groupedByDataStore = byOrgaTuple._2.groupBy(_._dataStore).toList | ||
_ <- Fox.serialCombined(groupedByDataStore) { byDataStoreTuple: (String, List[Dataset]) => | ||
{ | ||
logger.info(s"datastore: ${byDataStoreTuple._1}, datasets: ${byDataStoreTuple._2}") | ||
Fox.successful(()) | ||
} | ||
} | ||
result <- Fox.serialCombined(groupedByDataStore) { byDataStoreTuple: (String, List[Dataset]) => | ||
for { | ||
dataStore <- dataStoreDAO.findOneByName(byDataStoreTuple._1.trim)(GlobalAccessContext) | ||
dataStore <- dataStoreDAO.findOneByName(byDataStoreTuple._1.trim)(GlobalAccessContext) ?~> | ||
s"Could not find data store ${byDataStoreTuple._1}" | ||
resultByDataStore: Seq[JsObject] <- Fox.serialCombined(byDataStoreTuple._2) { d => | ||
datasetService.publicWrites( | ||
d, | ||
requestingUser, | ||
Some(organization), | ||
Some(dataStore), | ||
requestingUserTeamManagerMemberships) ?~> Messages("dataset.list.writesFailed", d.name) | ||
} | ||
} ?~> "Could not find public writes for datasets" | ||
} yield resultByDataStore | ||
} | ||
} ?~> s"Could not group by datastore for datasets ${byOrgaTuple._2.map(_._id)}" | ||
} yield result.flatten | ||
} | ||
} ?~> s"Could not group by organization for datasets ${datasets.map(_._id)}" | ||
} yield js.flatten | ||
|
||
def accessList(datasetId: String): Action[AnyContent] = sil.SecuredAction.async { implicit request => | ||
|
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Consider adjusting log levels and format for production use
The logging statements provide valuable debugging information but consider:
Also applies to: 214-214