Skip to content

Commit

Permalink
Add missing trigger slog events (#10357)
Browse files Browse the repository at this point in the history
closes: #10332 
closes: #8272
refs: #9569

## Description

Adds slog events for the bundle install and timer poll run triggers.
Add more context to the bridge and deliver inbound triggers.
Fixes the otel trace processing of upgrade events.

### Security Considerations
None

### Scaling Considerations
This adds a little more data to our slogs, but relatively minor compared to the amount of data we already generate.

### Documentation Considerations
None

### Testing Considerations

The integration test has limited coverage of the otel slog processor. I will repurpose #9569 to add testing in a3p, but in the mean time this change cannot affect operations and at worse the modification are not sufficient to our needs.

### Upgrade Considerations
Requires a chain software upgrade but the changes do not affect consensus and could be locally cherry-picked.
  • Loading branch information
mergify[bot] authored Oct 29, 2024
2 parents d7c994b + 03965d9 commit 745d557
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 7 deletions.
20 changes: 18 additions & 2 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ export async function launch({
inboundNum,
sender,
count: messages.length,
messages,
ack,
});
if (!mb.deliverInbound(sender, messages, ack)) {
return;
Expand All @@ -539,6 +541,7 @@ export async function launch({
type: 'cosmic-swingset-bridge-inbound',
inboundNum,
source,
body,
});
if (!bridgeInbound) throw Fail`bridgeInbound undefined`;
// console.log(`doBridgeInbound`);
Expand All @@ -547,7 +550,7 @@ export async function launch({
bridgeInbound(source, body);
}

async function installBundle(bundleJson) {
async function installBundle(bundleJson, inboundNum) {
let bundle;
try {
bundle = JSON.parse(bundleJson);
Expand All @@ -564,6 +567,13 @@ export async function launch({

const { endoZipBase64Sha512 } = bundle;

controller.writeSlogObject({
type: 'cosmic-swingset-install-bundle',
inboundNum,
endoZipBase64Sha512,
error,
});

if (installationPublisher === undefined) {
return;
}
Expand Down Expand Up @@ -645,7 +655,7 @@ export async function launch({
}

case ActionType.INSTALL_BUNDLE: {
p = installBundle(action.bundle);
p = installBundle(action.bundle, inboundNum);
break;
}

Expand Down Expand Up @@ -714,6 +724,12 @@ export async function launch({
// Then, update the timer device with the new external time, which might
// push work onto the kernel run-queue (if any timers were ready to wake).
const addedToQueue = timer.poll(blockTime);
controller.writeSlogObject({
type: 'cosmic-swingset-timer-poll',
blockHeight,
blockTime,
added: addedToQueue,
});
console.debug(
`polled; blockTime:${blockTime}, h:${blockHeight}; ADDED =`,
addedToQueue,
Expand Down
46 changes: 42 additions & 4 deletions packages/telemetry/src/context-aware-slog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* 'run.trigger.msgIdx': number;
* 'run.trigger.sender': Slog['sender'];
* 'run.trigger.source': Slog['source'];
* 'run.trigger.bundleHash': Slog['endoZipBase64Sha512'];
* 'run.trigger.time': Slog['blockTime'];
* 'run.trigger.txHash': string;
* 'run.trigger.type': string;
Expand All @@ -40,6 +41,7 @@
* runNum?: number;
* sender?: string;
* source?: string;
* endoZipBase64Sha512?: string;
* syscallNum?: number;
* time: number;
* type: string;
Expand All @@ -57,12 +59,10 @@ const SLOG_TYPES = {
FINISH: 'cosmic-swingset-bootstrap-block-finish',
START: 'cosmic-swingset-bootstrap-block-start',
},
BRIDGE_INBOUND: 'cosmic-swingset-bridge-inbound',
COMMIT: {
FINISH: 'cosmic-swingset-commit-finish',
START: 'cosmic-swingset-commit-start',
},
DELIVER_INBOUND: 'cosmic-swingset-deliver-inbound',
END_BLOCK: {
FINISH: 'cosmic-swingset-end-block-finish',
START: 'cosmic-swingset-end-block-start',
Expand All @@ -73,6 +73,12 @@ const SLOG_TYPES = {
START: 'cosmic-swingset-run-start',
},
},
COSMIC_SWINGSET_TRIGGERS: {
BRIDGE_INBOUND: 'cosmic-swingset-bridge-inbound',
DELIVER_INBOUND: 'cosmic-swingset-deliver-inbound',
TIMER_POLL: 'cosmic-swingset-timer-poll',
INSTALL_BUNDLE: 'cosmic-swingset-install-bundle',
},
CRANK: {
FINISH: 'crank-finish',
START: 'crank-start',
Expand Down Expand Up @@ -169,8 +175,8 @@ export const makeContextualSlogProcessor = (
assert(!!blockContext && !triggerContext);
break;
}
case SLOG_TYPES.COSMIC_SWINGSET.BRIDGE_INBOUND:
case SLOG_TYPES.COSMIC_SWINGSET.DELIVER_INBOUND: {
case SLOG_TYPES.COSMIC_SWINGSET_TRIGGERS.BRIDGE_INBOUND:
case SLOG_TYPES.COSMIC_SWINGSET_TRIGGERS.DELIVER_INBOUND: {
const [blockHeight, txHash, msgIdx] = (
finalBody.inboundNum || ''
).split('-');
Expand All @@ -189,6 +195,38 @@ export const makeContextualSlogProcessor = (
};
break;
}
case SLOG_TYPES.COSMIC_SWINGSET_TRIGGERS.INSTALL_BUNDLE: {
const [blockHeight, txHash, msgIdx] = (
finalBody.inboundNum || ''
).split('-');

const triggerType = 'install-bundle';

triggerContext = {
'run.num': undefined,
'run.id': `${triggerType}-${finalBody.inboundNum}`,
'run.trigger.type': triggerType,
'run.trigger.bundleHash': finalBody.endoZipBase64Sha512,
'run.trigger.blockHeight': Number(blockHeight),
'run.trigger.txHash': txHash,
'run.trigger.msgIdx': Number(msgIdx),
};

break;
}
case SLOG_TYPES.COSMIC_SWINGSET_TRIGGERS.TIMER_POLL: {
const triggerType = 'timer-poll';

triggerContext = {
'run.num': undefined,
'run.id': `${triggerType}-${finalBody.inboundNum}`,
'run.trigger.type': triggerType,
'run.trigger.time': finalBody.blockTime,
'run.trigger.blockHeight': finalBody.blockHeight,
};

break;
}
// eslint-disable-next-line no-restricted-syntax
case SLOG_TYPES.COSMIC_SWINGSET.RUN.START: {
if (!finalBody.runNum) {
Expand Down
12 changes: 11 additions & 1 deletion packages/telemetry/src/slog-to-otel.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
break;
}
case 'cosmic-swingset-upgrade-finish': {
spans.pop(['slogAttrs.blockHeight', slogAttrs.blockHeight]);
spans.pop(['upgrade', slogAttrs.blockHeight]);
dbTransactionManager.end();
break;
}
Expand Down Expand Up @@ -971,6 +971,16 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
spans.pop('bridge-inbound');
break;
}
case 'cosmic-swingset-timer-poll': {
spans.push(['timer-poll', slogAttrs.blockTime]);
spans.pop('timer-poll');
break;
}
case 'cosmic-swingset-install-bundle': {
spans.push(['install-bundle', slogAttrs.endoZipBase64Sha512]);
spans.pop('install-bundle');
break;
}
case 'cosmic-swingset-end-block-start': {
// Add `end-block` as an event onto the encompassing `block` span
spans.top()?.addEvent('end-block-action', cleanAttrs(slogAttrs), now);
Expand Down

0 comments on commit 745d557

Please sign in to comment.