Skip to content
Merged
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
11 changes: 11 additions & 0 deletions app/client/src/UITelemetry/generateTraces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ export function setAttributesToSpan(
span?.setAttributes(spanAttributes);
}

export const startAndEndSpanForFn = <T>(
spanName: string,
spanAttributes: SpanAttributes = {},
fn: () => T,
) => {
const span = startRootSpan(spanName, spanAttributes);
const res: T = fn();
span.end();
return res;
};

export function wrapFnWithParentTraceContext(parentSpan: Span, fn: () => any) {
const parentContext = trace.setSpan(context.active(), parentSpan);
return context.with(parentContext, fn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { klona } from "klona";

import FormContext from "../FormContext";
import type { FieldType } from "../constants";
import { startAndEndSpanForFn } from "UITelemetry/generateTraces";

export interface UseRegisterFieldValidityProps {
isValid: boolean;
Expand Down Expand Up @@ -34,10 +35,14 @@ function useRegisterFieldValidity({
setTimeout(() => {
try {
isValid
? clearErrors(fieldName)
: setError(fieldName, {
type: fieldType,
message: "Invalid field",
? startAndEndSpanForFn("JSONFormWidget.clearErrors", {}, () => {
clearErrors(fieldName);
})
: startAndEndSpanForFn("JSONFormWidget.setError", {}, () => {
setError(fieldName, {
type: fieldType,
message: "Invalid field",
});
});
} catch (e) {
Sentry.captureException(e);
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/widgets/JSONFormWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
ONSUBMIT_NOT_CONFIGURED_MESSAGE,
} from "../constants/messages";
import { createMessage } from "@appsmith/constants/messages";
import { endSpan, startRootSpan } from "UITelemetry/generateTraces";

const SUBMIT_BUTTON_DEFAULT_STYLES = {
buttonVariant: ButtonVariantTypes.PRIMARY,
Expand Down Expand Up @@ -651,6 +652,7 @@ class JSONFormWidget extends BaseWidget<
schema: Schema,
afterUpdateAction?: ExecuteTriggerPayload,
) => {
const span = startRootSpan("JSONFormWidget.parseAndSaveFieldState");
const fieldState = generateFieldState(schema, metaInternalFieldState);
const action = klona(afterUpdateAction);

Expand All @@ -664,6 +666,7 @@ class JSONFormWidget extends BaseWidget<
actionPayload,
);
}
endSpan(span);
};

onSubmit = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
Expand Down