@osfactory/otel-hook 0.6.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/dist/index.js CHANGED
@@ -1926,10 +1926,160 @@ var describeResolvedConfig = (config) => {
1926
1926
  };
1927
1927
  };
1928
1928
 
1929
+ // src/config/otlp-endpoint.ts
1930
+ var OTLP_ENDPOINT_VARIABLES = Object.freeze({
1931
+ generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
1932
+ traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
1933
+ logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
1934
+ });
1935
+ var OTLP_TRACES_PATH = "/v1/traces";
1936
+ var OTLP_LOGS_PATH = "/v1/logs";
1937
+ var withoutTrailingSlashes = (value) => {
1938
+ let end = value.length;
1939
+ while (end > 0 && value.charCodeAt(end - 1) === 47) {
1940
+ end -= 1;
1941
+ }
1942
+ return value.slice(0, end);
1943
+ };
1944
+ var otlpSignalEndpointFromBase = (base, signal) => {
1945
+ const trimmed = withoutTrailingSlashes(base);
1946
+ if (trimmed.endsWith(OTLP_TRACES_PATH)) {
1947
+ return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
1948
+ }
1949
+ return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
1950
+ };
1951
+
1952
+ // src/config/otlp-headers.ts
1953
+ var MAX_OTLP_HEADERS = 32;
1954
+ var OTLP_HEADER_VARIABLES = Object.freeze({
1955
+ generic: "OTEL_EXPORTER_OTLP_HEADERS",
1956
+ traces: "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
1957
+ logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
1958
+ });
1959
+ var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
1960
+ var isUnsafeHeaderValue = (value) => [...value].some((char) => {
1961
+ const code = char.codePointAt(0) ?? 0;
1962
+ return code < 32 && code !== 9 || code === 127 || code > 255;
1963
+ });
1964
+ var decode = (raw) => {
1965
+ try {
1966
+ return decodeURIComponent(raw);
1967
+ } catch {
1968
+ return void 0;
1969
+ }
1970
+ };
1971
+ var parseOtlpHeadersValue = (raw) => {
1972
+ const headers = {};
1973
+ const warnings = [];
1974
+ let overflowed = false;
1975
+ for (const [index, rawEntry] of raw.split(",").entries()) {
1976
+ const position = String(index + 1);
1977
+ const entry = rawEntry.trim();
1978
+ if (entry === "") {
1979
+ continue;
1980
+ }
1981
+ const equals = entry.indexOf("=");
1982
+ if (equals <= 0) {
1983
+ warnings.push(`entry ${position} is not a key=value pair; ignored`);
1984
+ continue;
1985
+ }
1986
+ const key = decode(entry.slice(0, equals).trim());
1987
+ const value = decode(entry.slice(equals + 1).trim());
1988
+ if (key === void 0 || value === void 0) {
1989
+ warnings.push(`entry ${position} has malformed percent-encoding; ignored`);
1990
+ continue;
1991
+ }
1992
+ const name = key.trim();
1993
+ const trimmedValue = value.trim();
1994
+ if (!HEADER_NAME_PATTERN.test(name)) {
1995
+ warnings.push(`entry ${position} does not name a valid HTTP header; ignored`);
1996
+ continue;
1997
+ }
1998
+ if (trimmedValue === "") {
1999
+ warnings.push(`entry ${position} has an empty value; ignored`);
2000
+ continue;
2001
+ }
2002
+ if (isUnsafeHeaderValue(trimmedValue)) {
2003
+ warnings.push(`entry ${position} has a character not allowed in an HTTP header value; ignored`);
2004
+ continue;
2005
+ }
2006
+ const existing = findHeaderName(headers, name);
2007
+ if (existing === void 0 && Object.keys(headers).length >= MAX_OTLP_HEADERS) {
2008
+ overflowed = true;
2009
+ continue;
2010
+ }
2011
+ if (existing !== void 0) {
2012
+ delete headers[existing];
2013
+ }
2014
+ headers[name] = trimmedValue;
2015
+ }
2016
+ if (overflowed) {
2017
+ warnings.push(`more than ${String(MAX_OTLP_HEADERS)} headers were supplied; the excess was ignored`);
2018
+ }
2019
+ return { headers, warnings };
2020
+ };
2021
+ var findHeaderName = (headers, name) => {
2022
+ const lower = name.toLowerCase();
2023
+ return Object.keys(headers).find((candidate) => candidate.toLowerCase() === lower);
2024
+ };
2025
+ var mergeOtlpHeaders = (...sources) => {
2026
+ const merged = {};
2027
+ for (const source of sources) {
2028
+ for (const [name, value] of Object.entries(source)) {
2029
+ const existing = findHeaderName(merged, name);
2030
+ if (existing !== void 0) {
2031
+ delete merged[existing];
2032
+ }
2033
+ merged[name] = value;
2034
+ }
2035
+ }
2036
+ return merged;
2037
+ };
2038
+ var resolveOtlpHeaders = (env, explicit = {}) => {
2039
+ const warnings = [];
2040
+ const read = (variable) => {
2041
+ const raw = env[variable];
2042
+ if (raw === void 0 || raw.trim() === "") {
2043
+ return {};
2044
+ }
2045
+ const parsed = parseOtlpHeadersValue(raw);
2046
+ for (const detail of parsed.warnings) {
2047
+ warnings.push({ variable, detail });
2048
+ }
2049
+ return parsed.headers;
2050
+ };
2051
+ const generic = read(OTLP_HEADER_VARIABLES.generic);
2052
+ const traces = read(OTLP_HEADER_VARIABLES.traces);
2053
+ const logs = read(OTLP_HEADER_VARIABLES.logs);
2054
+ return {
2055
+ traces: mergeOtlpHeaders(generic, traces, explicit),
2056
+ logs: mergeOtlpHeaders(generic, logs, explicit),
2057
+ warnings
2058
+ };
2059
+ };
2060
+ var unionOtlpHeaderNames = (...lists) => {
2061
+ const names = [];
2062
+ const seen = /* @__PURE__ */ new Set();
2063
+ for (const name of lists.flat()) {
2064
+ if (!seen.has(name.toLowerCase())) {
2065
+ seen.add(name.toLowerCase());
2066
+ names.push(name);
2067
+ }
2068
+ }
2069
+ return names.sort().slice(0, MAX_OTLP_HEADERS);
2070
+ };
2071
+ var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
2072
+
1929
2073
  // src/config/environment.ts
