@forklaunch/core 0.15.6 → 0.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/http/index.d.mts +2 -5
- package/lib/http/index.d.ts +2 -5
- package/lib/http/index.js +33 -28
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +32 -28
- package/lib/http/index.mjs.map +1 -1
- package/package.json +5 -5
package/lib/http/index.d.mts
CHANGED
|
@@ -60,9 +60,7 @@ interface TelemetryOptions {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDefinition> {
|
|
63
|
-
private
|
|
64
|
-
private readonly serviceName;
|
|
65
|
-
private readonly metrics;
|
|
63
|
+
#private;
|
|
66
64
|
constructor(serviceName: string, level?: LevelWithSilentOrString, metricDefinitions?: AppliedMetricsDefinition);
|
|
67
65
|
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
|
68
66
|
info: LogFn;
|
|
@@ -2082,7 +2080,6 @@ declare function meta(meta: Record<string, unknown>): LoggerMeta;
|
|
|
2082
2080
|
declare class PinoLogger {
|
|
2083
2081
|
private pinoLogger;
|
|
2084
2082
|
private meta;
|
|
2085
|
-
private prettyPrinter;
|
|
2086
2083
|
constructor(level: LevelWithSilentOrString, meta?: AnyValueMap);
|
|
2087
2084
|
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
|
2088
2085
|
error: LogFn;
|
|
@@ -2097,4 +2094,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
|
2097
2094
|
|
|
2098
2095
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
|
|
2099
2096
|
|
|
2100
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapHandlerToLiveSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResolvedSessionObject, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
|
|
2097
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapHandlerToLiveSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, PinoLogger, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResolvedSessionObject, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
|
package/lib/http/index.d.ts
CHANGED
|
@@ -60,9 +60,7 @@ interface TelemetryOptions {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDefinition> {
|
|
63
|
-
private
|
|
64
|
-
private readonly serviceName;
|
|
65
|
-
private readonly metrics;
|
|
63
|
+
#private;
|
|
66
64
|
constructor(serviceName: string, level?: LevelWithSilentOrString, metricDefinitions?: AppliedMetricsDefinition);
|
|
67
65
|
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
|
68
66
|
info: LogFn;
|
|
@@ -2082,7 +2080,6 @@ declare function meta(meta: Record<string, unknown>): LoggerMeta;
|
|
|
2082
2080
|
declare class PinoLogger {
|
|
2083
2081
|
private pinoLogger;
|
|
2084
2082
|
private meta;
|
|
2085
|
-
private prettyPrinter;
|
|
2086
2083
|
constructor(level: LevelWithSilentOrString, meta?: AnyValueMap);
|
|
2087
2084
|
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
|
2088
2085
|
error: LogFn;
|
|
@@ -2097,4 +2094,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
|
2097
2094
|
|
|
2098
2095
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
|
|
2099
2096
|
|
|
2100
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapHandlerToLiveSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResolvedSessionObject, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
|
|
2097
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapHandlerToLiveSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, PinoLogger, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResolvedSessionObject, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
|
package/lib/http/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(http_exports, {
|
|
|
41
41
|
HTTPStatuses: () => HTTPStatuses,
|
|
42
42
|
OPENAPI_DEFAULT_VERSION: () => OPENAPI_DEFAULT_VERSION,
|
|
43
43
|
OpenTelemetryCollector: () => OpenTelemetryCollector,
|
|
44
|
+
PinoLogger: () => PinoLogger,
|
|
44
45
|
createHmacToken: () => createHmacToken,
|
|
45
46
|
delete_: () => delete_,
|
|
46
47
|
discriminateAuthMethod: () => discriminateAuthMethod,
|
|
@@ -620,7 +621,6 @@ var import_common5 = require("@forklaunch/common");
|
|
|
620
621
|
var import_api2 = require("@opentelemetry/api");
|
|
621
622
|
var import_api_logs = require("@opentelemetry/api-logs");
|
|
622
623
|
var import_pino = __toESM(require("pino"));
|
|
623
|
-
var PinoPretty = __toESM(require("pino-pretty"));
|
|
624
624
|
|
|
625
625
|
// src/http/guards/isLoggerMeta.ts
|
|
626
626
|
function isLoggerMeta(arg) {
|
|
@@ -658,6 +658,15 @@ function normalizeLogArgs(args) {
|
|
|
658
658
|
for (const arg of args) {
|
|
659
659
|
if (typeof arg === "string" && message === "") {
|
|
660
660
|
message = arg;
|
|
661
|
+
} else if (arg instanceof Error) {
|
|
662
|
+
metaObjects.push({
|
|
663
|
+
err: {
|
|
664
|
+
message: arg.message,
|
|
665
|
+
name: arg.name,
|
|
666
|
+
stack: arg.stack,
|
|
667
|
+
...Object.keys(arg).length > 0 ? arg : {}
|
|
668
|
+
}
|
|
669
|
+
});
|
|
661
670
|
} else if (arg && typeof arg === "object" && !Array.isArray(arg)) {
|
|
662
671
|
metaObjects.push(arg);
|
|
663
672
|
} else {
|
|
@@ -690,13 +699,6 @@ ${JSON.stringify(metadata, null, 2)}` : ""}`;
|
|
|
690
699
|
var PinoLogger = class _PinoLogger {
|
|
691
700
|
pinoLogger;
|
|
692
701
|
meta;
|
|
693
|
-
prettyPrinter = PinoPretty.prettyFactory({
|
|
694
|
-
colorize: true,
|
|
695
|
-
// Add error handling options
|
|
696
|
-
errorLikeObjectKeys: ["err", "error"],
|
|
697
|
-
ignore: "pid,hostname",
|
|
698
|
-
translateTime: "SYS:standard"
|
|
699
|
-
});
|
|
700
702
|
constructor(level, meta2 = {}) {
|
|
701
703
|
this.pinoLogger = (0, import_pino.default)({
|
|
702
704
|
level: level || "info",
|
|
@@ -727,6 +729,8 @@ var PinoLogger = class _PinoLogger {
|
|
|
727
729
|
}
|
|
728
730
|
return true;
|
|
729
731
|
});
|
|
732
|
+
const [errorMetadata] = normalizeLogArgs(filteredArgs);
|
|
733
|
+
Object.assign(meta2, errorMetadata);
|
|
730
734
|
const activeSpan = import_api2.trace.getActiveSpan();
|
|
731
735
|
if (activeSpan) {
|
|
732
736
|
const activeSpanContext = activeSpan.spanContext();
|
|
@@ -779,38 +783,38 @@ function logger(level, meta2 = {}) {
|
|
|
779
783
|
|
|
780
784
|
// src/http/telemetry/openTelemetryCollector.ts
|
|
781
785
|
var OpenTelemetryCollector = class {
|
|
782
|
-
logger;
|
|
783
|
-
serviceName;
|
|
784
|
-
metrics;
|
|
786
|
+
#logger;
|
|
787
|
+
#serviceName;
|
|
788
|
+
#metrics;
|
|
785
789
|
// scoped creation and create this in middleware when api execute. Also add correlation id
|
|
786
790
|
constructor(serviceName, level, metricDefinitions) {
|
|
787
|
-
this
|
|
788
|
-
this
|
|
789
|
-
this
|
|
791
|
+
this.#serviceName = serviceName;
|
|
792
|
+
this.#logger = logger(level || "info");
|
|
793
|
+
this.#metrics = {};
|
|
790
794
|
for (const [metricId, metricType] of Object.entries(
|
|
791
795
|
metricDefinitions ?? {}
|
|
792
796
|
)) {
|
|
793
797
|
switch (metricType) {
|
|
794
798
|
case "counter":
|
|
795
|
-
this
|
|
799
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createCounter(metricId);
|
|
796
800
|
break;
|
|
797
801
|
case "gauge":
|
|
798
|
-
this
|
|
802
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createGauge(metricId);
|
|
799
803
|
break;
|
|
800
804
|
case "histogram":
|
|
801
|
-
this
|
|
805
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createHistogram(metricId);
|
|
802
806
|
break;
|
|
803
807
|
case "upDownCounter":
|
|
804
|
-
this
|
|
808
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createUpDownCounter(metricId);
|
|
805
809
|
break;
|
|
806
810
|
case "observableCounter":
|
|
807
|
-
this
|
|
811
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createObservableCounter(metricId);
|
|
808
812
|
break;
|
|
809
813
|
case "observableGauge":
|
|
810
|
-
this
|
|
814
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createObservableGauge(metricId);
|
|
811
815
|
break;
|
|
812
816
|
case "observableUpDownCounter":
|
|
813
|
-
this
|
|
817
|
+
this.#metrics[metricId] = import_api3.metrics.getMeter(this.#serviceName).createObservableUpDownCounter(metricId);
|
|
814
818
|
break;
|
|
815
819
|
}
|
|
816
820
|
}
|
|
@@ -820,25 +824,25 @@ var OpenTelemetryCollector = class {
|
|
|
820
824
|
);
|
|
821
825
|
}
|
|
822
826
|
log(level, ...args) {
|
|
823
|
-
this
|
|
827
|
+
this.#logger.log(level, ...args);
|
|
824
828
|
}
|
|
825
829
|
info = (msg, ...args) => {
|
|
826
|
-
this
|
|
830
|
+
this.#logger.log("info", msg, ...args);
|
|
827
831
|
};
|
|
828
832
|
error = (msg, ...args) => {
|
|
829
|
-
this
|
|
833
|
+
this.#logger.log("error", msg, ...args);
|
|
830
834
|
};
|
|
831
835
|
warn = (msg, ...args) => {
|
|
832
|
-
this
|
|
836
|
+
this.#logger.log("warn", msg, ...args);
|
|
833
837
|
};
|
|
834
838
|
debug = (msg, ...args) => {
|
|
835
|
-
this
|
|
839
|
+
this.#logger.log("debug", msg, ...args);
|
|
836
840
|
};
|
|
837
841
|
trace = (msg, ...args) => {
|
|
838
|
-
this
|
|
842
|
+
this.#logger.log("trace", msg, ...args);
|
|
839
843
|
};
|
|
840
844
|
getMetric(metricId) {
|
|
841
|
-
return this
|
|
845
|
+
return this.#metrics[metricId];
|
|
842
846
|
}
|
|
843
847
|
};
|
|
844
848
|
import_dotenv.default.config({ path: (0, import_common6.getEnvVar)("DOTENV_FILE_PATH") });
|
|
@@ -4013,6 +4017,7 @@ function metricsDefinitions(metrics2) {
|
|
|
4013
4017
|
HTTPStatuses,
|
|
4014
4018
|
OPENAPI_DEFAULT_VERSION,
|
|
4015
4019
|
OpenTelemetryCollector,
|
|
4020
|
+
PinoLogger,
|
|
4016
4021
|
createHmacToken,
|
|
4017
4022
|
delete_,
|
|
4018
4023
|
discriminateAuthMethod,
|