Skip to content
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

Move logging value definitions alongside their objects. #10439

Merged
merged 4 commits into from
Jul 29, 2021

Conversation

ghost
Copy link

@ghost ghost commented Jul 28, 2021

Rather than disassembling them elsewhere, let's do it in one place.

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

There's no reason for it to need `equals`, etc.

CHANGELOG_BEGIN
CHANGELOG_END
Instead of having a function, let's use `ToLoggingContext`.

This also adds a couple of missing items, and always logs `workflowId`.
Instead of having a function, let's use `ToLoggingContext`.

This changes some of the logging context structure, but otherwise
everything remains the same.
Copy link
Contributor

@kamil-da kamil-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
I've left a single comment for a possible follow-up PR.

Comment on lines +395 to +406
private object Logging {
def recordTime(timestamp: Timestamp): LoggingEntry =
"recordTime" -> timestamp.toInstant

def submissionId(id: Ref.SubmissionId): LoggingEntry =
"submissionId" -> id

def submissionIdOpt(id: Option[Ref.SubmissionId]): LoggingEntry =
"submissionId" -> id

def participantId(id: Ref.ParticipantId): LoggingEntry =
"participantId" -> id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we would like to keep some of T => LoggingEntry methods private to specific classes/packages because of required domain context that is known only in such class/package. However, we could at least consider moving methods for Ref types to a common object. Currently we have multiple definitions for several of Ref types, e.g. for Ref.SubmissionId.
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d be fine with moving them to Ref but doesn’t have to be in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be somewhat OK with this.

TBH I'm not sure these methods add too much but clearly others find value in them, so I guess there's something to it. I was tempted to inline them all.

That said, I'd prefer to find a way to derive these automatically from the type. Right now SubmissionId and some others are just type aliases to LedgerString though, so that wouldn't work.

Copy link
Contributor

@cocreature cocreature left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +395 to +406
private object Logging {
def recordTime(timestamp: Timestamp): LoggingEntry =
"recordTime" -> timestamp.toInstant

def submissionId(id: Ref.SubmissionId): LoggingEntry =
"submissionId" -> id

def submissionIdOpt(id: Option[Ref.SubmissionId]): LoggingEntry =
"submissionId" -> id

def participantId(id: Ref.ParticipantId): LoggingEntry =
"participantId" -> id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d be fine with moving them to Ref but doesn’t have to be in this PR.

)
}

/** @param party The stable unique identifier of a Daml party.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @param party The stable unique identifier of a Daml party.
/** @param party The stable unique identifier of a Daml party.

Comment on lines 12 to 27
* @param actAs the non-empty set of parties that submitted the change.
* @param applicationId an identifier for the Daml application that submitted the command.
* @param commandId a submitter-provided identifier to identify an intended ledger change
* within all the submissions by the same parties and application.
* @param optDeduplicationPeriod The deduplication period that the [[WriteService]] actually uses for the command submission.
* It may differ from the suggested deduplication period given to [[WriteService.submitTransaction]] or [[WriteService.rejectSubmission]].
* For example, the suggested deduplication period may have been converted into a different kind or extended.
* The particular choice depends on the particular implementation.
* This allows auditing the deduplication guarantee described in the [[ReadService.stateUpdates]].
* It may differ from the suggested deduplication period given to [[WriteService.submitTransaction]] or [[WriteService.rejectSubmission]].
* For example, the suggested deduplication period may have been converted into a different kind or extended.
* The particular choice depends on the particular implementation.
* This allows auditing the deduplication guarantee described in the [[ReadService.stateUpdates]].
*
* Optional as some implementations may not be able to provide this deduplication information.
* If an implementation does not provide this deduplication information,
* it MUST adhere to the deduplication guarantee under a sensible interpretation
* of the corresponding [[SubmitterInfo.deduplicationPeriod]].
* @param submissionId An identifier for the submission that allows an application
* to correlate completions to its submissions.
* Optional as some implementations may not be able to provide this deduplication information.
* If an implementation does not provide this deduplication information,
* it MUST adhere to the deduplication guarantee under a sensible interpretation
* of the corresponding [[CompletionInfo.deduplicationPeriod]].
* @param submissionId An identifier for the submission that allows an application
* to correlate completions to its submissions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand these ScalaDoc indentation changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntelliJ has made it happen. I actually hadn't realized it did it, it must have been on commit. Shame on me for not reading through my PR before opening it.

I will make sure they're all aligned.

Copy link
Author

@ghost ghost Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-aligned all Scaladoc comments in domain.scala, CompletionInfo.scala, and Update.scala.

@ghost ghost added the automerge label Jul 29, 2021
Comment on lines +361 to +365

object Logging {
implicit def `tagged value to LoggingValue`[T: ToLoggingValue, Tag]: ToLoggingValue[T @@ Tag] =
value => value.unwrap
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not completely understand the code here yet but I have the feeling this could be quite useful for the json api too 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says that if we have a type T, a type Tag, and an instance of ToLoggingValue[T], then we also have an instance of ToLoggingValue[T @@ Tag] (which just discards the tag).

For example, if we have a value of type Ref.TransactionId @@ TransactionIdTag, we can convert it to a logging value, because we know how to convert Ref.TransactionId to a logging value.

Happy to discuss further offline if you'd like to understand more.

@mergify mergify bot merged commit 9c08e4c into main Jul 29, 2021
@mergify mergify bot deleted the samir/reduce-logging-entries branch July 29, 2021 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants