-
Notifications
You must be signed in to change notification settings - Fork 205
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
Conversation
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.
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.
Looks good!
I've left a single comment for a possible follow-up PR.
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 |
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 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?
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’d be fine with moving them to Ref
but doesn’t have to be in 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.
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.
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.
Thanks!
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 |
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’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. |
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.
/** @param party The stable unique identifier of a Daml party. | |
/** @param party The stable unique identifier of a Daml party. |
* @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. |
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 am not sure I understand these ScalaDoc indentation changes
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.
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.
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.
Re-aligned all Scaladoc comments in domain.scala, CompletionInfo.scala, and Update.scala.
|
||
object Logging { | ||
implicit def `tagged value to LoggingValue`[T: ToLoggingValue, Tag]: ToLoggingValue[T @@ Tag] = | ||
value => value.unwrap | ||
} |
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 do not completely understand the code here yet but I have the feeling this could be quite useful for the json api too 🤔
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.
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.
Rather than disassembling them elsewhere, let's do it in one place.
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.