Skip to content

Commit cb5e4cd

Browse files
peterbroadhurstEnriqueL8
authored andcommitted
Add eyecatcher log lines at info-level for transaction lifecycle
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
1 parent 89299b0 commit cb5e4cd

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ FROM alpine:3.21 AS sbom
6666
WORKDIR /
6767
ADD . /SBOM
6868
RUN apk add --no-cache curl
69-
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.48.3
69+
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.68.1
7070
RUN trivy fs --format spdx-json --output /sbom.spdx.json /SBOM
7171
RUN trivy sbom /sbom.spdx.json --severity UNKNOWN,HIGH,CRITICAL --db-repository public.ecr.aws/aquasecurity/trivy-db --exit-code 1
7272

internal/operations/operation_updater.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,33 @@ func (ou *operationUpdater) doUpdate(ctx context.Context, update *core.Operation
310310
}
311311

312312
// Match a TX we already retrieved, if found add a specified Blockchain Transaction ID to it
313+
var txnIDStr string
314+
var idempotencyKeyStr string
313315
var tx *core.Transaction
314-
if op.Transaction != nil && update.BlockchainTXID != "" {
316+
if op.Transaction != nil {
315317
for _, candidate := range transactions {
316318
if op.Transaction.Equals(candidate.ID) {
317319
tx = candidate
320+
txnIDStr = candidate.ID.String()
321+
idempotencyKeyStr = string(candidate.IdempotencyKey)
318322
break
319323
}
320324
}
321325
}
322-
if tx != nil {
326+
if tx != nil && update.BlockchainTXID != "" {
323327
if err := ou.txHelper.AddBlockchainTX(ctx, tx, update.BlockchainTXID); err != nil {
324328
return err
325329
}
326330
}
327331

332+
// This is a key log line, where we can provide all pieces of correlation data a user needs:
333+
// - The type of the operation
334+
// - The plugin/connector
335+
// - The idempotencyKey
336+
// - The FF Transaction ID
337+
// - The Operation ID
338+
log.L(ctx).Infof("FF_OPERATION_UPDATE: plugin=%s type=%s status=%s operationId=%s transactionId=%s idempotencyKey='%s'", op.Plugin, op.Type, update.Status, op.ID, txnIDStr, idempotencyKeyStr)
339+
328340
if handler, ok := ou.manager.handlers[op.Type]; ok {
329341
if err := handler.OnOperationUpdate(ctx, op, update); err != nil {
330342
return err

internal/txwriter/txwriter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ func (tw *txWriter) processBatch(ctx context.Context, batch *txWriterBatch) erro
212212
for _, op := range req.operations {
213213
op.Transaction = txn.ID
214214
operations = append(operations, op)
215+
216+
// This is a key log line, where we can provide all pieces of correlation data a user needs:
217+
// - The type of the operation
218+
// - The plugin/connector
219+
// - The idempotencyKey
220+
// - The FF Transaction ID
221+
// - The Operation ID
222+
log.L(ctx).Infof("FF_NEW_TRANSACTION_OPERATION: plugin=%s type=%s operationId=%s transactionId=%s idempotencyKey='%s'", op.Plugin, op.Type, op.ID, txn.ID, txn.IdempotencyKey)
215223
}
216224
}
217225
}

0 commit comments

Comments
 (0)