mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-24 00:12:06 +00:00
add header setter
This commit is contained in:
parent
2b2f9a74b6
commit
d8d5556f1a
@ -10,6 +10,7 @@ enum IconProp {
|
||||
Settings = 'Settings',
|
||||
Criteria = 'Criteria',
|
||||
Notification = 'Notification',
|
||||
CursorArrowRays = 'CursorArrowRays',
|
||||
Cube = 'Cube',
|
||||
Squares = 'Squares',
|
||||
RectangleStack = 'RectangleStack',
|
||||
|
@ -8,6 +8,7 @@ export interface ComponentProps {
|
||||
icon: IconProp | undefined;
|
||||
footer?: ReactElement | undefined;
|
||||
id: string;
|
||||
iconClassName?: string;
|
||||
}
|
||||
|
||||
const EmptyState: FunctionComponent<ComponentProps> = (
|
||||
@ -20,7 +21,7 @@ const EmptyState: FunctionComponent<ComponentProps> = (
|
||||
{props.icon && (
|
||||
<Icon
|
||||
icon={props.icon}
|
||||
className="mx-auto h-12 w-12 text-gray-400"
|
||||
className={props.iconClassName || `mx-auto h-12 w-12 text-gray-400`}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
@ -162,6 +162,10 @@ const Icon: FunctionComponent<ComponentProps> = ({
|
||||
d="M6 6.878V6a2.25 2.25 0 012.25-2.25h7.5A2.25 2.25 0 0118 6v.878m-12 0c.235-.083.487-.128.75-.128h10.5c.263 0 .515.045.75.128m-12 0A2.25 2.25 0 004.5 9v.878m13.5-3A2.25 2.25 0 0119.5 9v.878m0 0a2.246 2.246 0 00-.75-.128H5.25c-.263 0-.515.045-.75.128m15 0A2.25 2.25 0 0121 12v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6c0-.98.626-1.813 1.5-2.122"
|
||||
/>
|
||||
);
|
||||
} else if (icon === IconProp.CursorArrowRays) {
|
||||
return getSvgWrapper(
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M15.042 21.672L13.684 16.6m0 0l-2.51 2.225.569-9.47 5.227 7.917-3.286-.672zM12 2.25V4.5m5.834.166l-1.591 1.591M20.25 10.5H18M7.757 14.743l-1.59 1.59M6 10.5H3.75m4.007-4.243l-1.59-1.59" />
|
||||
);
|
||||
} else if (icon === IconProp.SquareStack) {
|
||||
return getSvgWrapper(
|
||||
<path
|
||||
|
@ -129,7 +129,7 @@ const DashboardNavbar: FunctionComponent<ComponentProps> = (
|
||||
),
|
||||
}}
|
||||
>
|
||||
{/* <NavBarMenuItem
|
||||
<NavBarMenuItem
|
||||
title="Telemetry"
|
||||
description="Logs, Traces, Metrics and more."
|
||||
route={RouteUtil.populateRouteParams(
|
||||
@ -139,7 +139,7 @@ const DashboardNavbar: FunctionComponent<ComponentProps> = (
|
||||
onClick={() => {
|
||||
forceHideMoreMenu();
|
||||
}}
|
||||
/> */}
|
||||
/>
|
||||
|
||||
<NavBarMenuItem
|
||||
title="On-Call Duty"
|
||||
|
@ -8,6 +8,8 @@ import SideMenu from '../SideMenu';
|
||||
import Navigation from 'CommonUI/src/Utils/Navigation';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import Service from 'Model/Models/Service';
|
||||
import EmptyState from 'CommonUI/src/Components/EmptyState/EmptyState';
|
||||
import IconProp from 'Common/Types/Icon/IconProp';
|
||||
|
||||
const ServiceDelete: FunctionComponent<PageComponentProps> = (
|
||||
_props: PageComponentProps
|
||||
@ -61,7 +63,7 @@ const ServiceDelete: FunctionComponent<PageComponentProps> = (
|
||||
]}
|
||||
sideMenu={<SideMenu modelId={modelId} />}
|
||||
>
|
||||
<div>Traces</div>
|
||||
<EmptyState id="coming-soon" icon={IconProp.CursorArrowRays} title="Coming soon!" description="We will be launching this feature very soon. Stay Tuned!" />
|
||||
</ModelPage>
|
||||
);
|
||||
};
|
||||
|
@ -56,6 +56,8 @@ builder.Services.AddOpenTelemetry()
|
||||
opt.Endpoint = new Uri(endpoint);
|
||||
// Set headers in OTLP exporter
|
||||
opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
|
||||
|
||||
}
|
||||
|
||||
System.Console.WriteLine($"OTLP Exporter is using {opt.Protocol} protocol and endpoint {opt.Endpoint}");
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -16,3 +16,7 @@
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
|
@ -22,9 +22,9 @@ import LogService from 'CommonServer/Services/LogService';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import { JSONArray, JSONObject } from 'Common/Types/JSON';
|
||||
import OTelIngestService from '../Service/OTelIngest';
|
||||
import GlobalCache from 'CommonServer/Infrastructure/GlobalCache';
|
||||
import ServiceService from 'CommonServer/Services/ServiceService';
|
||||
import Service from 'Model/Models/Service';
|
||||
// import GlobalCache from 'CommonServer/Infrastructure/GlobalCache';
|
||||
// import ServiceService from 'CommonServer/Services/ServiceService';
|
||||
// import Service from 'Model/Models/Service';
|
||||
|
||||
// Load proto file for OTel
|
||||
|
||||
@ -72,63 +72,63 @@ router.use(
|
||||
|
||||
// check header.
|
||||
|
||||
if (!req.headers['oneuptime-service-token']) {
|
||||
throw new BadRequestException(
|
||||
'Missing header: oneuptime-service-token'
|
||||
);
|
||||
}
|
||||
// if (!req.headers['oneuptime-service-token']) {
|
||||
// throw new BadRequestException(
|
||||
// 'Missing header: oneuptime-service-token'
|
||||
// );
|
||||
// }
|
||||
|
||||
const cachedServiceId: string | null = await GlobalCache.getString(
|
||||
'service-token',
|
||||
req.headers['oneuptime-service-token'] as string
|
||||
);
|
||||
const serviceProjectId: string | null = await GlobalCache.getString(
|
||||
'service-project-id',
|
||||
req.headers['oneuptime-service-token'] as string
|
||||
);
|
||||
// const cachedServiceId: string | null = await GlobalCache.getString(
|
||||
// 'service-token',
|
||||
// req.headers['oneuptime-service-token'] as string
|
||||
// );
|
||||
// const serviceProjectId: string | null = await GlobalCache.getString(
|
||||
// 'service-project-id',
|
||||
// req.headers['oneuptime-service-token'] as string
|
||||
// );
|
||||
|
||||
if (!cachedServiceId || !serviceProjectId) {
|
||||
// load from the database and set the cache.
|
||||
const service: Service | null = await ServiceService.findOneBy({
|
||||
query: {
|
||||
serviceToken: new ObjectID(
|
||||
req.headers['oneuptime-service-token'] as string
|
||||
),
|
||||
},
|
||||
select: {
|
||||
_id: true,
|
||||
projectId: true,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
// if (!cachedServiceId || !serviceProjectId) {
|
||||
// // load from the database and set the cache.
|
||||
// const service: Service | null = await ServiceService.findOneBy({
|
||||
// query: {
|
||||
// serviceToken: new ObjectID(
|
||||
// req.headers['oneuptime-service-token'] as string
|
||||
// ),
|
||||
// },
|
||||
// select: {
|
||||
// _id: true,
|
||||
// projectId: true,
|
||||
// },
|
||||
// props: {
|
||||
// isRoot: true,
|
||||
// },
|
||||
// });
|
||||
|
||||
if (!service) {
|
||||
throw new BadRequestException('Invalid service token');
|
||||
}
|
||||
// if (!service) {
|
||||
// throw new BadRequestException('Invalid service token');
|
||||
// }
|
||||
|
||||
await GlobalCache.setString(
|
||||
'service-token',
|
||||
req.headers['oneuptime-service-token'] as string,
|
||||
service._id?.toString() as string
|
||||
);
|
||||
await GlobalCache.setString(
|
||||
'service-project-id',
|
||||
req.headers['oneuptime-service-token'] as string,
|
||||
service.projectId?.toString() as string
|
||||
);
|
||||
// await GlobalCache.setString(
|
||||
// 'service-token',
|
||||
// req.headers['oneuptime-service-token'] as string,
|
||||
// service._id?.toString() as string
|
||||
// );
|
||||
// await GlobalCache.setString(
|
||||
// 'service-project-id',
|
||||
// req.headers['oneuptime-service-token'] as string,
|
||||
// service.projectId?.toString() as string
|
||||
// );
|
||||
|
||||
(req as OtelRequest).serviceId = service.id as ObjectID;
|
||||
(req as OtelRequest).projectId = service.projectId as ObjectID;
|
||||
}
|
||||
// (req as OtelRequest).serviceId = service.id as ObjectID;
|
||||
// (req as OtelRequest).projectId = service.projectId as ObjectID;
|
||||
// }
|
||||
|
||||
(req as OtelRequest).serviceId = ObjectID.fromString(
|
||||
cachedServiceId as string
|
||||
);
|
||||
(req as OtelRequest).projectId = ObjectID.fromString(
|
||||
serviceProjectId as string
|
||||
);
|
||||
// (req as OtelRequest).serviceId = ObjectID.fromString(
|
||||
// cachedServiceId as string
|
||||
// );
|
||||
// (req as OtelRequest).projectId = ObjectID.fromString(
|
||||
// serviceProjectId as string
|
||||
// );
|
||||
|
||||
next();
|
||||
} catch (err) {
|
||||
@ -455,6 +455,9 @@ router.post(
|
||||
next: NextFunction
|
||||
): Promise<void> => {
|
||||
try {
|
||||
|
||||
debugger;
|
||||
|
||||
logger.info('OTel Ingestor API called');
|
||||
|
||||
req.body = req.body.toJSON();
|
||||
|
@ -1,3 +1,10 @@
|
||||
extensions:
|
||||
headers_setter:
|
||||
headers:
|
||||
- action: insert
|
||||
key: oneuptime-service-token
|
||||
from_context: oneuptime-service-token
|
||||
|
||||
processors:
|
||||
|
||||
receivers:
|
||||
@ -5,6 +12,7 @@ receivers:
|
||||
protocols:
|
||||
grpc:
|
||||
http:
|
||||
include_metadata: true
|
||||
|
||||
|
||||
|
||||
@ -14,6 +22,7 @@ exporters:
|
||||
headers: {"Content-Type": "application/json"}
|
||||
|
||||
service:
|
||||
extensions: [ headers_setter ]
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
|
Loading…
Reference in New Issue
Block a user