1930
2074
  var ENVIRONMENT_VARIABLES = Object.freeze({
1931
2075
  exporterEnabled: "OTEL_HOOK_ENABLED",
2076
+ /** Full traces URL; otel-hook's own variable, above the standard ones. */
1932
2077
  exporterEndpoint: "OTEL_HOOK_EXPORTER_ENDPOINT",
2078
+ /**
2079
+ * Standard base URL: `/v1/traces` and `/v1/logs` are appended per signal. A
2080
+ * value already ending in `/v1/traces` is the legacy full traces URL and is
2081
+ * used as-is (see `otlpSignalEndpointFromBase`).
2082
+ */
1933
2083
  otlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT",
1934
2084
  exporterProtocol: "OTEL_HOOK_EXPORTER_PROTOCOL",
1935
2085
  exporterTimeoutMillis: "OTEL_HOOK_EXPORTER_TIMEOUT_MS",
@@ -2003,7 +2153,10 @@ var parseEnvironmentConfig = (env) => {
2003
2153
  return trimmed === "" ? void 0 : trimmed;
2004
2154
  };
2005
2155
  const exporterEnabled = readBoolean(ENVIRONMENT_VARIABLES.exporterEnabled);
2006
- const endpoint = readString(ENVIRONMENT_VARIABLES.exporterEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpEndpoint);
2156
+ const hookEndpoint = readString(ENVIRONMENT_VARIABLES.exporterEndpoint);
2157
+ const otlpTracesEndpoint = readString(OTLP_ENDPOINT_VARIABLES.traces);
2158
+ const otlpBaseEndpoint = readString(ENVIRONMENT_VARIABLES.otlpEndpoint);
2159
+ const endpoint = hookEndpoint ?? otlpTracesEndpoint ?? (otlpBaseEndpoint === void 0 ? void 0 : otlpSignalEndpointFromBase(otlpBaseEndpoint, "traces"));
2007
2160
  const timeoutMillis = readInteger(ENVIRONMENT_VARIABLES.exporterTimeoutMillis);
2008
2161
  const resourceRaw = readString(ENVIRONMENT_VARIABLES.resourceAttributes);
2009
2162
  const resource = resourceRaw === void 0 ? void 0 : parseResourceAttributesValue(resourceRaw);
@@ -2089,17 +2242,23 @@ var parseEnvironmentConfig = (env) => {
2089
2242
  const maxEventsPerInvocation = readInteger(ENVIRONMENT_VARIABLES.maxEventsPerInvocation);
2090
2243
  const logsEnabled = readBoolean(ENVIRONMENT_VARIABLES.logsEnabled);
2091
2244
  const logsIncludeContent = readBoolean(ENVIRONMENT_VARIABLES.logsIncludeContent);
2092
- const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint);
2245
+ const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint) ?? (hookEndpoint === void 0 && otlpTracesEndpoint !== void 0 && otlpBaseEndpoint !== void 0 ? otlpSignalEndpointFromBase(otlpBaseEndpoint, "logs") : void 0);
2093
2246
  const logs = {
2094
2247
  ...logsEnabled === void 0 ? {} : { enabled: logsEnabled },
2095
2248
  ...logsEndpoint === void 0 ? {} : { endpoint: logsEndpoint },
2096
2249
  ...logsIncludeContent === void 0 ? {} : { includeContent: logsIncludeContent }
2097
2250
  };
2251
+ const otlpHeaders = resolveOtlpHeaders(env);
2252
+ for (const { variable, detail } of otlpHeaders.warnings) {
2253
+ warn(variable, detail);
2254
+ }
2255
+ const headerNames = describeOtlpHeaderNames(otlpHeaders.traces, otlpHeaders.logs);
2098
2256
  const exporter = {
2099
2257
  ...exporterEnabled === void 0 ? {} : { enabled: exporterEnabled },
2100
2258
  ...endpoint === void 0 ? {} : { endpoint },
2101
2259
  ...protocol === void 0 ? {} : { protocol },
2102
2260
  ...timeoutMillis === void 0 ? {} : { timeoutMillis },
2261
+ ...headerNames.length === 0 ? {} : { headerNames: [...headerNames] },
2103
2262
  ...serviceName === void 0 ? {} : { serviceName },
2104
2263
  ...serviceNamespace === void 0 ? {} : { serviceNamespace },
2105
2264
  ...Object.keys(resourceAttributes).length === 0 ? {} : { resourceAttributes },
@@ -7644,27 +7803,7 @@ var createCallbackDeduplicator = (deps) => {
7644
7803
  // src/telemetry/semconv.ts
7645
7804
  import { createHash as createHash3 } from "crypto";
7646
7805
  import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
7647
-
7648
- // node_modules/@opentelemetry/core/build/esm/common/time.js
7649
- var NANOSECOND_DIGITS = 9;
7650
- var NANOSECOND_DIGITS_IN_MILLIS = 6;
7651
- var MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
7652
- var SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
7653
- function millisToHrTime(epochMillis) {
7654
- const epochSeconds = epochMillis / 1e3;
7655
- const seconds = Math.trunc(epochSeconds);
7656
- const nanos = Math.round(epochMillis % 1e3 * MILLISECONDS_TO_NANOSECONDS);
7657
- return [seconds, nanos];
7658
- }
7659
-
7660
- // node_modules/@opentelemetry/core/build/esm/ExportResult.js
7661
- var ExportResultCode;
7662
- (function(ExportResultCode2) {
7663
- ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
7664
- ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
7665
- })(ExportResultCode || (ExportResultCode = {}));
7666
-
7667
- // src/telemetry/semconv.ts
7806
+ import { millisToHrTime } from "@opentelemetry/core";
7668
7807
  import {
7669
7808
  ATTR_ERROR_TYPE,
7670
7809
  ATTR_GEN_AI_OPERATION_NAME,
@@ -7681,7 +7820,7 @@ import {
7681
7820
  } from "@opentelemetry/semantic-conventions/incubating";
7682
7821
 
7683
7822
  // src/version.ts
7684
- var VERSION = "0.6.0";
7823
+ var VERSION = "0.8.0";
7685
7824
 
7686
7825
  // src/telemetry/export-identity.ts
7687
7826
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -7696,7 +7835,10 @@ var ATTR_OTELHOOK_INVOCATION_ID = "otelhook.invocation.id";
7696
7835
  var ATTR_OTELHOOK_PROVIDER_ID = "otelhook.provider.id";
7697
7836
  var ATTR_OTELHOOK_PROVIDER_VERSION = "otelhook.provider.version";
7698
7837
  var ATTR_OTELHOOK_WORKSPACE_ID = "otelhook.workspace.id";
7699
- var HAR_SESSION_KEY = "har.session_key";
7838
+ var EXTERNAL_SESSION_KEY_ATTRIBUTES = Object.freeze([
7839
+ ATTR_SESSION_ID,
7840
+ "har.session_key"
7841
+ ]);
7700
7842
  var ATTR_OTELHOOK_SUBAGENT_ID = "otelhook.subagent.id";
7701
7843
  var ATTR_VCS_REF_HEAD_NAME = "vcs.ref.head.name";
7702
7844
  var ATTR_OTELHOOK_TARGET_WORKSPACE_ID = "otelhook.target.workspace.id";
@@ -7719,21 +7861,26 @@ var targetAttributes = (event3) => {
7719
7861
  };
7720
7862
  var usageTemporalityAttributes = (usage) => usage === void 0 ? {} : { [ATTR_OTELHOOK_USAGE_TEMPORALITY]: usage.temporality };
7721
7863
  var isPrimitiveAttribute = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
7722
- var passthroughHarAttributes = (resource) => {
7864
+ var PASSTHROUGH_RESOURCE_PREFIXES = Object.freeze(["har.", "factory.", "vcs."]);
7865
+ var LOCAL_ONLY_RESOURCE_PREFIX = "factory.local.";
7866
+ var isPassthroughKey = (key) => PASSTHROUGH_RESOURCE_PREFIXES.some((prefix) => key.startsWith(prefix)) && !key.startsWith(LOCAL_ONLY_RESOURCE_PREFIX) && key !== "factory.local";
7867
+ var passthroughResourceAttributes = (resource) => {
7723
7868
  const attributes = {};
7724
7869
  for (const [key, value] of Object.entries(resource.attributes)) {
7725
- if (key.startsWith("har.") && isPrimitiveAttribute(value)) {
7870
+ if (isPassthroughKey(key) && isPrimitiveAttribute(value)) {
7726
7871
  attributes[key] = value;
7727
7872
  }
7728
7873
  }
7729
7874
  return attributes;
7730
7875
  };
7731
7876
  var resolveExportedSessionId = (eventSessionId, resource) => {
7732
- const har = resource.attributes[HAR_SESSION_KEY];
7733
- if (typeof har === "string") {
7734
- const trimmed = har.trim();
7735
- if (trimmed.length > 0) {
7736
- return { sessionId: trimmed, providerSessionId: eventSessionId };
7877
+ for (const key of EXTERNAL_SESSION_KEY_ATTRIBUTES) {
7878
+ const supplied = resource.attributes[key];
7879
+ if (typeof supplied === "string") {
7880
+ const trimmed = supplied.trim();
7881
+ if (trimmed.length > 0) {
7882
+ return { sessionId: trimmed, providerSessionId: eventSessionId };
7883
+ }
7737
7884
  }
7738
7885
  }
7739
7886
  return { sessionId: eventSessionId, providerSessionId: eventSessionId };
@@ -7754,7 +7901,7 @@ var exportIdentityAttributes = (event3, resource, ids) => {
7754
7901
  ...event3.provenance.providerVersion === void 0 ? {} : { [ATTR_OTELHOOK_PROVIDER_VERSION]: event3.provenance.providerVersion },
7755
7902
  [ATTR_OTELHOOK_WORKSPACE_ID]: event3.workspace.workspaceId,
7756
7903
  ...event3.subagentId === void 0 ? {} : { [ATTR_OTELHOOK_SUBAGENT_ID]: event3.subagentId },
7757
- ...passthroughHarAttributes(resource),
7904
+ ...passthroughResourceAttributes(resource),
7758
7905
  ...hexTraceAttributes(ids)
7759
7906
  };
7760
7907
  };
@@ -7904,12 +8051,12 @@ var pickTarget = (attributes) => {
7904
8051
  }
7905
8052
  return picked;
7906
8053
  };
7907
- var withoutTarget = (attributes) => {
8054
+ var withoutTarget = (attributes, resource) => {
7908
8055
  const rest = { ...attributes };
7909
8056
  for (const key of TARGET_KEYS) {
7910
8057
  delete rest[key];
7911
8058
  }
7912
- return rest;
8059
+ return { ...rest, ...pickTarget(passthroughResourceAttributes(resource)) };
7913
8060
  };
7914
8061
  var rankOf = (candidate) => {
7915
8062
  const source = candidate[ATTR_OTELHOOK_TARGET_SOURCE];
@@ -8014,7 +8161,7 @@ var buildLifecycleSpan = (plan, resource, scope) => {
8014
8161
  name = "session";
8015
8162
  kind = SpanKind.INTERNAL;
8016
8163
  attributes = {
8017
- ...withoutTarget(attributes),
8164
+ ...withoutTarget(attributes, resource),
8018
8165
  ...strongestTarget([pickTarget(resolved.recovered), start === void 0 ? {} : targetAttributes(start)]),
8019
8166
  ...start?.agentName === void 0 ? {} : { [ATTR_OTELHOOK_AGENT_NAME]: start.agentName },
8020
8167
  ...start?.agentVersion === void 0 ? {} : { [ATTR_OTELHOOK_AGENT_VERSION]: start.agentVersion },
@@ -8055,7 +8202,7 @@ var buildLifecycleSpan = (plan, resource, scope) => {
8055
8202
  kind = SpanKind.CLIENT;
8056
8203
  attributes = {
8057
8204
  // Target keys are re-chosen below as one unit, never mixed across edges.
8058
- ...withoutTarget(attributes),
8205
+ ...withoutTarget(attributes, resource),
8059
8206
  [ATTR_GEN_AI_TOOL_NAME]: toolName,
8060
8207
  [ATTR_GEN_AI_TOOL_CALL_ID]: start?.toolCallId ?? end?.toolCallId ?? group.ref.scopeKey,
8061
8208
  ...start?.toolKind === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_KIND]: start.toolKind },
@@ -9403,6 +9550,7 @@ var createFileDurableSpool = (options) => createSpoolQueue({
9403
9550
  });
9404
9551
 
9405
9552
  // src/telemetry/otlp-sink.ts
9553
+ import { ExportResultCode } from "@opentelemetry/core";
9406
9554
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
9407
9555
 
9408
9556
  // src/diagnostics/health.ts
@@ -9669,8 +9817,8 @@ var createOtlpTraceSink = (options) => {
9669
9817
  };
9670
9818
 
9671
9819
  // src/telemetry/log-records.ts
9672
- import { TraceFlags as TraceFlags2 } from "@opentelemetry/api";
9673
- import { SeverityNumber } from "@opentelemetry/api-logs";
9820
+ import { SeverityNumber, TraceFlags as TraceFlags2 } from "@opentelemetry/api";
9821
+ import { millisToHrTime as millisToHrTime2 } from "@opentelemetry/core";
9674
9822
  import {
9675
9823
  ATTR_ERROR_TYPE as ATTR_ERROR_TYPE2,
9676
9824
  ATTR_GEN_AI_OPERATION_NAME as ATTR_GEN_AI_OPERATION_NAME2,
@@ -9991,14 +10139,14 @@ var contentAttributes = (fact, body) => ({
9991
10139
  });
9992
10140
  var buildRecord = (input) => {
9993
10141
  const severityNumber = severityFor(input.event);
9994
- const hrTime2 = millisToHrTime(input.event.occurredAt);
10142
+ const hrTime = millisToHrTime2(input.event.occurredAt);
9995
10143
  return {
9996
- hrTime: hrTime2,
10144
+ hrTime,
9997
10145
  // A hook observes an event that already happened, and this mapping is pure —
9998
10146
  // there is no clock here to read a real observation time from. Reporting the
9999
10147
  // occurrence time for both is the honest answer: it says "this is when it
10000
10148
  // happened" twice rather than inventing a second, wrong timestamp.
10001
- hrTimeObserved: hrTime2,
10149
+ hrTimeObserved: hrTime,
10002
10150
  spanContext: input.spanContext,
10003
10151
  severityNumber,
10004
10152
  severityText: SEVERITY_TEXT[severityNumber] ?? "INFO",
@@ -10188,16 +10336,9 @@ var createFileDurableLogSpool = (options) => createSpoolQueue({
10188
10336
 
10189
10337
  // src/telemetry/otlp-log-sink.ts
10190
10338
  import { TraceFlags as TraceFlags3 } from "@opentelemetry/api";
10339
+ import { ExportResultCode as ExportResultCode2 } from "@opentelemetry/core";
10340
+ import { millisToHrTime as millisToHrTime3 } from "@opentelemetry/core";
10191
10341
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-proto";
10192
- var OTLP_TRACES_PATH = "/v1/traces";
10193
- var OTLP_LOGS_PATH = "/v1/logs";
10194
- var withoutTrailingSlashes = (value) => {
10195
- let end = value.length;
10196
- while (end > 0 && value.charCodeAt(end - 1) === 47) {
10197
- end -= 1;
10198
- }
10199
- return value.slice(0, end);
10200
- };
10201
10342
  var resolveLogsEndpoint = (exporter) => {
10202
10343
  if (exporter.logs.endpoint !== void 0) {
10203
10344
  return { endpoint: exporter.logs.endpoint, derived: false };
@@ -10251,8 +10392,8 @@ var deserializeRecord = (serialized, resource, scope) => {
10251
10392
  isRemote: false
10252
10393
  };
10253
10394
  return {
10254
- hrTime: millisToHrTime(serialized.timeMillis),
10255
- hrTimeObserved: millisToHrTime(serialized.observedTimeMillis),
10395
+ hrTime: millisToHrTime3(serialized.timeMillis),
10396
+ hrTimeObserved: millisToHrTime3(serialized.observedTimeMillis),
10256
10397
  ...spanContext === void 0 ? {} : { spanContext },
10257
10398
  severityNumber: serialized.severityNumber,
10258
10399
  ...serialized.severityText === void 0 ? {} : { severityText: serialized.severityText },
@@ -10353,7 +10494,7 @@ var createOtlpLogSink = (options) => {
10353
10494
  (record) => deserializeRecord(record, batchResource, batch.instrumentationScope)
10354
10495
  );
10355
10496
  const result = await exportRecords(records);
10356
- return result.code === ExportResultCode.SUCCESS;
10497
+ return result.code === ExportResultCode2.SUCCESS;
10357
10498
  };
10358
10499
  const resolveCorrelations = async (events) => {
10359
10500
  if (options.correlate === void 0) {
@@ -10395,11 +10536,11 @@ var createOtlpLogSink = (options) => {
10395
10536
  result = await exportRecords(batch);
10396
10537
  } catch (thrown) {
10397
10538
  result = {
10398
- code: ExportResultCode.FAILED,
10539
+ code: ExportResultCode2.FAILED,
10399
10540
  error: thrown instanceof Error ? thrown : new Error("export threw")
10400
10541
  };
10401
10542
  }
10402
- if (result.code === ExportResultCode.SUCCESS) {
10543
+ if (result.code === ExportResultCode2.SUCCESS) {
10403
10544
  accepted += batch.length;
10404
10545
  health.recordSuccess(batch.length, options.clock.now());
10405
10546
  continue;
@@ -10600,9 +10741,10 @@ var createHookRuntime = (options) => {
10600
10741
  ...spool === void 0 ? {} : { spool },
10601
10742
  correlate
10602
10743
  });
10744
+ const logHeaders = options.logHeaders ?? options.headers;
10603
10745
  const logSink = createOtlpLogSink({
10604
10746
  exporter: options.config.exporter,
10605
- ...options.headers === void 0 ? {} : { headers: options.headers },
10747
+ ...logHeaders === void 0 ? {} : { headers: logHeaders },
10606
10748
  providerId: options.providerNamespace,
10607
10749
  installationId: options.installationId,
10608
10750
  clock,
@@ -12473,6 +12615,7 @@ export {
12473
12615
  MAX_LOG_BODY_CHARACTERS,
12474
12616
  MAX_LOG_RECORDS_PER_BATCH,
12475
12617
  MAX_LOG_RECORDS_PER_EVENT,
12618
+ MAX_OTLP_HEADERS,
12476
12619
  MAX_RECOVERED_START_ATTRIBUTES,
12477
12620
  MAX_RESOURCE_ATTRIBUTES,
12478
12621
  MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
@@ -12482,6 +12625,8 @@ export {
12482
12625
  MAX_WORKTREE_WALK_DEPTH,
12483
12626
  MCP_TOOL_NAME_PATTERN,
12484
12627
  NO_LOG_CONTENT,
12628
+ OTLP_ENDPOINT_VARIABLES,
12629
+ OTLP_HEADER_VARIABLES,
12485
12630
  OtelHookError,
12486
12631
  PROVIDERS_WITHOUT_VERIFIED_LOCATION,
12487
12632
  PROVIDERS_WITH_VERIFIED_LOCATION,
@@ -12582,6 +12727,7 @@ export {
12582
12727
  describeAdapter,
12583
12728
  describeErrorCode,
12584
12729
  describeLogsDeliverability,
12730
+ describeOtlpHeaderNames,
12585
12731
  describeProviderCatalog,
12586
12732
  describeResolvedConfig,
12587
12733
  describeResourceAttributeNames,
@@ -12638,6 +12784,7 @@ export {
12638
12784
  mergeCursorHookRegistration,
12639
12785
  mergeGeminiHookRegistration,
12640
12786
  mergeNestedHookRegistration,
12787
+ mergeOtlpHeaders,
12641
12788
  minimumStaleClaimMillis,
12642
12789
  modelDescriptorSchema,
12643
12790
  nonEmptyStringSchema,
@@ -12647,12 +12794,14 @@ export {
12647
12794
  otelHookConfigSchema,
12648
12795
  otelHookErrorCodeSchema,
12649
12796
  otelHookErrorInfoSchema,
12797
+ otlpSignalEndpointFromBase,
12650
12798
  parentScopeRefOf,
12651
12799
  parseCanonicalEvent,
12652
12800
  parseCommonDirFile,
12653
12801
  parseEnvironmentConfig,
12654
12802
  parseGitDirFile,
12655
12803
  parseHeadBranch,
12804
+ parseOtlpHeadersValue,
12656
12805
  parseResourceAttributesValue,
12657
12806
  planProviderRegistration,
12658
12807
  privacyLimitsSchema,
@@ -12688,6 +12837,7 @@ export {
12688
12837
  resolveInstallPath,
12689
12838
  resolveInvocationIdentity,
12690
12839
  resolveLogsEndpoint,
12840
+ resolveOtlpHeaders,
12691
12841
  resolvePrivacyPolicy,
12692
12842
  resolvedProviderIdSchema,
12693
12843
  resourceAttributeValueSchema,
@@ -12717,6 +12867,7 @@ export {
12717
12867
  toolEndEventSchema,
12718
12868
  toolKindSchema,
12719
12869
  toolStartEventSchema,
12870
+ unionOtlpHeaderNames,
12720
12871
  unknownDetection,
12721
12872
  unknownWorkspaceIdentity,
12722
12873
  usageReportSchema,