@osfactory/otel-hook 0.7.0 → 0.8.0
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/README.md +85 -2
- package/dist/cli.js +59 -50
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +48 -1
- package/dist/config.js +36 -2
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +61 -50
- package/dist/index.js.map +1 -1
- package/dist/integration.d.ts +1 -1
- package/dist/integration.js +41 -48
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +3 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{otlp-log-sink-eUEjaLhk.d.ts → otlp-log-sink-zuHojHSP.d.ts} +16 -0
- package/dist/telemetry.d.ts +2 -2
- package/dist/telemetry.js +34 -39
- package/dist/telemetry.js.map +1 -1
- package/package.json +9 -9
package/dist/config.d.ts
CHANGED
|
@@ -200,10 +200,21 @@ type EnvironmentConfigResult = {
|
|
|
200
200
|
* `OTLP_HEADER_VARIABLES`: only the header *names* they set enter the
|
|
201
201
|
* configuration patch, and their values are resolved by `resolveOtlpHeaders`
|
|
202
202
|
* for the sinks alone.
|
|
203
|
+
*
|
|
204
|
+
* `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` is read too, but listed in
|
|
205
|
+
* `OTLP_ENDPOINT_VARIABLES` with its two siblings: an endpoint is not identity,
|
|
206
|
+
* yet a `TRACE` name in this list would defeat the guard that keeps identity
|
|
207
|
+
* variables out of it.
|
|
203
208
|
*/
|
|
204
209
|
declare const ENVIRONMENT_VARIABLES: Readonly<{
|
|
205
210
|
exporterEnabled: "OTEL_HOOK_ENABLED";
|
|
211
|
+
/** Full traces URL; otel-hook's own variable, above the standard ones. */
|
|
206
212
|
exporterEndpoint: "OTEL_HOOK_EXPORTER_ENDPOINT";
|
|
213
|
+
/**
|
|
214
|
+
* Standard base URL: `/v1/traces` and `/v1/logs` are appended per signal. A
|
|
215
|
+
* value already ending in `/v1/traces` is the legacy full traces URL and is
|
|
216
|
+
* used as-is (see `otlpSignalEndpointFromBase`).
|
|
217
|
+
*/
|
|
207
218
|
otlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT";
|
|
208
219
|
exporterProtocol: "OTEL_HOOK_EXPORTER_PROTOCOL";
|
|
209
220
|
exporterTimeoutMillis: "OTEL_HOOK_EXPORTER_TIMEOUT_MS";
|
|
@@ -314,4 +325,40 @@ declare const unionOtlpHeaderNames: (...lists: readonly (readonly string[])[]) =
|
|
|
314
325
|
/** {@link unionOtlpHeaderNames} over the names of header maps. */
|
|
315
326
|
declare const describeOtlpHeaderNames: (...sources: readonly Readonly<Record<string, string>>[]) => readonly string[];
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
/**
|
|
329
|
+
* OTLP/HTTP endpoint URLs per signal, as the OpenTelemetry exporter
|
|
330
|
+
* specification defines them.
|
|
331
|
+
*
|
|
332
|
+
* - `OTEL_EXPORTER_OTLP_ENDPOINT` is a **base** URL: the signal path
|
|
333
|
+
* (`/v1/traces`, `/v1/logs`) is appended to it.
|
|
334
|
+
* - `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` / `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`
|
|
335
|
+
* are full URLs, used as they are.
|
|
336
|
+
*
|
|
337
|
+
* One compatibility rule: earlier releases read `OTEL_EXPORTER_OTLP_ENDPOINT`
|
|
338
|
+
* as the full traces URL. A base URL that already ends in `/v1/traces` is
|
|
339
|
+
* therefore taken to be that full URL, not a base to append to, so an existing
|
|
340
|
+
* `…/v1/traces` value keeps posting where it did.
|
|
341
|
+
*/
|
|
342
|
+
/**
|
|
343
|
+
* The standard endpoint variables. `generic` and `logs` also appear in
|
|
344
|
+
* `ENVIRONMENT_VARIABLES`; `traces` does not, because that list is guarded
|
|
345
|
+
* against identity-looking (`TRACE`) names.
|
|
346
|
+
*/
|
|
347
|
+
declare const OTLP_ENDPOINT_VARIABLES: Readonly<{
|
|
348
|
+
generic: "OTEL_EXPORTER_OTLP_ENDPOINT";
|
|
349
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
|
|
350
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
|
|
351
|
+
}>;
|
|
352
|
+
type OtlpSignal = "traces" | "logs";
|
|
353
|
+
/**
|
|
354
|
+
* The URL a signal posts to, given an `OTEL_EXPORTER_OTLP_ENDPOINT` base.
|
|
355
|
+
*
|
|
356
|
+
* Trailing slashes on the base are dropped before the signal path is appended,
|
|
357
|
+
* so `https://host/otlp` and `https://host/otlp/` both give
|
|
358
|
+
* `https://host/otlp/v1/traces`. A base ending in `/v1/traces` (the legacy
|
|
359
|
+
* full-URL form) is used as-is for traces and has that suffix swapped for
|
|
360
|
+
* `/v1/logs` for logs.
|
|
361
|
+
*/
|
|
362
|
+
declare const otlpSignalEndpointFromBase: (base: string, signal: OtlpSignal) => string;
|
|
363
|
+
|
|
364
|
+
export { CONFIG_SOURCE_PRECEDENCE, type ConfigLayer, type ConfigProvenance, type ConfigResolution, type ConfigSource, EMPTY_RESOURCE_ATTRIBUTES, ENVIRONMENT_VARIABLES, type EnvironmentConfigResult, type EnvironmentRecord, MAX_OTLP_HEADERS, MAX_RESOURCE_ATTRIBUTES, MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH, MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH, OTLP_ENDPOINT_VARIABLES, OTLP_HEADER_VARIABLES, OtelHookConfig, OtelHookConfigPatch, type OtlpSignal, type ParsedOtlpHeaders, type ParsedResourceAttributes, RESERVED_RESOURCE_ATTRIBUTE_KEYS, RESOURCE_ATTRIBUTE_KEY_PATTERN, RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL, type ResolvedOtlpHeaders, type ResourceAttributeKeyRejection, type ResourceAttributeValue, type ResourceAttributes, checkResourceAttributeKey, configSourceSchema, describeOtlpHeaderNames, describeResolvedConfig, describeResourceAttributeNames, isReservedResourceAttributeKey, isSecretResourceAttributeKey, mergeOtlpHeaders, otlpSignalEndpointFromBase, parseEnvironmentConfig, parseOtlpHeadersValue, parseResourceAttributesValue, resolveConfig, resolveOtlpHeaders, resourceAttributeValueSchema, resourceAttributesSchema, sanitizeResourceAttributes, unionOtlpHeaderNames };
|
package/dist/config.js
CHANGED
|
@@ -761,6 +761,29 @@ var describeResolvedConfig = (config) => {
|
|
|
761
761
|
};
|
|
762
762
|
};
|
|
763
763
|
|
|
764
|
+
// src/config/otlp-endpoint.ts
|
|
765
|
+
var OTLP_ENDPOINT_VARIABLES = Object.freeze({
|
|
766
|
+
generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
767
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
768
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
|
769
|
+
});
|
|
770
|
+
var OTLP_TRACES_PATH = "/v1/traces";
|
|
771
|
+
var OTLP_LOGS_PATH = "/v1/logs";
|
|
772
|
+
var withoutTrailingSlashes = (value) => {
|
|
773
|
+
let end = value.length;
|
|
774
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
775
|
+
end -= 1;
|
|
776
|
+
}
|
|
777
|
+
return value.slice(0, end);
|
|
778
|
+
};
|
|
779
|
+
var otlpSignalEndpointFromBase = (base, signal) => {
|
|
780
|
+
const trimmed = withoutTrailingSlashes(base);
|
|
781
|
+
if (trimmed.endsWith(OTLP_TRACES_PATH)) {
|
|
782
|
+
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
|
|
783
|
+
}
|
|
784
|
+
return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
|
|
785
|
+
};
|
|
786
|
+
|
|
764
787
|
// src/config/otlp-headers.ts
|
|
765
788
|
var MAX_OTLP_HEADERS = 32;
|
|
766
789
|
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
@@ -885,7 +908,13 @@ var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.ma
|
|
|
885
908
|
// src/config/environment.ts
|
|
886
909
|
var ENVIRONMENT_VARIABLES = Object.freeze({
|
|
887
910
|
exporterEnabled: "OTEL_HOOK_ENABLED",
|
|
911
|
+
/** Full traces URL; otel-hook's own variable, above the standard ones. */
|
|
888
912
|
exporterEndpoint: "OTEL_HOOK_EXPORTER_ENDPOINT",
|
|
913
|
+
/**
|
|
914
|
+
* Standard base URL: `/v1/traces` and `/v1/logs` are appended per signal. A
|
|
915
|
+
* value already ending in `/v1/traces` is the legacy full traces URL and is
|
|
916
|
+
* used as-is (see `otlpSignalEndpointFromBase`).
|
|
917
|
+
*/
|
|
889
918
|
otlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
890
919
|
exporterProtocol: "OTEL_HOOK_EXPORTER_PROTOCOL",
|
|
891
920
|
exporterTimeoutMillis: "OTEL_HOOK_EXPORTER_TIMEOUT_MS",
|
|
@@ -959,7 +988,10 @@ var parseEnvironmentConfig = (env) => {
|
|
|
959
988
|
return trimmed === "" ? void 0 : trimmed;
|
|
960
989
|
};
|
|
961
990
|
const exporterEnabled = readBoolean(ENVIRONMENT_VARIABLES.exporterEnabled);
|
|
962
|
-
const
|
|
991
|
+
const hookEndpoint = readString(ENVIRONMENT_VARIABLES.exporterEndpoint);
|
|
992
|
+
const otlpTracesEndpoint = readString(OTLP_ENDPOINT_VARIABLES.traces);
|
|
993
|
+
const otlpBaseEndpoint = readString(ENVIRONMENT_VARIABLES.otlpEndpoint);
|
|
994
|
+
const endpoint = hookEndpoint ?? otlpTracesEndpoint ?? (otlpBaseEndpoint === void 0 ? void 0 : otlpSignalEndpointFromBase(otlpBaseEndpoint, "traces"));
|
|
963
995
|
const timeoutMillis = readInteger(ENVIRONMENT_VARIABLES.exporterTimeoutMillis);
|
|
964
996
|
const resourceRaw = readString(ENVIRONMENT_VARIABLES.resourceAttributes);
|
|
965
997
|
const resource = resourceRaw === void 0 ? void 0 : parseResourceAttributesValue(resourceRaw);
|
|
@@ -1045,7 +1077,7 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1045
1077
|
const maxEventsPerInvocation = readInteger(ENVIRONMENT_VARIABLES.maxEventsPerInvocation);
|
|
1046
1078
|
const logsEnabled = readBoolean(ENVIRONMENT_VARIABLES.logsEnabled);
|
|
1047
1079
|
const logsIncludeContent = readBoolean(ENVIRONMENT_VARIABLES.logsIncludeContent);
|
|
1048
|
-
const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint);
|
|
1080
|
+
const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint) ?? (hookEndpoint === void 0 && otlpTracesEndpoint !== void 0 && otlpBaseEndpoint !== void 0 ? otlpSignalEndpointFromBase(otlpBaseEndpoint, "logs") : void 0);
|
|
1049
1081
|
const logs = {
|
|
1050
1082
|
...logsEnabled === void 0 ? {} : { enabled: logsEnabled },
|
|
1051
1083
|
...logsEndpoint === void 0 ? {} : { endpoint: logsEndpoint },
|
|
@@ -1102,6 +1134,7 @@ export {
|
|
|
1102
1134
|
MAX_RESOURCE_ATTRIBUTES,
|
|
1103
1135
|
MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
|
|
1104
1136
|
MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH,
|
|
1137
|
+
OTLP_ENDPOINT_VARIABLES,
|
|
1105
1138
|
OTLP_HEADER_VARIABLES,
|
|
1106
1139
|
RESERVED_RESOURCE_ATTRIBUTE_KEYS,
|
|
1107
1140
|
RESOURCE_ATTRIBUTE_KEY_PATTERN,
|
|
@@ -1121,6 +1154,7 @@ export {
|
|
|
1121
1154
|
mergeOtlpHeaders,
|
|
1122
1155
|
otelHookConfigPatchSchema,
|
|
1123
1156
|
otelHookConfigSchema,
|
|
1157
|
+
otlpSignalEndpointFromBase,
|
|
1124
1158
|
parseEnvironmentConfig,
|
|
1125
1159
|
parseOtlpHeadersValue,
|
|
1126
1160
|
parseResourceAttributesValue,
|