@naylence/agent-sdk 0.3.4-test.727 → 0.3.4-test.728
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/browser/index.js +317 -302
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -15671,12 +15671,12 @@
|
|
|
15671
15671
|
// --- END ENV SHIM ---
|
|
15672
15672
|
|
|
15673
15673
|
// This file is auto-generated during build - do not edit manually
|
|
15674
|
-
// Generated from package.json version: 0.3.5-test.
|
|
15674
|
+
// Generated from package.json version: 0.3.5-test.930
|
|
15675
15675
|
/**
|
|
15676
15676
|
* The package version, injected at build time.
|
|
15677
15677
|
* @internal
|
|
15678
15678
|
*/
|
|
15679
|
-
const VERSION$1 = '0.3.5-test.
|
|
15679
|
+
const VERSION$1 = '0.3.5-test.930';
|
|
15680
15680
|
|
|
15681
15681
|
/**
|
|
15682
15682
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -44050,239 +44050,10 @@
|
|
|
44050
44050
|
default: NoopTraceEmitterFactory
|
|
44051
44051
|
});
|
|
44052
44052
|
|
|
44053
|
-
const logger$n = getLogger('naylence.fame.telemetry.otel_setup');
|
|
44054
|
-
const stringFrom = (...codes) => String.fromCharCode(...codes);
|
|
44055
|
-
const OTEL_PREFIX = `${stringFrom(64, 111, 112, 101, 110, 116, 101, 108, 101, 109, 101, 116, 114, 121)}${stringFrom(47)}`;
|
|
44056
|
-
const OTEL_API_SPEC = `${OTEL_PREFIX}${stringFrom(97, 112, 105)}`;
|
|
44057
|
-
const OTEL_RESOURCES_SPEC = `${OTEL_PREFIX}${stringFrom(114, 101, 115, 111, 117, 114, 99, 101, 115)}`;
|
|
44058
|
-
const OTEL_TRACE_NODE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 110, 111, 100, 101)}`;
|
|
44059
|
-
const OTEL_TRACE_BASE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 98, 97, 115, 101)}`;
|
|
44060
|
-
const OTEL_EXPORTER_HTTP_SPEC = `${OTEL_PREFIX}${stringFrom(101, 120, 112, 111, 114, 116, 101, 114, 45, 116, 114, 97, 99, 101, 45, 111, 116, 108, 112, 45, 104, 116, 116, 112)}`;
|
|
44061
|
-
let registeredOtel = null;
|
|
44062
|
-
async function setupOtel(options) {
|
|
44063
|
-
const normalized = normalizeSetupOtelOptions(options);
|
|
44064
|
-
try {
|
|
44065
|
-
if (registeredOtel) {
|
|
44066
|
-
logger$n.debug('open_telemetry_reusing_provider', {
|
|
44067
|
-
service_name: normalized.serviceName,
|
|
44068
|
-
});
|
|
44069
|
-
return registeredOtel.control;
|
|
44070
|
-
}
|
|
44071
|
-
const [apiModule, resourcesModule, nodeModule, traceBaseModule] = await Promise.all([
|
|
44072
|
-
import(OTEL_API_SPEC),
|
|
44073
|
-
import(OTEL_RESOURCES_SPEC),
|
|
44074
|
-
import(OTEL_TRACE_NODE_SPEC),
|
|
44075
|
-
import(OTEL_TRACE_BASE_SPEC),
|
|
44076
|
-
]);
|
|
44077
|
-
const { trace } = apiModule;
|
|
44078
|
-
const { defaultResource, resourceFromAttributes } = resourcesModule;
|
|
44079
|
-
const { NodeTracerProvider } = nodeModule;
|
|
44080
|
-
const { BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, AlwaysOnSampler, AlwaysOffSampler, TraceIdRatioBasedSampler, } = traceBaseModule;
|
|
44081
|
-
const currentProvider = trace.getTracerProvider();
|
|
44082
|
-
if (currentProvider && currentProvider instanceof NodeTracerProvider) {
|
|
44083
|
-
return null;
|
|
44084
|
-
}
|
|
44085
|
-
if (currentProvider &&
|
|
44086
|
-
currentProvider.constructor?.name === 'NodeTracerProvider') {
|
|
44087
|
-
logger$n.debug('open_telemetry_existing_node_provider', {
|
|
44088
|
-
service_name: normalized.serviceName,
|
|
44089
|
-
});
|
|
44090
|
-
return null;
|
|
44091
|
-
}
|
|
44092
|
-
logger$n.debug('open_telemetry_initializing', {
|
|
44093
|
-
service_name: normalized.serviceName,
|
|
44094
|
-
endpoint: normalized.endpoint ?? null,
|
|
44095
|
-
environment: normalized.environment ?? null,
|
|
44096
|
-
sampler: normalized.sampler ?? null,
|
|
44097
|
-
headers_present: Boolean(normalized.headers && Object.keys(normalized.headers).length),
|
|
44098
|
-
});
|
|
44099
|
-
const sampler = resolveSampler(normalized.sampler, {
|
|
44100
|
-
ParentBasedSampler,
|
|
44101
|
-
AlwaysOnSampler,
|
|
44102
|
-
AlwaysOffSampler,
|
|
44103
|
-
TraceIdRatioBasedSampler,
|
|
44104
|
-
});
|
|
44105
|
-
const baseResource = defaultResource();
|
|
44106
|
-
const mergedResource = resourceFromAttributes({
|
|
44107
|
-
'service.name': normalized.serviceName,
|
|
44108
|
-
'service.instance.id': generateInstanceId(),
|
|
44109
|
-
'deployment.environment': normalized.environment ?? 'dev',
|
|
44110
|
-
});
|
|
44111
|
-
const resource = baseResource.merge(mergedResource);
|
|
44112
|
-
const exporter = await resolveExporter(normalized.endpoint ?? undefined, normalized.headers, ConsoleSpanExporter);
|
|
44113
|
-
const spanProcessor = new BatchSpanProcessor(exporter);
|
|
44114
|
-
const provider = new NodeTracerProvider({
|
|
44115
|
-
resource,
|
|
44116
|
-
sampler,
|
|
44117
|
-
spanProcessors: [spanProcessor],
|
|
44118
|
-
});
|
|
44119
|
-
provider.register();
|
|
44120
|
-
logger$n.debug('open_telemetry_initialized', {
|
|
44121
|
-
service_name: normalized.serviceName,
|
|
44122
|
-
exporter: exporter.constructor?.name ?? 'unknown_exporter',
|
|
44123
|
-
});
|
|
44124
|
-
const control = {
|
|
44125
|
-
forceFlush: async () => {
|
|
44126
|
-
try {
|
|
44127
|
-
await provider.forceFlush();
|
|
44128
|
-
}
|
|
44129
|
-
catch (flushError) {
|
|
44130
|
-
logger$n.warning('open_telemetry_force_flush_failed', {
|
|
44131
|
-
error: flushError instanceof Error
|
|
44132
|
-
? flushError.message
|
|
44133
|
-
: String(flushError),
|
|
44134
|
-
});
|
|
44135
|
-
}
|
|
44136
|
-
},
|
|
44137
|
-
shutdown: async () => {
|
|
44138
|
-
try {
|
|
44139
|
-
await provider.shutdown();
|
|
44140
|
-
}
|
|
44141
|
-
catch (shutdownError) {
|
|
44142
|
-
logger$n.warning('open_telemetry_shutdown_failed', {
|
|
44143
|
-
error: shutdownError instanceof Error
|
|
44144
|
-
? shutdownError.message
|
|
44145
|
-
: String(shutdownError),
|
|
44146
|
-
});
|
|
44147
|
-
}
|
|
44148
|
-
finally {
|
|
44149
|
-
registeredOtel = null;
|
|
44150
|
-
}
|
|
44151
|
-
},
|
|
44152
|
-
};
|
|
44153
|
-
registeredOtel = {
|
|
44154
|
-
provider,
|
|
44155
|
-
control,
|
|
44156
|
-
};
|
|
44157
|
-
return control;
|
|
44158
|
-
}
|
|
44159
|
-
catch (error) {
|
|
44160
|
-
logger$n.error('open_telemetry_not_available', {
|
|
44161
|
-
error: error instanceof Error ? error.message : String(error),
|
|
44162
|
-
stack: error instanceof Error && error.stack ? error.stack : undefined,
|
|
44163
|
-
});
|
|
44164
|
-
return null;
|
|
44165
|
-
}
|
|
44166
|
-
}
|
|
44167
|
-
function normalizeSetupOtelOptions(options) {
|
|
44168
|
-
const source = (options ?? {});
|
|
44169
|
-
const serviceName = extractNonEmptyString$1(pickFirst$2(source, ['serviceName', 'service_name'])) ??
|
|
44170
|
-
'naylence-service';
|
|
44171
|
-
const endpoint = extractNonEmptyString$1(pickFirst$2(source, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
44172
|
-
const environment = extractNonEmptyString$1(pickFirst$2(source, [
|
|
44173
|
-
'environment',
|
|
44174
|
-
'deploymentEnvironment',
|
|
44175
|
-
'deployment_environment',
|
|
44176
|
-
])) ?? null;
|
|
44177
|
-
const sampler = extractNonEmptyString$1(pickFirst$2(source, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
44178
|
-
const headers = extractHeaders$1(pickFirst$2(source, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
44179
|
-
return {
|
|
44180
|
-
serviceName,
|
|
44181
|
-
endpoint,
|
|
44182
|
-
environment,
|
|
44183
|
-
sampler,
|
|
44184
|
-
headers: headers ?? undefined,
|
|
44185
|
-
};
|
|
44186
|
-
}
|
|
44187
|
-
function pickFirst$2(source, keys) {
|
|
44188
|
-
for (const key of keys) {
|
|
44189
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44190
|
-
const value = source[key];
|
|
44191
|
-
if (value !== undefined) {
|
|
44192
|
-
return value;
|
|
44193
|
-
}
|
|
44194
|
-
}
|
|
44195
|
-
}
|
|
44196
|
-
return undefined;
|
|
44197
|
-
}
|
|
44198
|
-
function extractNonEmptyString$1(value) {
|
|
44199
|
-
if (typeof value === 'string') {
|
|
44200
|
-
const trimmed = value.trim();
|
|
44201
|
-
if (trimmed.length > 0) {
|
|
44202
|
-
return trimmed;
|
|
44203
|
-
}
|
|
44204
|
-
}
|
|
44205
|
-
return undefined;
|
|
44206
|
-
}
|
|
44207
|
-
function extractHeaders$1(value) {
|
|
44208
|
-
if (!value || typeof value !== 'object') {
|
|
44209
|
-
return null;
|
|
44210
|
-
}
|
|
44211
|
-
const headers = {};
|
|
44212
|
-
for (const [key, raw] of Object.entries(value)) {
|
|
44213
|
-
if (typeof raw === 'string') {
|
|
44214
|
-
headers[key] = raw;
|
|
44215
|
-
}
|
|
44216
|
-
}
|
|
44217
|
-
return Object.keys(headers).length > 0 ? headers : null;
|
|
44218
|
-
}
|
|
44219
|
-
function generateInstanceId() {
|
|
44220
|
-
try {
|
|
44221
|
-
if (typeof crypto !== 'undefined' &&
|
|
44222
|
-
typeof crypto.randomUUID === 'function') {
|
|
44223
|
-
return crypto.randomUUID().replace(/-/g, '');
|
|
44224
|
-
}
|
|
44225
|
-
}
|
|
44226
|
-
catch {
|
|
44227
|
-
// Ignore crypto availability errors
|
|
44228
|
-
}
|
|
44229
|
-
const random = Math.random().toString(16).slice(2);
|
|
44230
|
-
return random.padEnd(32, '0').slice(0, 32);
|
|
44231
|
-
}
|
|
44232
|
-
function resolveSampler(samplerSetting, samplers) {
|
|
44233
|
-
const normalized = (samplerSetting ?? 'parentbased_always_on').toLowerCase();
|
|
44234
|
-
let base;
|
|
44235
|
-
if (normalized === 'always_off') {
|
|
44236
|
-
base = new samplers.AlwaysOffSampler();
|
|
44237
|
-
}
|
|
44238
|
-
else if (normalized === 'always_on' ||
|
|
44239
|
-
normalized === 'parentbased_always_on') {
|
|
44240
|
-
base = new samplers.AlwaysOnSampler();
|
|
44241
|
-
}
|
|
44242
|
-
else if (normalized.startsWith('ratio:')) {
|
|
44243
|
-
const ratioValue = Number.parseFloat(normalized.slice('ratio:'.length));
|
|
44244
|
-
const ratio = Number.isFinite(ratioValue)
|
|
44245
|
-
? Math.min(Math.max(ratioValue, 0), 1)
|
|
44246
|
-
: 1;
|
|
44247
|
-
base = new samplers.TraceIdRatioBasedSampler(ratio);
|
|
44248
|
-
}
|
|
44249
|
-
else {
|
|
44250
|
-
base = new samplers.AlwaysOnSampler();
|
|
44251
|
-
}
|
|
44252
|
-
return new samplers.ParentBasedSampler({ root: base });
|
|
44253
|
-
}
|
|
44254
|
-
async function resolveExporter(endpoint, headers, ConsoleSpanExporter) {
|
|
44255
|
-
if (endpoint) {
|
|
44256
|
-
try {
|
|
44257
|
-
const exporterModule = await import(OTEL_EXPORTER_HTTP_SPEC);
|
|
44258
|
-
if ('OTLPTraceExporter' in exporterModule) {
|
|
44259
|
-
const { OTLPTraceExporter } = exporterModule;
|
|
44260
|
-
const exporterOptions = {
|
|
44261
|
-
url: endpoint,
|
|
44262
|
-
};
|
|
44263
|
-
if (headers && Object.keys(headers).length > 0) {
|
|
44264
|
-
exporterOptions.headers = headers;
|
|
44265
|
-
}
|
|
44266
|
-
logger$n.debug('open_telemetry_using_otlp_http_exporter', {
|
|
44267
|
-
endpoint,
|
|
44268
|
-
headers_present: Boolean(headers && Object.keys(headers).length),
|
|
44269
|
-
});
|
|
44270
|
-
return new OTLPTraceExporter(exporterOptions);
|
|
44271
|
-
}
|
|
44272
|
-
}
|
|
44273
|
-
catch (error) {
|
|
44274
|
-
logger$n.error('open_telemetry_exporter_not_available', {
|
|
44275
|
-
error: error instanceof Error ? error.message : String(error),
|
|
44276
|
-
});
|
|
44277
|
-
}
|
|
44278
|
-
}
|
|
44279
|
-
logger$n.warning('open_telemetry_falling_back_to_console_exporter');
|
|
44280
|
-
return new ConsoleSpanExporter();
|
|
44281
|
-
}
|
|
44282
|
-
|
|
44283
44053
|
let openTelemetryTraceEmitterModulePromise = null;
|
|
44284
44054
|
let otelApiModulePromise = null;
|
|
44285
|
-
|
|
44055
|
+
let otelSetupModulePromise = null;
|
|
44056
|
+
const logger$n = getLogger('naylence.fame.telemetry.open_telemetry_trace_emitter_factory');
|
|
44286
44057
|
const MISSING_OTEL_HELP_MESSAGE = 'Missing optional OpenTelemetry dependency. Install @opentelemetry/api (and related packages) to enable trace emission.';
|
|
44287
44058
|
function getOpenTelemetryTraceEmitterModule() {
|
|
44288
44059
|
if (!openTelemetryTraceEmitterModulePromise) {
|
|
@@ -44300,6 +44071,14 @@
|
|
|
44300
44071
|
}
|
|
44301
44072
|
return otelApiModulePromise;
|
|
44302
44073
|
}
|
|
44074
|
+
function getOtelSetupModule() {
|
|
44075
|
+
if (!otelSetupModulePromise) {
|
|
44076
|
+
otelSetupModulePromise = safeImport(() => Promise.resolve().then(function () { return otelSetup; }), '@opentelemetry/api', {
|
|
44077
|
+
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
44078
|
+
});
|
|
44079
|
+
}
|
|
44080
|
+
return otelSetupModulePromise;
|
|
44081
|
+
}
|
|
44303
44082
|
const FACTORY_META$V = {
|
|
44304
44083
|
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
44305
44084
|
key: 'OpenTelemetryTraceEmitter',
|
|
@@ -44323,7 +44102,7 @@
|
|
|
44323
44102
|
await AuthInjectionStrategyFactory.createAuthInjectionStrategy(normalized.auth);
|
|
44324
44103
|
try {
|
|
44325
44104
|
await authStrategy.apply(mergedHeaders);
|
|
44326
|
-
logger$
|
|
44105
|
+
logger$n.info('trace_emitter_auth_applied', {
|
|
44327
44106
|
service_name: normalized.serviceName,
|
|
44328
44107
|
});
|
|
44329
44108
|
}
|
|
@@ -44339,6 +44118,7 @@
|
|
|
44339
44118
|
}
|
|
44340
44119
|
let lifecycle = null;
|
|
44341
44120
|
try {
|
|
44121
|
+
const { setupOtel } = await getOtelSetupModule();
|
|
44342
44122
|
lifecycle = await setupOtel({
|
|
44343
44123
|
serviceName: normalized.serviceName,
|
|
44344
44124
|
endpoint: normalized.endpoint,
|
|
@@ -44346,7 +44126,7 @@
|
|
|
44346
44126
|
sampler: normalized.sampler,
|
|
44347
44127
|
headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : undefined,
|
|
44348
44128
|
});
|
|
44349
|
-
logger$
|
|
44129
|
+
logger$n.debug('trace_emitter_lifecycle_acquired', {
|
|
44350
44130
|
service_name: normalized.serviceName,
|
|
44351
44131
|
lifecycle_available: Boolean(lifecycle),
|
|
44352
44132
|
});
|
|
@@ -44384,7 +44164,7 @@
|
|
|
44384
44164
|
}
|
|
44385
44165
|
try {
|
|
44386
44166
|
const emitter = new OpenTelemetryTraceEmitter(emitterOptions);
|
|
44387
|
-
logger$
|
|
44167
|
+
logger$n.debug('trace_emitter_created', {
|
|
44388
44168
|
service_name: normalized.serviceName,
|
|
44389
44169
|
has_lifecycle: Boolean(lifecycle),
|
|
44390
44170
|
has_auth_strategy: Boolean(authStrategy),
|
|
@@ -44416,17 +44196,17 @@
|
|
|
44416
44196
|
};
|
|
44417
44197
|
}
|
|
44418
44198
|
const candidate = config;
|
|
44419
|
-
const serviceName = extractString(pickFirst$
|
|
44199
|
+
const serviceName = extractString(pickFirst$2(candidate, ['serviceName', 'service_name'])) ??
|
|
44420
44200
|
'naylence-service';
|
|
44421
|
-
const endpoint = extractString(pickFirst$
|
|
44422
|
-
const environment = extractString(pickFirst$
|
|
44201
|
+
const endpoint = extractString(pickFirst$2(candidate, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
44202
|
+
const environment = extractString(pickFirst$2(candidate, [
|
|
44423
44203
|
'environment',
|
|
44424
44204
|
'deploymentEnvironment',
|
|
44425
44205
|
'deployment_environment',
|
|
44426
44206
|
])) ?? null;
|
|
44427
|
-
const sampler = extractString(pickFirst$
|
|
44428
|
-
const headersFromConfig = extractHeaders(pickFirst$
|
|
44429
|
-
const authConfig = pickFirst$
|
|
44207
|
+
const sampler = extractString(pickFirst$2(candidate, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
44208
|
+
const headersFromConfig = extractHeaders$1(pickFirst$2(candidate, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
44209
|
+
const authConfig = pickFirst$2(candidate, [
|
|
44430
44210
|
'auth',
|
|
44431
44211
|
]);
|
|
44432
44212
|
return {
|
|
@@ -44444,7 +44224,7 @@
|
|
|
44444
44224
|
}
|
|
44445
44225
|
return undefined;
|
|
44446
44226
|
}
|
|
44447
|
-
function pickFirst$
|
|
44227
|
+
function pickFirst$2(source, keys) {
|
|
44448
44228
|
for (const key of keys) {
|
|
44449
44229
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44450
44230
|
const value = source[key];
|
|
@@ -44455,7 +44235,7 @@
|
|
|
44455
44235
|
}
|
|
44456
44236
|
return undefined;
|
|
44457
44237
|
}
|
|
44458
|
-
function extractHeaders(value) {
|
|
44238
|
+
function extractHeaders$1(value) {
|
|
44459
44239
|
if (!value || typeof value !== 'object') {
|
|
44460
44240
|
return null;
|
|
44461
44241
|
}
|
|
@@ -44475,7 +44255,7 @@
|
|
|
44475
44255
|
default: OpenTelemetryTraceEmitterFactory
|
|
44476
44256
|
});
|
|
44477
44257
|
|
|
44478
|
-
const logger$
|
|
44258
|
+
const logger$m = getLogger('naylence.fame.telemetry.trace_emitter_profile_factory');
|
|
44479
44259
|
const PROFILE_NAME_NOOP$1 = 'noop';
|
|
44480
44260
|
const PROFILE_NAME_OPEN_TELEMETRY = 'open-telemetry';
|
|
44481
44261
|
const ENV_VAR_TELEMETRY_SERVICE_NAME = 'FAME_TELEMETRY_SERVICE_NAME';
|
|
@@ -44503,7 +44283,7 @@
|
|
|
44503
44283
|
async create(config, ...factoryArgs) {
|
|
44504
44284
|
const normalized = normalizeTraceEmitterProfileConfig(config);
|
|
44505
44285
|
const profileConfig = resolveProfileConfig$2(normalized.profile);
|
|
44506
|
-
logger$
|
|
44286
|
+
logger$m.debug('enabling_trace_emitter_profile', {
|
|
44507
44287
|
profile: normalized.profile,
|
|
44508
44288
|
});
|
|
44509
44289
|
const traceEmitter = await TraceEmitterFactory.createTraceEmitter(profileConfig, {
|
|
@@ -44691,7 +44471,7 @@
|
|
|
44691
44471
|
default: HttpListenerFactory
|
|
44692
44472
|
});
|
|
44693
44473
|
|
|
44694
|
-
const logger$
|
|
44474
|
+
const logger$l = getLogger('naylence.fame.connector.http_stateless_connector');
|
|
44695
44475
|
class HttpStatelessConnector extends BaseAsyncConnector {
|
|
44696
44476
|
constructor(config, dependencies = {}) {
|
|
44697
44477
|
super(config);
|
|
@@ -44737,7 +44517,7 @@
|
|
|
44737
44517
|
}
|
|
44738
44518
|
catch (error) {
|
|
44739
44519
|
if (error instanceof QueueFullError) {
|
|
44740
|
-
logger$
|
|
44520
|
+
logger$l.warning('receive_queue_full', {
|
|
44741
44521
|
url: this.url,
|
|
44742
44522
|
});
|
|
44743
44523
|
}
|
|
@@ -44759,7 +44539,7 @@
|
|
|
44759
44539
|
});
|
|
44760
44540
|
if (!response.ok) {
|
|
44761
44541
|
const statusText = response.statusText || 'HTTP error';
|
|
44762
|
-
logger$
|
|
44542
|
+
logger$l.error('http_request_failed', {
|
|
44763
44543
|
url: this.url,
|
|
44764
44544
|
status: response.status,
|
|
44765
44545
|
statusText,
|
|
@@ -44771,7 +44551,7 @@
|
|
|
44771
44551
|
if (error instanceof FameTransportClose) {
|
|
44772
44552
|
throw error;
|
|
44773
44553
|
}
|
|
44774
|
-
logger$
|
|
44554
|
+
logger$l.error('http_request_error', {
|
|
44775
44555
|
url: this.url,
|
|
44776
44556
|
error: error instanceof Error ? error.message : String(error),
|
|
44777
44557
|
});
|
|
@@ -44985,7 +44765,7 @@
|
|
|
44985
44765
|
default: HttpStatelessConnectorFactory
|
|
44986
44766
|
});
|
|
44987
44767
|
|
|
44988
|
-
const logger$
|
|
44768
|
+
const logger$k = getLogger('naylence.fame.connector.websocket_connector_factory');
|
|
44989
44769
|
let sslLoader = null;
|
|
44990
44770
|
function setWebSocketConnectorSslLoader(loader) {
|
|
44991
44771
|
sslLoader = loader;
|
|
@@ -45269,7 +45049,7 @@
|
|
|
45269
45049
|
}
|
|
45270
45050
|
async _defaultWebSocketClient(url, subprotocols, headers) {
|
|
45271
45051
|
try {
|
|
45272
|
-
logger$
|
|
45052
|
+
logger$k.debug('websocket_connector_connecting', { url, subprotocols });
|
|
45273
45053
|
if (typeof window !== 'undefined' &&
|
|
45274
45054
|
typeof window.WebSocket !== 'undefined') {
|
|
45275
45055
|
return await this._createBrowserWebSocket(url, subprotocols);
|
|
@@ -45352,7 +45132,7 @@
|
|
|
45352
45132
|
await Promise.resolve().then(function () { return websocketConnectorNodeSsl; });
|
|
45353
45133
|
}
|
|
45354
45134
|
catch (error) {
|
|
45355
|
-
logger$
|
|
45135
|
+
logger$k.debug('ssl_certificate_loader_import_failed', {
|
|
45356
45136
|
error: error instanceof Error ? error.message : String(error),
|
|
45357
45137
|
});
|
|
45358
45138
|
}
|
|
@@ -45361,7 +45141,7 @@
|
|
|
45361
45141
|
if (!loader) {
|
|
45362
45142
|
return undefined;
|
|
45363
45143
|
}
|
|
45364
|
-
return await loader(logger$
|
|
45144
|
+
return await loader(logger$k);
|
|
45365
45145
|
}
|
|
45366
45146
|
}
|
|
45367
45147
|
|
|
@@ -45696,7 +45476,7 @@
|
|
|
45696
45476
|
default: AtMostOnceDeliveryPolicyFactory
|
|
45697
45477
|
});
|
|
45698
45478
|
|
|
45699
|
-
const logger$
|
|
45479
|
+
const logger$j = getLogger('naylence.fame.delivery.delivery_profile_factory');
|
|
45700
45480
|
const PROFILE_NAME_AT_LEAST_ONCE = 'at-least-once';
|
|
45701
45481
|
const PROFILE_NAME_AT_MOST_ONCE = 'at-most-once';
|
|
45702
45482
|
const ENV_VAR_FAME_DELIVERY_MAX_RETRIES = 'FAME_DELIVERY_MAX_RETRIES';
|
|
@@ -45736,7 +45516,7 @@
|
|
|
45736
45516
|
async create(config) {
|
|
45737
45517
|
const normalized = normalizeDeliveryProfileConfig(config);
|
|
45738
45518
|
const profileConfig = resolveProfileConfig$1(normalized.profile);
|
|
45739
|
-
logger$
|
|
45519
|
+
logger$j.debug('enabling_delivery_profile', { profile: normalized.profile });
|
|
45740
45520
|
const policy = await DeliveryPolicyFactory.createDeliveryPolicy(profileConfig);
|
|
45741
45521
|
if (!policy) {
|
|
45742
45522
|
throw new Error(`Failed to create delivery policy for profile: ${normalized.profile}`);
|
|
@@ -45819,7 +45599,7 @@
|
|
|
45819
45599
|
service.capabilities.includes(SINK_CAPABILITY));
|
|
45820
45600
|
}
|
|
45821
45601
|
|
|
45822
|
-
const logger$
|
|
45602
|
+
const logger$i = getLogger('naylence.fame.fabric.in_process');
|
|
45823
45603
|
function normalizeNodeConfig(config) {
|
|
45824
45604
|
if (config && typeof config === 'object' && !Array.isArray(config)) {
|
|
45825
45605
|
return config;
|
|
@@ -45843,13 +45623,13 @@
|
|
|
45843
45623
|
this._versionLogged = true;
|
|
45844
45624
|
const version = await resolveRuntimeVersion();
|
|
45845
45625
|
if (version) {
|
|
45846
|
-
logger$
|
|
45626
|
+
logger$i.info('naylence_runtime_startup', {
|
|
45847
45627
|
version,
|
|
45848
45628
|
fabric_type: 'in_process',
|
|
45849
45629
|
});
|
|
45850
45630
|
}
|
|
45851
45631
|
else {
|
|
45852
|
-
logger$
|
|
45632
|
+
logger$i.warning('naylence_runtime_version_not_found', {
|
|
45853
45633
|
message: 'Could not determine package version',
|
|
45854
45634
|
fabric_type: 'in_process',
|
|
45855
45635
|
});
|
|
@@ -45874,7 +45654,7 @@
|
|
|
45874
45654
|
return;
|
|
45875
45655
|
}
|
|
45876
45656
|
await this.logStartupVersion();
|
|
45877
|
-
logger$
|
|
45657
|
+
logger$i.debug('starting_fabric', { type: 'in_process' });
|
|
45878
45658
|
if (!this._currentNode) {
|
|
45879
45659
|
const nodeConfig = normalizeNodeConfig(this._config?.node ?? null);
|
|
45880
45660
|
this._currentNode = await NodeLikeFactory.createNode(nodeConfig);
|
|
@@ -46009,7 +45789,7 @@
|
|
|
46009
45789
|
default: InProcessFameFabricFactory
|
|
46010
45790
|
});
|
|
46011
45791
|
|
|
46012
|
-
const logger$
|
|
45792
|
+
const logger$h = getLogger('naylence.fame.node.admission.admission_profile_factory');
|
|
46013
45793
|
const ENV_VAR_IS_ROOT = 'FAME_ROOT';
|
|
46014
45794
|
const ENV_VAR_JWT_AUDIENCE = 'FAME_JWT_AUDIENCE';
|
|
46015
45795
|
const ENV_VAR_ADMISSION_TOKEN_URL = 'FAME_ADMISSION_TOKEN_URL';
|
|
@@ -46244,7 +46024,7 @@
|
|
|
46244
46024
|
async create(config) {
|
|
46245
46025
|
const normalized = normalizeConfig$m(config);
|
|
46246
46026
|
const profileConfig = resolveProfileConfig(normalized.profile);
|
|
46247
|
-
logger$
|
|
46027
|
+
logger$h.debug('enabling_admission_profile', { profile: normalized.profile });
|
|
46248
46028
|
return AdmissionClientFactory.createAdmissionClient(profileConfig);
|
|
46249
46029
|
}
|
|
46250
46030
|
}
|
|
@@ -46283,7 +46063,7 @@
|
|
|
46283
46063
|
default: AdmissionProfileFactory
|
|
46284
46064
|
});
|
|
46285
46065
|
|
|
46286
|
-
const logger$
|
|
46066
|
+
const logger$g = getLogger('naylence.fame.node.admission.direct_admission_client');
|
|
46287
46067
|
class DirectAdmissionClient {
|
|
46288
46068
|
constructor(options) {
|
|
46289
46069
|
this.hasUpstream = true;
|
|
@@ -46308,7 +46088,7 @@
|
|
|
46308
46088
|
}
|
|
46309
46089
|
}
|
|
46310
46090
|
async hello(systemId, instanceId, requestedLogicals) {
|
|
46311
|
-
logger$
|
|
46091
|
+
logger$g.debug('direct_admission_hello_start', {
|
|
46312
46092
|
providedSystemId: systemId,
|
|
46313
46093
|
instanceId,
|
|
46314
46094
|
requestedLogicals,
|
|
@@ -46316,7 +46096,7 @@
|
|
|
46316
46096
|
const effectiveSystemId = systemId && systemId.trim().length > 0
|
|
46317
46097
|
? systemId
|
|
46318
46098
|
: await generateIdAsync({ mode: 'fingerprint' }).catch(async () => {
|
|
46319
|
-
logger$
|
|
46099
|
+
logger$g.debug('direct_admission_fingerprint_generation_failed', {
|
|
46320
46100
|
reason: 'falling back to random id',
|
|
46321
46101
|
});
|
|
46322
46102
|
return generateIdAsync({ mode: 'random' });
|
|
@@ -46338,7 +46118,7 @@
|
|
|
46338
46118
|
const envelope = createFameEnvelope({
|
|
46339
46119
|
frame: welcomeFrame,
|
|
46340
46120
|
});
|
|
46341
|
-
logger$
|
|
46121
|
+
logger$g.debug('direct_admission_hello_success', {
|
|
46342
46122
|
systemId: welcomeFrame.systemId,
|
|
46343
46123
|
instanceId: welcomeFrame.instanceId,
|
|
46344
46124
|
acceptedLogicals: welcomeFrame.acceptedLogicals,
|
|
@@ -46515,7 +46295,7 @@
|
|
|
46515
46295
|
default: NoAuthInjectionStrategyFactory
|
|
46516
46296
|
});
|
|
46517
46297
|
|
|
46518
|
-
const logger$
|
|
46298
|
+
const logger$f = getLogger('naylence.fame.node.admission.welcome_service_client');
|
|
46519
46299
|
class WelcomeServiceClient {
|
|
46520
46300
|
constructor(options) {
|
|
46521
46301
|
this.hasUpstream = options.hasUpstream ?? options.has_upstream ?? false;
|
|
@@ -46564,7 +46344,7 @@
|
|
|
46564
46344
|
'Content-Type': 'application/json',
|
|
46565
46345
|
...authHeaders,
|
|
46566
46346
|
};
|
|
46567
|
-
logger$
|
|
46347
|
+
logger$f.debug('welcome_service_hello_request', {
|
|
46568
46348
|
url: this.url,
|
|
46569
46349
|
systemId,
|
|
46570
46350
|
instanceId,
|
|
@@ -46600,7 +46380,7 @@
|
|
|
46600
46380
|
parsedEnvelope.frame.type !== 'NodeWelcome') {
|
|
46601
46381
|
throw new Error(`Unexpected frame type '${parsedEnvelope.frame?.type ?? 'unknown'}'`);
|
|
46602
46382
|
}
|
|
46603
|
-
logger$
|
|
46383
|
+
logger$f.debug('welcome_service_hello_success', {
|
|
46604
46384
|
systemId: parsedEnvelope.frame.systemId,
|
|
46605
46385
|
targetSystemId: parsedEnvelope.frame.targetSystemId,
|
|
46606
46386
|
assignedPath: parsedEnvelope.frame.assignedPath,
|
|
@@ -47732,7 +47512,7 @@
|
|
|
47732
47512
|
default: NoopTokenVerifierFactory
|
|
47733
47513
|
});
|
|
47734
47514
|
|
|
47735
|
-
const logger$
|
|
47515
|
+
const logger$e = getLogger('naylence.fame.security.auth.oauth2_authorizer_factory');
|
|
47736
47516
|
let oauth2AuthorizerModulePromise = null;
|
|
47737
47517
|
function getOAuth2AuthorizerModule() {
|
|
47738
47518
|
if (!oauth2AuthorizerModulePromise) {
|
|
@@ -47759,12 +47539,12 @@
|
|
|
47759
47539
|
if (normalized.tokenIssuerConfig) {
|
|
47760
47540
|
try {
|
|
47761
47541
|
tokenIssuer = await TokenIssuerFactory.createTokenIssuer(normalized.tokenIssuerConfig);
|
|
47762
|
-
logger$
|
|
47542
|
+
logger$e.debug('token_issuer_created_for_reverse_auth', {
|
|
47763
47543
|
issuer_type: normalized.tokenIssuerConfig.type,
|
|
47764
47544
|
});
|
|
47765
47545
|
}
|
|
47766
47546
|
catch (error) {
|
|
47767
|
-
logger$
|
|
47547
|
+
logger$e.warning('failed_to_create_token_issuer_for_reverse_auth', {
|
|
47768
47548
|
error: error instanceof Error ? error.message : String(error),
|
|
47769
47549
|
issuer_config: normalized.tokenIssuerConfig,
|
|
47770
47550
|
});
|
|
@@ -48717,7 +48497,7 @@
|
|
|
48717
48497
|
normalizeSessionKeyConfig: normalizeSessionKeyConfig
|
|
48718
48498
|
});
|
|
48719
48499
|
|
|
48720
|
-
const logger$
|
|
48500
|
+
const logger$d = getLogger('naylence.fame.security.default_security_manager_factory');
|
|
48721
48501
|
function normalizeDefaultSecurityManagerConfig(config) {
|
|
48722
48502
|
if (!config) {
|
|
48723
48503
|
return null;
|
|
@@ -48885,7 +48665,7 @@
|
|
|
48885
48665
|
return await KeyStoreFactory.createKeyStore(value, createOptions ?? undefined);
|
|
48886
48666
|
}
|
|
48887
48667
|
catch (error) {
|
|
48888
|
-
logger$
|
|
48668
|
+
logger$d.error('failed_to_create_key_store_from_config', {
|
|
48889
48669
|
error: error instanceof Error ? error.message : String(error),
|
|
48890
48670
|
});
|
|
48891
48671
|
return null;
|
|
@@ -48921,7 +48701,7 @@
|
|
|
48921
48701
|
return null;
|
|
48922
48702
|
}
|
|
48923
48703
|
const cryptoProvider = cryptoProviderOverride ?? null;
|
|
48924
|
-
logger$
|
|
48704
|
+
logger$d.debug('auto_create_envelope_signer', {
|
|
48925
48705
|
has_crypto_override: Boolean(cryptoProviderOverride),
|
|
48926
48706
|
override_constructor: cryptoProviderOverride
|
|
48927
48707
|
? (cryptoProviderOverride.constructor?.name ?? 'unknown')
|
|
@@ -48942,7 +48722,7 @@
|
|
|
48942
48722
|
});
|
|
48943
48723
|
}
|
|
48944
48724
|
catch (error) {
|
|
48945
|
-
logger$
|
|
48725
|
+
logger$d.error('failed_to_auto_create_envelope_signer', {
|
|
48946
48726
|
error: error instanceof Error ? error.message : String(error),
|
|
48947
48727
|
exc_info: true,
|
|
48948
48728
|
});
|
|
@@ -48977,7 +48757,7 @@
|
|
|
48977
48757
|
});
|
|
48978
48758
|
}
|
|
48979
48759
|
catch (error) {
|
|
48980
|
-
logger$
|
|
48760
|
+
logger$d.error('failed_to_auto_create_envelope_verifier', {
|
|
48981
48761
|
error: error instanceof Error ? error.message : String(error),
|
|
48982
48762
|
exc_info: true,
|
|
48983
48763
|
});
|
|
@@ -48989,7 +48769,7 @@
|
|
|
48989
48769
|
if (encryptionConfig &&
|
|
48990
48770
|
DefaultSecurityManagerFactory.isConfigLike(encryptionConfig)) {
|
|
48991
48771
|
if (!keyManager) {
|
|
48992
|
-
logger$
|
|
48772
|
+
logger$d.warning('encryption_manager_config_requires_key_manager');
|
|
48993
48773
|
return { encryptionManager: null, secureChannelManager };
|
|
48994
48774
|
}
|
|
48995
48775
|
const manager = await EncryptionManagerFactory.createEncryptionManager(encryptionConfig, {
|
|
@@ -49026,7 +48806,7 @@
|
|
|
49026
48806
|
return { encryptionManager: manager, secureChannelManager };
|
|
49027
48807
|
}
|
|
49028
48808
|
catch (error) {
|
|
49029
|
-
logger$
|
|
48809
|
+
logger$d.error('failed_to_auto_create_encryption_manager', {
|
|
49030
48810
|
error: error instanceof Error ? error.message : String(error),
|
|
49031
48811
|
exc_info: true,
|
|
49032
48812
|
});
|
|
@@ -49069,7 +48849,7 @@
|
|
|
49069
48849
|
});
|
|
49070
48850
|
}
|
|
49071
48851
|
catch (error) {
|
|
49072
|
-
logger$
|
|
48852
|
+
logger$d.error('failed_to_auto_create_key_manager', {
|
|
49073
48853
|
error: error instanceof Error ? error.message : String(error),
|
|
49074
48854
|
exc_info: true,
|
|
49075
48855
|
});
|
|
@@ -49118,7 +48898,7 @@
|
|
|
49118
48898
|
})) ?? null);
|
|
49119
48899
|
}
|
|
49120
48900
|
catch (error) {
|
|
49121
|
-
logger$
|
|
48901
|
+
logger$d.error('failed_to_auto_create_authorizer', {
|
|
49122
48902
|
error: error instanceof Error ? error.message : String(error),
|
|
49123
48903
|
exc_info: true,
|
|
49124
48904
|
});
|
|
@@ -49147,7 +48927,7 @@
|
|
|
49147
48927
|
});
|
|
49148
48928
|
}
|
|
49149
48929
|
catch (error) {
|
|
49150
|
-
logger$
|
|
48930
|
+
logger$d.error('failed_to_auto_create_certificate_manager', {
|
|
49151
48931
|
error: error instanceof Error ? error.message : String(error),
|
|
49152
48932
|
exc_info: true,
|
|
49153
48933
|
});
|
|
@@ -49405,7 +49185,7 @@
|
|
|
49405
49185
|
default: DefaultKeyManagerFactory
|
|
49406
49186
|
});
|
|
49407
49187
|
|
|
49408
|
-
const logger$
|
|
49188
|
+
const logger$c = getLogger('naylence.fame.security.keys.in_memory_key_store');
|
|
49409
49189
|
class InMemoryKeyStore extends KeyStore {
|
|
49410
49190
|
constructor(initialKeys = null) {
|
|
49411
49191
|
super();
|
|
@@ -49427,7 +49207,7 @@
|
|
|
49427
49207
|
}
|
|
49428
49208
|
catch (error) {
|
|
49429
49209
|
if (error instanceof JWKValidationError) {
|
|
49430
|
-
logger$
|
|
49210
|
+
logger$c.warning('rejected_invalid_jwk_individual', {
|
|
49431
49211
|
kid,
|
|
49432
49212
|
error: error.message,
|
|
49433
49213
|
});
|
|
@@ -49471,7 +49251,7 @@
|
|
|
49471
49251
|
}
|
|
49472
49252
|
}
|
|
49473
49253
|
if (staleKeys.length > 0) {
|
|
49474
|
-
logger$
|
|
49254
|
+
logger$c.debug('removing_stale_keys_before_adding_new_key', {
|
|
49475
49255
|
new_kid: kid,
|
|
49476
49256
|
physical_path: physicalPath,
|
|
49477
49257
|
base_path: basePath,
|
|
@@ -49499,7 +49279,7 @@
|
|
|
49499
49279
|
}
|
|
49500
49280
|
keysByPath[path].push(existingKid);
|
|
49501
49281
|
}
|
|
49502
|
-
logger$
|
|
49282
|
+
logger$c.debug('key_lookup_failed', {
|
|
49503
49283
|
missing_kid: kid,
|
|
49504
49284
|
available_kids: Array.from(this.keys.keys()),
|
|
49505
49285
|
keys_by_path: keysByPath,
|
|
@@ -49548,7 +49328,7 @@
|
|
|
49548
49328
|
this.keys.delete(kid);
|
|
49549
49329
|
}
|
|
49550
49330
|
if (keysToRemove.length > 0) {
|
|
49551
|
-
logger$
|
|
49331
|
+
logger$c.debug('removed_keys_for_path', {
|
|
49552
49332
|
physical_path: physicalPath,
|
|
49553
49333
|
removed_key_ids: keysToRemove,
|
|
49554
49334
|
count: keysToRemove.length,
|
|
@@ -49559,7 +49339,7 @@
|
|
|
49559
49339
|
async removeKey(kid) {
|
|
49560
49340
|
const removed = this.keys.delete(kid);
|
|
49561
49341
|
if (removed) {
|
|
49562
|
-
logger$
|
|
49342
|
+
logger$c.debug('removed_individual_key', { kid });
|
|
49563
49343
|
}
|
|
49564
49344
|
return removed;
|
|
49565
49345
|
}
|
|
@@ -49925,7 +49705,7 @@
|
|
|
49925
49705
|
default: CapabilityAwareRoutingPolicyFactory
|
|
49926
49706
|
});
|
|
49927
49707
|
|
|
49928
|
-
const logger$
|
|
49708
|
+
const logger$b = getLogger('naylence.fame.sentinel.composite_routing_policy_factory');
|
|
49929
49709
|
const FACTORY_META$8 = {
|
|
49930
49710
|
base: ROUTING_POLICY_FACTORY_BASE,
|
|
49931
49711
|
key: 'CompositeRoutingPolicy',
|
|
@@ -49951,13 +49731,13 @@
|
|
|
49951
49731
|
policies.push(policy);
|
|
49952
49732
|
}
|
|
49953
49733
|
else {
|
|
49954
|
-
logger$
|
|
49734
|
+
logger$b.warning('composite_policy_null_child', {
|
|
49955
49735
|
config: policyConfig,
|
|
49956
49736
|
});
|
|
49957
49737
|
}
|
|
49958
49738
|
}
|
|
49959
49739
|
catch (error) {
|
|
49960
|
-
logger$
|
|
49740
|
+
logger$b.warning('composite_policy_child_error', {
|
|
49961
49741
|
error: error instanceof Error ? error.message : String(error),
|
|
49962
49742
|
config: policyConfig,
|
|
49963
49743
|
});
|
|
@@ -50253,7 +50033,7 @@
|
|
|
50253
50033
|
default: HRWLoadBalancingStrategyFactory
|
|
50254
50034
|
});
|
|
50255
50035
|
|
|
50256
|
-
const logger$
|
|
50036
|
+
const logger$a = getLogger('naylence.fame.sentinel.load_balancing.load_balancing_profile_factory');
|
|
50257
50037
|
const PROFILE_NAME_RANDOM = 'random';
|
|
50258
50038
|
const PROFILE_NAME_ROUND_ROBIN = 'round_robin';
|
|
50259
50039
|
const PROFILE_NAME_HRW = 'hrw';
|
|
@@ -50287,7 +50067,7 @@
|
|
|
50287
50067
|
async create(config, ...factoryArgs) {
|
|
50288
50068
|
const finalConfig = this.normalizeConfig(config);
|
|
50289
50069
|
const profileName = finalConfig.profile ?? PROFILE_NAME_DEVELOPMENT$1;
|
|
50290
|
-
logger$
|
|
50070
|
+
logger$a.debug('enabling_load_balancing_profile', { profile: profileName });
|
|
50291
50071
|
const strategyConfig = this.resolveProfile(profileName);
|
|
50292
50072
|
const strategy = await createResource$1(LOAD_BALANCING_STRATEGY_FACTORY_BASE, strategyConfig, { factoryArgs });
|
|
50293
50073
|
if (!strategy) {
|
|
@@ -50478,7 +50258,7 @@
|
|
|
50478
50258
|
default: StickyLoadBalancingStrategyFactory
|
|
50479
50259
|
});
|
|
50480
50260
|
|
|
50481
|
-
const logger$
|
|
50261
|
+
const logger$9 = getLogger('naylence.fame.sentinel.routing_profile_factory');
|
|
50482
50262
|
const PROFILE_NAME_DEVELOPMENT = 'development';
|
|
50483
50263
|
const PROFILE_NAME_PRODUCTION = 'production';
|
|
50484
50264
|
const PROFILE_NAME_BASIC = 'basic';
|
|
@@ -50529,7 +50309,7 @@
|
|
|
50529
50309
|
}
|
|
50530
50310
|
async create(config, ...kwargs) {
|
|
50531
50311
|
const normalized = this.normalizeConfig(config);
|
|
50532
|
-
logger$
|
|
50312
|
+
logger$9.debug('enabling_routing_profile', { profile: normalized.profile });
|
|
50533
50313
|
const routingConfig = this.getProfileConfig(normalized.profile);
|
|
50534
50314
|
const policy = await createResource$1(ROUTING_POLICY_FACTORY_BASE, routingConfig, {
|
|
50535
50315
|
factoryArgs: kwargs,
|
|
@@ -50825,21 +50605,21 @@
|
|
|
50825
50605
|
}
|
|
50826
50606
|
function normalizeOpenTelemetryTraceEmitterOptions(input) {
|
|
50827
50607
|
const source = (input ?? {});
|
|
50828
|
-
const serviceName = extractNonEmptyString(pickFirst(source, ['serviceName', 'service_name'])) ?? 'naylence-service';
|
|
50829
|
-
const tracer = pickFirst(source, ['tracer']);
|
|
50830
|
-
const otelApi = pickFirst(source, [
|
|
50608
|
+
const serviceName = extractNonEmptyString$1(pickFirst$1(source, ['serviceName', 'service_name'])) ?? 'naylence-service';
|
|
50609
|
+
const tracer = pickFirst$1(source, ['tracer']);
|
|
50610
|
+
const otelApi = pickFirst$1(source, [
|
|
50831
50611
|
'otelApi',
|
|
50832
50612
|
'otel_api',
|
|
50833
50613
|
]);
|
|
50834
50614
|
if (!otelApi) {
|
|
50835
50615
|
throw new Error('OpenTelemetryTraceEmitter requires OpenTelemetry API bindings. Provide otelApi via options.');
|
|
50836
50616
|
}
|
|
50837
|
-
const lifecycle = pickFirst(source, [
|
|
50617
|
+
const lifecycle = pickFirst$1(source, [
|
|
50838
50618
|
'lifecycle',
|
|
50839
50619
|
'lifeCycle',
|
|
50840
50620
|
'life_cycle',
|
|
50841
50621
|
]) ?? null;
|
|
50842
|
-
const authStrategy = pickFirst(source, [
|
|
50622
|
+
const authStrategy = pickFirst$1(source, [
|
|
50843
50623
|
'authStrategy',
|
|
50844
50624
|
'auth_strategy',
|
|
50845
50625
|
]) ?? null;
|
|
@@ -50851,7 +50631,7 @@
|
|
|
50851
50631
|
authStrategy,
|
|
50852
50632
|
};
|
|
50853
50633
|
}
|
|
50854
|
-
function pickFirst(source, keys) {
|
|
50634
|
+
function pickFirst$1(source, keys) {
|
|
50855
50635
|
for (const key of keys) {
|
|
50856
50636
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
50857
50637
|
const value = source[key];
|
|
@@ -50862,7 +50642,7 @@
|
|
|
50862
50642
|
}
|
|
50863
50643
|
return undefined;
|
|
50864
50644
|
}
|
|
50865
|
-
function extractNonEmptyString(value) {
|
|
50645
|
+
function extractNonEmptyString$1(value) {
|
|
50866
50646
|
if (typeof value === 'string') {
|
|
50867
50647
|
const trimmed = value.trim();
|
|
50868
50648
|
if (trimmed.length > 0) {
|
|
@@ -50915,6 +50695,241 @@
|
|
|
50915
50695
|
OpenTelemetryTraceEmitter: OpenTelemetryTraceEmitter
|
|
50916
50696
|
});
|
|
50917
50697
|
|
|
50698
|
+
const logger$8 = getLogger('naylence.fame.telemetry.otel_setup');
|
|
50699
|
+
const stringFrom = (...codes) => String.fromCharCode(...codes);
|
|
50700
|
+
const OTEL_PREFIX = `${stringFrom(64, 111, 112, 101, 110, 116, 101, 108, 101, 109, 101, 116, 114, 121)}${stringFrom(47)}`;
|
|
50701
|
+
const OTEL_API_SPEC = `${OTEL_PREFIX}${stringFrom(97, 112, 105)}`;
|
|
50702
|
+
const OTEL_RESOURCES_SPEC = `${OTEL_PREFIX}${stringFrom(114, 101, 115, 111, 117, 114, 99, 101, 115)}`;
|
|
50703
|
+
const OTEL_TRACE_NODE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 110, 111, 100, 101)}`;
|
|
50704
|
+
const OTEL_TRACE_BASE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 98, 97, 115, 101)}`;
|
|
50705
|
+
const OTEL_EXPORTER_HTTP_SPEC = `${OTEL_PREFIX}${stringFrom(101, 120, 112, 111, 114, 116, 101, 114, 45, 116, 114, 97, 99, 101, 45, 111, 116, 108, 112, 45, 104, 116, 116, 112)}`;
|
|
50706
|
+
let registeredOtel = null;
|
|
50707
|
+
async function setupOtel(options) {
|
|
50708
|
+
const normalized = normalizeSetupOtelOptions(options);
|
|
50709
|
+
try {
|
|
50710
|
+
if (registeredOtel) {
|
|
50711
|
+
logger$8.debug('open_telemetry_reusing_provider', {
|
|
50712
|
+
service_name: normalized.serviceName,
|
|
50713
|
+
});
|
|
50714
|
+
return registeredOtel.control;
|
|
50715
|
+
}
|
|
50716
|
+
const [apiModule, resourcesModule, nodeModule, traceBaseModule] = await Promise.all([
|
|
50717
|
+
import(OTEL_API_SPEC),
|
|
50718
|
+
import(OTEL_RESOURCES_SPEC),
|
|
50719
|
+
import(OTEL_TRACE_NODE_SPEC),
|
|
50720
|
+
import(OTEL_TRACE_BASE_SPEC),
|
|
50721
|
+
]);
|
|
50722
|
+
const { trace } = apiModule;
|
|
50723
|
+
const { defaultResource, resourceFromAttributes } = resourcesModule;
|
|
50724
|
+
const { NodeTracerProvider } = nodeModule;
|
|
50725
|
+
const { BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, AlwaysOnSampler, AlwaysOffSampler, TraceIdRatioBasedSampler, } = traceBaseModule;
|
|
50726
|
+
const currentProvider = trace.getTracerProvider();
|
|
50727
|
+
if (currentProvider && currentProvider instanceof NodeTracerProvider) {
|
|
50728
|
+
return null;
|
|
50729
|
+
}
|
|
50730
|
+
if (currentProvider &&
|
|
50731
|
+
currentProvider.constructor?.name === 'NodeTracerProvider') {
|
|
50732
|
+
logger$8.debug('open_telemetry_existing_node_provider', {
|
|
50733
|
+
service_name: normalized.serviceName,
|
|
50734
|
+
});
|
|
50735
|
+
return null;
|
|
50736
|
+
}
|
|
50737
|
+
logger$8.debug('open_telemetry_initializing', {
|
|
50738
|
+
service_name: normalized.serviceName,
|
|
50739
|
+
endpoint: normalized.endpoint ?? null,
|
|
50740
|
+
environment: normalized.environment ?? null,
|
|
50741
|
+
sampler: normalized.sampler ?? null,
|
|
50742
|
+
headers_present: Boolean(normalized.headers && Object.keys(normalized.headers).length),
|
|
50743
|
+
});
|
|
50744
|
+
const sampler = resolveSampler(normalized.sampler, {
|
|
50745
|
+
ParentBasedSampler,
|
|
50746
|
+
AlwaysOnSampler,
|
|
50747
|
+
AlwaysOffSampler,
|
|
50748
|
+
TraceIdRatioBasedSampler,
|
|
50749
|
+
});
|
|
50750
|
+
const baseResource = defaultResource();
|
|
50751
|
+
const mergedResource = resourceFromAttributes({
|
|
50752
|
+
'service.name': normalized.serviceName,
|
|
50753
|
+
'service.instance.id': generateInstanceId(),
|
|
50754
|
+
'deployment.environment': normalized.environment ?? 'dev',
|
|
50755
|
+
});
|
|
50756
|
+
const resource = baseResource.merge(mergedResource);
|
|
50757
|
+
const exporter = await resolveExporter(normalized.endpoint ?? undefined, normalized.headers, ConsoleSpanExporter);
|
|
50758
|
+
const spanProcessor = new BatchSpanProcessor(exporter);
|
|
50759
|
+
const provider = new NodeTracerProvider({
|
|
50760
|
+
resource,
|
|
50761
|
+
sampler,
|
|
50762
|
+
spanProcessors: [spanProcessor],
|
|
50763
|
+
});
|
|
50764
|
+
provider.register();
|
|
50765
|
+
logger$8.debug('open_telemetry_initialized', {
|
|
50766
|
+
service_name: normalized.serviceName,
|
|
50767
|
+
exporter: exporter.constructor?.name ?? 'unknown_exporter',
|
|
50768
|
+
});
|
|
50769
|
+
const control = {
|
|
50770
|
+
forceFlush: async () => {
|
|
50771
|
+
try {
|
|
50772
|
+
await provider.forceFlush();
|
|
50773
|
+
}
|
|
50774
|
+
catch (flushError) {
|
|
50775
|
+
logger$8.warning('open_telemetry_force_flush_failed', {
|
|
50776
|
+
error: flushError instanceof Error
|
|
50777
|
+
? flushError.message
|
|
50778
|
+
: String(flushError),
|
|
50779
|
+
});
|
|
50780
|
+
}
|
|
50781
|
+
},
|
|
50782
|
+
shutdown: async () => {
|
|
50783
|
+
try {
|
|
50784
|
+
await provider.shutdown();
|
|
50785
|
+
}
|
|
50786
|
+
catch (shutdownError) {
|
|
50787
|
+
logger$8.warning('open_telemetry_shutdown_failed', {
|
|
50788
|
+
error: shutdownError instanceof Error
|
|
50789
|
+
? shutdownError.message
|
|
50790
|
+
: String(shutdownError),
|
|
50791
|
+
});
|
|
50792
|
+
}
|
|
50793
|
+
finally {
|
|
50794
|
+
registeredOtel = null;
|
|
50795
|
+
}
|
|
50796
|
+
},
|
|
50797
|
+
};
|
|
50798
|
+
registeredOtel = {
|
|
50799
|
+
provider,
|
|
50800
|
+
control,
|
|
50801
|
+
};
|
|
50802
|
+
return control;
|
|
50803
|
+
}
|
|
50804
|
+
catch (error) {
|
|
50805
|
+
logger$8.error('open_telemetry_not_available', {
|
|
50806
|
+
error: error instanceof Error ? error.message : String(error),
|
|
50807
|
+
stack: error instanceof Error && error.stack ? error.stack : undefined,
|
|
50808
|
+
});
|
|
50809
|
+
return null;
|
|
50810
|
+
}
|
|
50811
|
+
}
|
|
50812
|
+
function normalizeSetupOtelOptions(options) {
|
|
50813
|
+
const source = (options ?? {});
|
|
50814
|
+
const serviceName = extractNonEmptyString(pickFirst(source, ['serviceName', 'service_name'])) ??
|
|
50815
|
+
'naylence-service';
|
|
50816
|
+
const endpoint = extractNonEmptyString(pickFirst(source, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
50817
|
+
const environment = extractNonEmptyString(pickFirst(source, [
|
|
50818
|
+
'environment',
|
|
50819
|
+
'deploymentEnvironment',
|
|
50820
|
+
'deployment_environment',
|
|
50821
|
+
])) ?? null;
|
|
50822
|
+
const sampler = extractNonEmptyString(pickFirst(source, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
50823
|
+
const headers = extractHeaders(pickFirst(source, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
50824
|
+
return {
|
|
50825
|
+
serviceName,
|
|
50826
|
+
endpoint,
|
|
50827
|
+
environment,
|
|
50828
|
+
sampler,
|
|
50829
|
+
headers: headers ?? undefined,
|
|
50830
|
+
};
|
|
50831
|
+
}
|
|
50832
|
+
function pickFirst(source, keys) {
|
|
50833
|
+
for (const key of keys) {
|
|
50834
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
50835
|
+
const value = source[key];
|
|
50836
|
+
if (value !== undefined) {
|
|
50837
|
+
return value;
|
|
50838
|
+
}
|
|
50839
|
+
}
|
|
50840
|
+
}
|
|
50841
|
+
return undefined;
|
|
50842
|
+
}
|
|
50843
|
+
function extractNonEmptyString(value) {
|
|
50844
|
+
if (typeof value === 'string') {
|
|
50845
|
+
const trimmed = value.trim();
|
|
50846
|
+
if (trimmed.length > 0) {
|
|
50847
|
+
return trimmed;
|
|
50848
|
+
}
|
|
50849
|
+
}
|
|
50850
|
+
return undefined;
|
|
50851
|
+
}
|
|
50852
|
+
function extractHeaders(value) {
|
|
50853
|
+
if (!value || typeof value !== 'object') {
|
|
50854
|
+
return null;
|
|
50855
|
+
}
|
|
50856
|
+
const headers = {};
|
|
50857
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
50858
|
+
if (typeof raw === 'string') {
|
|
50859
|
+
headers[key] = raw;
|
|
50860
|
+
}
|
|
50861
|
+
}
|
|
50862
|
+
return Object.keys(headers).length > 0 ? headers : null;
|
|
50863
|
+
}
|
|
50864
|
+
function generateInstanceId() {
|
|
50865
|
+
try {
|
|
50866
|
+
if (typeof crypto !== 'undefined' &&
|
|
50867
|
+
typeof crypto.randomUUID === 'function') {
|
|
50868
|
+
return crypto.randomUUID().replace(/-/g, '');
|
|
50869
|
+
}
|
|
50870
|
+
}
|
|
50871
|
+
catch {
|
|
50872
|
+
// Ignore crypto availability errors
|
|
50873
|
+
}
|
|
50874
|
+
const random = Math.random().toString(16).slice(2);
|
|
50875
|
+
return random.padEnd(32, '0').slice(0, 32);
|
|
50876
|
+
}
|
|
50877
|
+
function resolveSampler(samplerSetting, samplers) {
|
|
50878
|
+
const normalized = (samplerSetting ?? 'parentbased_always_on').toLowerCase();
|
|
50879
|
+
let base;
|
|
50880
|
+
if (normalized === 'always_off') {
|
|
50881
|
+
base = new samplers.AlwaysOffSampler();
|
|
50882
|
+
}
|
|
50883
|
+
else if (normalized === 'always_on' ||
|
|
50884
|
+
normalized === 'parentbased_always_on') {
|
|
50885
|
+
base = new samplers.AlwaysOnSampler();
|
|
50886
|
+
}
|
|
50887
|
+
else if (normalized.startsWith('ratio:')) {
|
|
50888
|
+
const ratioValue = Number.parseFloat(normalized.slice('ratio:'.length));
|
|
50889
|
+
const ratio = Number.isFinite(ratioValue)
|
|
50890
|
+
? Math.min(Math.max(ratioValue, 0), 1)
|
|
50891
|
+
: 1;
|
|
50892
|
+
base = new samplers.TraceIdRatioBasedSampler(ratio);
|
|
50893
|
+
}
|
|
50894
|
+
else {
|
|
50895
|
+
base = new samplers.AlwaysOnSampler();
|
|
50896
|
+
}
|
|
50897
|
+
return new samplers.ParentBasedSampler({ root: base });
|
|
50898
|
+
}
|
|
50899
|
+
async function resolveExporter(endpoint, headers, ConsoleSpanExporter) {
|
|
50900
|
+
if (endpoint) {
|
|
50901
|
+
try {
|
|
50902
|
+
const exporterModule = await import(OTEL_EXPORTER_HTTP_SPEC);
|
|
50903
|
+
if ('OTLPTraceExporter' in exporterModule) {
|
|
50904
|
+
const { OTLPTraceExporter } = exporterModule;
|
|
50905
|
+
const exporterOptions = {
|
|
50906
|
+
url: endpoint,
|
|
50907
|
+
};
|
|
50908
|
+
if (headers && Object.keys(headers).length > 0) {
|
|
50909
|
+
exporterOptions.headers = headers;
|
|
50910
|
+
}
|
|
50911
|
+
logger$8.debug('open_telemetry_using_otlp_http_exporter', {
|
|
50912
|
+
endpoint,
|
|
50913
|
+
headers_present: Boolean(headers && Object.keys(headers).length),
|
|
50914
|
+
});
|
|
50915
|
+
return new OTLPTraceExporter(exporterOptions);
|
|
50916
|
+
}
|
|
50917
|
+
}
|
|
50918
|
+
catch (error) {
|
|
50919
|
+
logger$8.error('open_telemetry_exporter_not_available', {
|
|
50920
|
+
error: error instanceof Error ? error.message : String(error),
|
|
50921
|
+
});
|
|
50922
|
+
}
|
|
50923
|
+
}
|
|
50924
|
+
logger$8.warning('open_telemetry_falling_back_to_console_exporter');
|
|
50925
|
+
return new ConsoleSpanExporter();
|
|
50926
|
+
}
|
|
50927
|
+
|
|
50928
|
+
var otelSetup = /*#__PURE__*/Object.freeze({
|
|
50929
|
+
__proto__: null,
|
|
50930
|
+
setupOtel: setupOtel
|
|
50931
|
+
});
|
|
50932
|
+
|
|
50918
50933
|
const logger$7 = getLogger('naylence.fame.connector.default_http_server');
|
|
50919
50934
|
function makeKey(host, port) {
|
|
50920
50935
|
return `${host}:${port}`;
|