Skip to content

Open-source status page, incident response and uptime monitoring

chore: add section-otel

Maximilian Kaskea3474e7d29d1
diff --git a/apps/web/src/components/banner/coming-soon-banner.tsx b/apps/web/src/components/banner/coming-soon-banner.tsx
new file mode 100644
index 000000000..7116b0f81
--- /dev/null
+++ b/apps/web/src/components/banner/coming-soon-banner.tsx
@@ -0,0 +1,19 @@
+import { Alert, AlertTitle, AlertDescription } from "@openstatus/ui";
+import { Hourglass } from "lucide-react";
+
+interface Props {
+ description?: string;
+}
+
+export function ComingSoonBanner({ description }: Props) {
+ return (
+ <Alert>
+ <Hourglass className="h-4 w-4" />
+ <AlertTitle>Coming Soon</AlertTitle>
+ <AlertDescription>
+ {description ??
+ "This feature is coming soon. Keep an eye on our changelog."}
+ </AlertDescription>
+ </Alert>
+ );
+}
diff --git a/apps/web/src/components/forms/monitor/form.tsx b/apps/web/src/components/forms/monitor/form.tsx
index 4c212344f..bb06b46b7 100644
--- a/apps/web/src/components/forms/monitor/form.tsx
+++ b/apps/web/src/components/forms/monitor/form.tsx
@@ -39,6 +39,7 @@ import { SectionNotifications } from "./section-notifications";
import { SectionRequests } from "./section-requests";
import { SectionScheduling } from "./section-scheduling";
import { SectionStatusPage } from "./section-status-page";
+import { SectionOtel } from "./section-otel";
interface Props {
defaultSection?: string;
@@ -92,7 +93,7 @@ export function MonitorForm({
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
headerAssertions: _assertions.filter((a) => a.type === "header") as any, // TS considers a.type === "status"
textBodyAssertions: _assertions.filter(
- (a) => a.type === "textBody",
+ (a) => a.type === "textBody"
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
) as any, // TS considers a.type === "textBody"
degradedAfter: defaultValues?.degradedAfter,
@@ -106,7 +107,7 @@ export function MonitorForm({
const [pingFailed, setPingFailed] = React.useState(false);
const type = React.useMemo(
() => (defaultValues ? "update" : "create"),
- [defaultValues],
+ [defaultValues]
);
const handleDataUpdateOrInsertion = async (props: InsertMonitor) => {
@@ -153,7 +154,7 @@ export function MonitorForm({
finally: () => {
setPending(false);
},
- },
+ }
);
};
@@ -188,7 +189,7 @@ export function MonitorForm({
body &&
body !== "" &&
headers?.some(
- (h) => h.key === "Content-Type" && h.value === "application/json",
+ (h) => h.key === "Content-Type" && h.value === "application/json"
)
) {
const validJSON = validateJSON(body);
@@ -217,7 +218,7 @@ export function MonitorForm({
...(statusAssertions || []),
...(headerAssertions || []),
...(textBodyAssertions || []),
- ]),
+ ])
);
const data = (await res.json()) as RegionChecker;
@@ -253,7 +254,7 @@ export function MonitorForm({
if (error instanceof Error && error.name === "AbortError") {
return {
error: `Abort error: request takes more then ${formatDuration(
- ABORT_TIMEOUT,
+ ABORT_TIMEOUT
)}.`,
};
}
@@ -312,6 +313,15 @@ export function MonitorForm({
</Badge>
) : null}
</TabsTrigger>
+ <TabsTrigger
+ value="otel"
+ disabled={process.env.NODE_ENV === "production"}
+ >
+ OTel{" "}
+ <Badge variant="secondary" className="ml-1">
+ Soon
+ </Badge>
+ </TabsTrigger>
{defaultValues?.id ? (
<TabsTrigger value="danger">Danger</TabsTrigger>
) : null}
@@ -325,6 +335,9 @@ export function MonitorForm({
<TabsContent value="scheduling">
<SectionScheduling {...{ form, limits, plan }} />
</TabsContent>
+ <TabsContent value="otel">
+ <SectionOtel {...{ form, limits }} />
+ </TabsContent>
<TabsContent value="notifications">
<SectionNotifications {...{ form, notifications }} />
</TabsContent>
diff --git a/apps/web/src/components/forms/monitor/section-otel.tsx b/apps/web/src/components/forms/monitor/section-otel.tsx
new file mode 100644
index 000000000..3489117c3
--- /dev/null
+++ b/apps/web/src/components/forms/monitor/section-otel.tsx
@@ -0,0 +1,121 @@
+"use client";
+
+import { X } from "lucide-react";
+import { useFieldArray, type UseFormReturn } from "react-hook-form";
+
+import type { InsertMonitor } from "@openstatus/db/src/schema";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
+
+import {
+ Button,
+ FormControl,
+ FormDescription,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+ Input,
+} from "@openstatus/ui";
+
+import { SectionHeader } from "../shared/section-header";
+import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
+import { ComingSoonBanner } from "@/components/banner/coming-soon-banner";
+
+interface Props {
+ form: UseFormReturn<InsertMonitor>;
+ limits: Limits;
+}
+
+export function SectionOtel({ form, limits }: Props) {
+ if (process.env.NODE_ENV === "production") {
+ return <ComingSoonBanner />;
+ }
+
+ const { fields, append, prepend, remove, update } = useFieldArray({
+ // name: "otelHeaders",
+ name: "headers",
+ control: form.control,
+ });
+
+ if (!limits.otel) {
+ return <ProFeatureAlert feature="OpenTelemetry" workspacePlan="team" />;
+ }
+
+ return (
+ <div className="grid w-full gap-4">
+ <SectionHeader
+ title="OpenTelemetry"
+ description="Configure your OpenTelemetry endpoint to send metrics to."
+ />
+ <div className="grid sm:grid-cols-2 md:grid-cols-3">
+ <FormField
+ control={form.control}
+ // name="otelEndpoint"
+ name="url"
+ render={({ field }) => (
+ <FormItem className="col-span-full">
+ <FormLabel>Endpoint</FormLabel>
+ <FormControl>
+ <Input
+ type="text"
+ placeholder="https://otel.openstatus.dev/api/v1/metrics"
+ {...field}
+ />
+ </FormControl>
+ <FormDescription>
+ The endpoint to send metrics to.
+ </FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+ <div className="space-y-2 sm:col-span-full">
+ <FormLabel>Request Header</FormLabel>
+ {fields.map((field, index) => (
+ <div key={field.id} className="grid grid-cols-6 gap-4">
+ <FormField
+ control={form.control}
+ name={`headers.${index}.key`}
+ render={({ field }) => (
+ <FormItem className="col-span-2">
+ <FormControl>
+ <Input placeholder="key" {...field} />
+ </FormControl>
+ </FormItem>
+ )}
+ />
+ <div className="col-span-4 flex items-center space-x-2">
+ <FormField
+ control={form.control}
+ name={`headers.${index}.value`}
+ render={({ field }) => (
+ <FormItem className="w-full">
+ <FormControl>
+ <Input placeholder="value" {...field} />
+ </FormControl>
+ </FormItem>
+ )}
+ />
+ <Button
+ size="icon"
+ variant="ghost"
+ type="button"
+ onClick={() => remove(index)}
+ >
+ <X className="h-4 w-4" />
+ </Button>
+ </div>
+ </div>
+ ))}
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => append({ key: "", value: "" })}
+ >
+ Add Custom Header
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/db/src/schema/plan/config.ts b/packages/db/src/schema/plan/config.ts
index b2d3ad9ef..43fce98cb 100644
--- a/packages/db/src/schema/plan/config.ts
+++ b/packages/db/src/schema/plan/config.ts
@@ -28,6 +28,7 @@ export const allPlans: Record<
maintenance: true,
"monitor-values-visibility": true,
screenshots: false,
+ otel: false,
"status-subscribers": false,
"custom-domain": false,
"password-protection": false,
@@ -59,6 +60,7 @@ export const allPlans: Record<
maintenance: true,
"monitor-values-visibility": true,
screenshots: true,
+ otel: false,
"status-subscribers": true,
"custom-domain": true,
"password-protection": true,
@@ -126,6 +128,7 @@ export const allPlans: Record<
maintenance: true,
"monitor-values-visibility": true,
screenshots: true,
+ otel: true,
"status-subscribers": true,
"custom-domain": true,
"password-protection": true,
@@ -193,6 +196,7 @@ export const allPlans: Record<
maintenance: true,
"monitor-values-visibility": true,
screenshots: true,
+ otel: true,
"status-subscribers": true,
"custom-domain": true,
"password-protection": true,
diff --git a/packages/db/src/schema/plan/schema.ts b/packages/db/src/schema/plan/schema.ts
index 389b77b19..70636051d 100644
--- a/packages/db/src/schema/plan/schema.ts
+++ b/packages/db/src/schema/plan/schema.ts
@@ -22,6 +22,7 @@ export const limitsSchema = z.object({
.default(["ams", "gru", "iad", "jnb", "hkg", "syd"]),
"private-locations": z.boolean().default(false),
screenshots: z.boolean().default(false),
+ otel: z.boolean().default(false),
/**
* Status page limits
*/