Skip to content

Commit df3fe81

Browse files
authored
Merge pull request #1711 from hyperledger/dispatch-log
Add eyecatcher log lines at info-level for transaction lifecycle
2 parents de1f917 + b5e0379 commit df3fe81

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
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: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ func (ou *operationUpdater) doBatchUpdate(ctx context.Context, updates []*core.O
270270
if err != nil {
271271
return err
272272
}
273-
transactions = append(transactions, transaction)
273+
if transaction != nil {
274+
transactions = append(transactions, transaction)
275+
}
274276
}
275277
}
276278

@@ -310,21 +312,33 @@ func (ou *operationUpdater) doUpdate(ctx context.Context, update *core.Operation
310312
}
311313

312314
// Match a TX we already retrieved, if found add a specified Blockchain Transaction ID to it
315+
var txnIDStr string
316+
var idempotencyKeyStr string
313317
var tx *core.Transaction
314-
if op.Transaction != nil && update.BlockchainTXID != "" {
318+
if op.Transaction != nil {
315319
for _, candidate := range transactions {
316320
if op.Transaction.Equals(candidate.ID) {
317321
tx = candidate
322+
txnIDStr = candidate.ID.String()
323+
idempotencyKeyStr = string(candidate.IdempotencyKey)
318324
break
319325
}
320326
}
321327
}
322-
if tx != nil {
328+
if tx != nil && update.BlockchainTXID != "" {
323329
if err := ou.txHelper.AddBlockchainTX(ctx, tx, update.BlockchainTXID); err != nil {
324330
return err
325331
}
326332
}
327333

334+
// This is a key log line, where we can provide all pieces of correlation data a user needs:
335+
// - The type of the operation
336+
// - The plugin/connector
337+
// - The idempotencyKey
338+
// - The FF Transaction ID
339+
// - The Operation ID
340+
log.L(ctx).Infof("FF_OPERATION_UPDATE: namespace=%s plugin=%s type=%s status=%s operationId=%s transactionId=%s idempotencyKey='%s'", op.Namespace, op.Plugin, op.Type, update.Status, op.ID, txnIDStr, idempotencyKeyStr)
341+
328342
if handler, ok := ou.manager.handlers[op.Type]; ok {
329343
if err := handler.OnOperationUpdate(ctx, op, update); err != nil {
330344
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: namespace=%s plugin=%s type=%s operationId=%s transactionId=%s idempotencyKey='%s'", op.Namespace, op.Plugin, op.Type, op.ID, txn.ID, txn.IdempotencyKey)
215223
}
216224
}
217225
}

0 commit comments

Comments
 (0)