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

Updated HistoryEvent type case to camelCase #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ export class OrchestrationFields extends React.Component<{ state: OrchestrationD
private renderEventLink(event: HistoryEvent): JSX.Element | string {

const state = this.props.state;
const functionName = event.Name;
const functionName = event.name;

if (!!event.SubOrchestrationId) {
return (<OrchestrationLink orchestrationId={event.SubOrchestrationId}
if (!!event.subOrchestrationId) {
return (<OrchestrationLink orchestrationId={event.subOrchestrationId}
title={functionName}
backendClient={state.backendClient}
/>);
Expand Down Expand Up @@ -393,34 +393,34 @@ export class OrchestrationFields extends React.Component<{ state: OrchestrationD
color={Theme.palette.mode === 'dark' ? 'inherit' : 'primary'}
onClick={() => {

this.props.state.timeFrom = moment(event.Timestamp);
this.props.state.timeFrom = moment(event.timestamp);
this.props.state.reloadHistory();
}}
>
{this.context.formatDateTimeString(event.Timestamp)}
{this.context.formatDateTimeString(event.timestamp)}
</Link>

</TableCell>
<TableCell style={cellStyle}>
{event.EventType}
{event.eventType}
</TableCell>
<TableCell style={cellStyle}>
{event.EventId}
{event.eventId}
</TableCell>
<TableCell className="name-cell" style={cellStyle}>
{this.renderEventLink(event)}
</TableCell>
<TableCell style={cellStyle}>
{this.context.formatDateTimeString(event.ScheduledTime)}
{this.context.formatDateTimeString(event.scheduledTime)}
</TableCell>
<TableCell className="long-text-cell" style={cellStyle}>
{LongJsonDialog.renderJson(event.Input, '', () => this.props.state.longJsonDialogState.showDialog(`${event.EventType} / ${event.Name} / ${HistoryEventFields[5]}`, event.Input))}
{LongJsonDialog.renderJson(event.input, '', () => this.props.state.longJsonDialogState.showDialog(`${event.eventType} / ${event.name} / ${HistoryEventFields[5]}`, event.input))}
</TableCell>
<TableCell className="long-text-cell" style={cellStyle}>
{LongJsonDialog.renderJson(event.Result, '', () => this.props.state.longJsonDialogState.showDialog(`${event.EventType} / ${event.Name} / ${HistoryEventFields[6]}`, event.Result))}
{LongJsonDialog.renderJson(event.input, '', () => this.props.state.longJsonDialogState.showDialog(`${event.eventType} / ${event.name} / ${HistoryEventFields[6]}`, event.result))}
</TableCell>
<TableCell className="long-text-cell" style={cellStyle}>
{LongJsonDialog.renderJson(event.Details, '', () => this.props.state.longJsonDialogState.showDialog(`${event.EventType} / ${event.Name} / ${HistoryEventFields[7]}`, event.Details))}
{LongJsonDialog.renderJson(event.input, '', () => this.props.state.longJsonDialogState.showDialog(`${event.eventType} / ${event.name} / ${HistoryEventFields[7]}`, event.details))}
</TableCell>
</TableRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

// A DTO used by DurableOrchestrationStatus.historyEvents
export class HistoryEvent {
Timestamp: string;
EventType: string;
EventId: number;
Name: string;
ScheduledTime: string;
DurationInMs: number;
SubOrchestrationId: string;
Input: any;
Result: any;
Details: any;
timestamp: string;
eventType: string;
eventId: number;
name: string;
scheduledTime: string;
durationInMs: number;
subOrchestrationId: string;
input: any;
result: any;
details: any;
}

// Extends HistoryEvent with history for a suborchestration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,32 @@ export class FunctionGraphTabState extends FunctionGraphStateBase implements ICu

for (var event of history) {

const subFuncName = event.Name;
const subFuncName = event.name;

switch (event.EventType) {
switch (event.eventType) {
case 'SubOrchestrationInstanceCreated':

if (!!event.SubOrchestrationId && !!event.history) {
if (!!event.subOrchestrationId && !!event.history) {

this.updateMetricsForInstance(metrics, subFuncName, "Running", 0, event.history, cancelToken);
}

break;
case 'SubOrchestrationInstanceCompleted':

if (!!event.SubOrchestrationId && !!event.history) {
if (!!event.subOrchestrationId && !!event.history) {

const durationInMs = new Date(event.Timestamp).getTime() - new Date(event.ScheduledTime).getTime();
const durationInMs = new Date(event.timestamp).getTime() - new Date(event.scheduledTime).getTime();

this.updateMetricsForInstance(metrics, subFuncName, "Completed", durationInMs, event.history, cancelToken);
}

break;
case 'SubOrchestrationInstanceFailed':

if (!!event.SubOrchestrationId && !!event.history) {
if (!!event.subOrchestrationId && !!event.history) {

const durationInMs = new Date(event.Timestamp).getTime() - new Date(event.ScheduledTime).getTime();
const durationInMs = new Date(event.timestamp).getTime() - new Date(event.scheduledTime).getTime();

this.updateMetricsForInstance(metrics, subFuncName, "Failed", durationInMs, event.history, cancelToken);
}
Expand All @@ -147,8 +147,8 @@ export class FunctionGraphTabState extends FunctionGraphStateBase implements ICu

metrics[subFuncName].completed++;

if (metrics[subFuncName].duration < event.DurationInMs) {
metrics[subFuncName].duration = event.DurationInMs;
if (metrics[subFuncName].duration < event.durationInMs) {
metrics[subFuncName].duration = event.durationInMs;
}

break;
Expand All @@ -160,8 +160,8 @@ export class FunctionGraphTabState extends FunctionGraphStateBase implements ICu

metrics[subFuncName].failed++;

if (metrics[subFuncName].duration < event.DurationInMs) {
metrics[subFuncName].duration = event.DurationInMs;
if (metrics[subFuncName].duration < event.durationInMs) {
metrics[subFuncName].duration = event.durationInMs;
}

break;
Expand Down Expand Up @@ -224,22 +224,22 @@ export class FunctionGraphTabState extends FunctionGraphStateBase implements ICu

for (const event of history) {

switch (event.EventType) {
switch (event.eventType) {
case "SubOrchestrationInstanceCompleted":
case "SubOrchestrationInstanceFailed":

promises.push(

this._loadHistory(event.SubOrchestrationId)
.then(subHistory => this.loadSubOrchestrations(event.Name, subHistory as any))
this._loadHistory(event.subOrchestrationId)
.then(subHistory => this.loadSubOrchestrations(event.name, subHistory as any))
.then(subHistory => {

event.history = subHistory;

})
.catch(err => {

console.log(`Failed to load ${event.SubOrchestrationId}. ${err.message}`);
console.log(`Failed to load ${event.subOrchestrationId}. ${err.message}`);
})
);

Expand All @@ -253,7 +253,7 @@ export class FunctionGraphTabState extends FunctionGraphStateBase implements ICu

if (!!this._traversalResult && !!this._traversalResult.functions) {

const func = this._traversalResult.functions[event.Name];
const func = this._traversalResult.functions[event.name];
if (!!func) {

if (!func.isCalledBy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {

const results: LineTextAndMetadata[] = [];

const startedEvent = historyEvents.find(event => event.EventType === 'ExecutionStarted');
const completedEvent = historyEvents.find(event => event.EventType === 'ExecutionCompleted');
const startedEvent = historyEvents.find(event => event.eventType === 'ExecutionStarted');
const completedEvent = historyEvents.find(event => event.eventType === 'ExecutionCompleted');

var needToAddAxisFormat = isParentOrchestration;
var nextLine: string;
Expand All @@ -112,23 +112,23 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {
if (needToAddAxisFormat) {

// Axis format should always appear on top, prior to all other lines - this is why it looks a bit complicated.
const longerThanADay = completedEvent.DurationInMs > 86400000;
const longerThanADay = completedEvent.durationInMs > 86400000;
nextLine = longerThanADay ? 'axisFormat %Y-%m-%d %H:%M \n' : 'axisFormat %H:%M:%S \n';
results.push({ nextLine });
needToAddAxisFormat = false;
}

nextLine = isParentOrchestration ? '' : `section ${orchestrationName}(${this.escapeTitle(orchestrationId)}) \n`;

var lineName = this.formatDuration(completedEvent.DurationInMs);
var lineName = this.formatDuration(completedEvent.durationInMs);
if (!lineName) {
lineName = this.formatLineName(orchestrationName, 0);
}

nextLine += `${lineName}: ${isParentOrchestration ? '' : 'active,'} ${this.formatDateTime(startedEvent.Timestamp)}, ${completedEvent.DurationInMs}ms \n`;
nextLine += `${lineName}: ${isParentOrchestration ? '' : 'active,'} ${this.formatDateTime(startedEvent.timestamp)}, ${completedEvent.durationInMs}ms \n`;
results.push({ nextLine, functionName: orchestrationName, instanceId: orchestrationId });

orchDuration = completedEvent.DurationInMs;
orchDuration = completedEvent.durationInMs;
}

if (needToAddAxisFormat) {
Expand All @@ -143,29 +143,29 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {
let numOfAggregatedEvents = 0;

// If too many events, then trying to aggregate
if (historyEvents.length > MaxEventsBeforeStartAggregating && EventTypesToBeAggregated.includes(event.EventType)) {
if (historyEvents.length > MaxEventsBeforeStartAggregating && EventTypesToBeAggregated.includes(event.eventType)) {

const scheduledTimeInMs = Date.parse(event.ScheduledTime);
let maxDurationInMs = event.DurationInMs;
const scheduledTimeInMs = Date.parse(event.scheduledTime);
let maxDurationInMs = event.durationInMs;

let j = i + 1;
while (j < historyEvents.length) {

const nextScheduledTimeInMs = Date.parse(historyEvents[j].ScheduledTime);
const nextScheduledTimeInMs = Date.parse(historyEvents[j].scheduledTime);

if (
(MaxAggregatedEvents <= j - i)
||
(historyEvents[j].EventType !== event.EventType)
(historyEvents[j].eventType !== event.eventType)
||
(historyEvents[j].Name !== event.Name)
(historyEvents[j].name !== event.name)
||
(TimestampIntervalInMsForAggregating < nextScheduledTimeInMs - scheduledTimeInMs)
) {
break;
}

const nextDurationInMs = (nextScheduledTimeInMs - scheduledTimeInMs) + historyEvents[j].DurationInMs;
const nextDurationInMs = (nextScheduledTimeInMs - scheduledTimeInMs) + historyEvents[j].durationInMs;
if (nextDurationInMs > maxDurationInMs) {
maxDurationInMs = nextDurationInMs;
}
Expand All @@ -176,27 +176,27 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {
if (j > i + 1) {

numOfAggregatedEvents = j - i;
event.DurationInMs = maxDurationInMs;
event.durationInMs = maxDurationInMs;
i = j - 1;
}
}

var eventTimestamp = event.ScheduledTime;
var eventTimestamp = event.scheduledTime;

// Sometimes activity timestamp might appear to be earlier than orchestration start (due to machine time difference, I assume),
// and that breaks the diagram
if (!!startedEvent && (Date.parse(eventTimestamp) < Date.parse(startedEvent.Timestamp))) {
eventTimestamp = startedEvent.Timestamp;
if (!!startedEvent && (Date.parse(eventTimestamp) < Date.parse(startedEvent.timestamp))) {
eventTimestamp = startedEvent.timestamp;
}

switch (event.EventType) {
switch (event.eventType) {
case 'SubOrchestrationInstanceCompleted':
case 'SubOrchestrationInstanceFailed':

if (!!event.SubOrchestrationId && !!event.history) {
if (!!event.subOrchestrationId && !!event.history) {

const subOrchestrationId = event.SubOrchestrationId;
const subOrchestrationName = event.Name;
const subOrchestrationId = event.subOrchestrationId;
const subOrchestrationName = event.name;

results.push(...this.renderOrchestration(subOrchestrationId, subOrchestrationName, event.history, false));

Expand All @@ -207,31 +207,31 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {
break;
case 'TaskCompleted':

nextLine = `${this.formatLineName(event.Name, numOfAggregatedEvents)} ${this.formatDuration(event.DurationInMs)}: done, ${this.formatDateTime(eventTimestamp)}, ${event.DurationInMs}ms \n`;
nextLine = `${this.formatLineName(event.name, numOfAggregatedEvents)} ${this.formatDuration(event.durationInMs)}: done, ${this.formatDateTime(eventTimestamp)}, ${event.durationInMs}ms \n`;
results.push({
nextLine,
functionName: event.Name,
functionName: event.name,
parentInstanceId: orchestrationId,
duration: event.DurationInMs,
widthPercentage: orchDuration ? event.DurationInMs / orchDuration : 0
duration: event.durationInMs,
widthPercentage: orchDuration ? event.durationInMs / orchDuration : 0
});

break;
case 'TaskFailed':

nextLine = `${this.formatLineName(event.Name, numOfAggregatedEvents)} ${this.formatDuration(event.DurationInMs)}: crit, ${this.formatDateTime(eventTimestamp)}, ${event.DurationInMs}ms \n`;
nextLine = `${this.formatLineName(event.name, numOfAggregatedEvents)} ${this.formatDuration(event.durationInMs)}: crit, ${this.formatDateTime(eventTimestamp)}, ${event.durationInMs}ms \n`;
results.push({
nextLine,
functionName: event.Name,
functionName: event.name,
parentInstanceId: orchestrationId,
duration: event.DurationInMs,
widthPercentage: orchDuration ? event.DurationInMs / orchDuration : 0
duration: event.durationInMs,
widthPercentage: orchDuration ? event.durationInMs / orchDuration : 0
});

break;
case 'TimerFired':

nextLine = `[TimerFired]: milestone, ${this.formatDateTime(event.Timestamp)}, 0s \n`;
nextLine = `[TimerFired]: milestone, ${this.formatDateTime(event.timestamp)}, 0s \n`;
results.push({
nextLine,
functionName: orchestrationName,
Expand All @@ -252,13 +252,13 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {

for (const event of history) {

switch (event.EventType) {
switch (event.eventType) {
case "SubOrchestrationInstanceCompleted":
case "SubOrchestrationInstanceFailed":

promises.push(

this._loadHistory(event.SubOrchestrationId)
this._loadHistory(event.subOrchestrationId)
.then(subHistory => this.loadSubOrchestrations(subHistory as any))
.then(subHistory => {

Expand All @@ -267,7 +267,7 @@ export class GanttDiagramTabState extends MermaidDiagramTabState {
})
.catch(err => {

console.log(`Failed to load ${event.SubOrchestrationId}. ${err.message}`);
console.log(`Failed to load ${event.subOrchestrationId}. ${err.message}`);
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class OrchestrationDetailsState extends ErrorMessageState {

if (this._history.length > 0) {

this._timeFrom = moment(this._history[0].Timestamp);
this._timeFrom = moment(this._history[0].timestamp);

} else {

Expand Down
Loading