neatlogs 1.1.21 → 1.1.23
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 +12 -9
- package/dist/ai-sdk.cjs +153 -24
- package/dist/ai-sdk.cjs.map +1 -1
- package/dist/ai-sdk.d.ts +30 -6
- package/dist/ai-sdk.mjs +153 -24
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/cli.cjs +25 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +25 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +181 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +181 -35
- package/dist/index.mjs.map +1 -1
- package/dist/opencode-plugin.cjs +1 -1
- package/dist/opencode-plugin.cjs.map +1 -1
- package/dist/opencode-plugin.mjs +1 -1
- package/dist/opencode-plugin.mjs.map +1 -1
- package/package.json +15 -3
package/dist/index.cjs
CHANGED
|
@@ -1742,6 +1742,19 @@ var UnifiedAttributeProcessor = class {
|
|
|
1742
1742
|
attrs["llm.output_messages.0.message.role"] = "assistant";
|
|
1743
1743
|
attrs["llm.output_messages.0.message.content"] = typeof obj === "string" ? obj : JSON.stringify(obj);
|
|
1744
1744
|
}
|
|
1745
|
+
const responseReasoning = attrs["ai.response.reasoning"];
|
|
1746
|
+
if (typeof responseReasoning === "string" && responseReasoning.length > 0 && !("neatlogs.llm.output_messages.0.thinking" in attrs)) {
|
|
1747
|
+
attrs["neatlogs.llm.output_messages.0.thinking"] = responseReasoning;
|
|
1748
|
+
}
|
|
1749
|
+
const thinking = attrs["neatlogs.llm.output_messages.0.thinking"];
|
|
1750
|
+
if (typeof thinking === "string" && thinking.length > 0) {
|
|
1751
|
+
if (!("neatlogs.llm.thinking" in attrs)) {
|
|
1752
|
+
attrs["neatlogs.llm.thinking"] = thinking;
|
|
1753
|
+
}
|
|
1754
|
+
if (!("neatlogs.llm.has_thinking" in attrs)) {
|
|
1755
|
+
attrs["neatlogs.llm.has_thinking"] = "true";
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1745
1758
|
if ("ai.response.finishReason" in attrs && !("llm.response.finish_reason" in attrs)) {
|
|
1746
1759
|
attrs["llm.response.finish_reason"] = attrs["ai.response.finishReason"];
|
|
1747
1760
|
}
|
|
@@ -8494,16 +8507,20 @@ var ObservableBatchLogRecordProcessor = class extends import_sdk_logs.BatchLogRe
|
|
|
8494
8507
|
// src/core/log.ts
|
|
8495
8508
|
var import_node_async_hooks5 = require("async_hooks");
|
|
8496
8509
|
var logger12 = getLogger();
|
|
8497
|
-
var
|
|
8498
|
-
var
|
|
8510
|
+
var LOG_RUNTIME_STATE_KEY = /* @__PURE__ */ Symbol.for("neatlogs.log_runtime_state");
|
|
8511
|
+
var neatlogsGlobal3 = globalThis;
|
|
8512
|
+
var logRuntimeState = neatlogsGlobal3[LOG_RUNTIME_STATE_KEY] ?? (neatlogsGlobal3[LOG_RUNTIME_STATE_KEY] = {
|
|
8513
|
+
otelLogger: null,
|
|
8514
|
+
debugMode: false
|
|
8515
|
+
});
|
|
8499
8516
|
var stdoutCaptureContext = new import_node_async_hooks5.AsyncLocalStorage();
|
|
8500
8517
|
function resolveOtelLogger() {
|
|
8501
8518
|
const client = getActiveClient();
|
|
8502
|
-
return client ? client.getLogger() :
|
|
8519
|
+
return client ? client.getLogger() : logRuntimeState.otelLogger;
|
|
8503
8520
|
}
|
|
8504
8521
|
function _setOtelLogger(otelLogger, debug) {
|
|
8505
|
-
|
|
8506
|
-
|
|
8522
|
+
logRuntimeState.otelLogger = otelLogger;
|
|
8523
|
+
logRuntimeState.debugMode = debug;
|
|
8507
8524
|
}
|
|
8508
8525
|
function log(msgTemplate, options) {
|
|
8509
8526
|
const { level = "info", ...variables } = options ?? {};
|
|
@@ -8511,7 +8528,7 @@ function log(msgTemplate, options) {
|
|
|
8511
8528
|
for (const [key, value] of Object.entries(variables)) {
|
|
8512
8529
|
rendered = rendered.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
|
|
8513
8530
|
}
|
|
8514
|
-
if (
|
|
8531
|
+
if (logRuntimeState.debugMode) {
|
|
8515
8532
|
console.log(`[neatlogs:log] ${rendered}`);
|
|
8516
8533
|
}
|
|
8517
8534
|
const otelLogger = resolveOtelLogger();
|
|
@@ -9376,7 +9393,7 @@ function _resetMastraCache() {
|
|
|
9376
9393
|
}
|
|
9377
9394
|
|
|
9378
9395
|
// src/version.ts
|
|
9379
|
-
var __version__ = "1.1.
|
|
9396
|
+
var __version__ = "1.1.23";
|
|
9380
9397
|
|
|
9381
9398
|
// src/core/deadline.ts
|
|
9382
9399
|
async function runByDeadline(operation, deadlineMs) {
|
|
@@ -9412,7 +9429,7 @@ var _logProvider = null;
|
|
|
9412
9429
|
var _spanProcessor = null;
|
|
9413
9430
|
var _transportSpanProcessors = [];
|
|
9414
9431
|
var _completionProcessor = null;
|
|
9415
|
-
var
|
|
9432
|
+
var _debugMode = false;
|
|
9416
9433
|
var _deliveryDiagnostics = new DeliveryDiagnostics();
|
|
9417
9434
|
var _initIdentity = null;
|
|
9418
9435
|
var _effectiveSampleRate = 1;
|
|
@@ -9704,7 +9721,7 @@ async function _performInit(options) {
|
|
|
9704
9721
|
if (options.debug) {
|
|
9705
9722
|
enableDebugLogging();
|
|
9706
9723
|
}
|
|
9707
|
-
|
|
9724
|
+
_debugMode = options.debug ?? false;
|
|
9708
9725
|
const resolvedWorkflowName = _resolveWorkflowName(options.workflowName);
|
|
9709
9726
|
const endpoint = resolveInitEndpoint(options.endpoint);
|
|
9710
9727
|
const baseUrl = resolveIngestBaseUrl(endpoint);
|
|
@@ -10090,7 +10107,7 @@ async function _performShutdown(terminationReason, timeoutMs) {
|
|
|
10090
10107
|
_spanProcessor = null;
|
|
10091
10108
|
_transportSpanProcessors = [];
|
|
10092
10109
|
_completionProcessor = null;
|
|
10093
|
-
|
|
10110
|
+
_debugMode = false;
|
|
10094
10111
|
_effectiveSampleRate = 1;
|
|
10095
10112
|
_exportEnabled = false;
|
|
10096
10113
|
_queueMaxSize = 2048;
|
|
@@ -10102,7 +10119,7 @@ async function _performShutdown(terminationReason, timeoutMs) {
|
|
|
10102
10119
|
return success;
|
|
10103
10120
|
}
|
|
10104
10121
|
function isDebugEnabled() {
|
|
10105
|
-
return
|
|
10122
|
+
return _debugMode;
|
|
10106
10123
|
}
|
|
10107
10124
|
function _doctorRuntimeSnapshot() {
|
|
10108
10125
|
return {
|
|
@@ -10682,10 +10699,105 @@ function setHeader(carrier, name, value) {
|
|
|
10682
10699
|
// src/ai-sdk.ts
|
|
10683
10700
|
var import_api13 = require("@opentelemetry/api");
|
|
10684
10701
|
var TRACER_NAME2 = "neatlogs.ai-sdk";
|
|
10702
|
+
var NEATLOGS_V7_INTEGRATION = /* @__PURE__ */ Symbol("neatlogs.ai-sdk.v7-integration");
|
|
10703
|
+
var AI_SDK_OTEL_MODULE = "@ai-sdk/otel";
|
|
10704
|
+
var LazyV7OpenTelemetryIntegration = class {
|
|
10705
|
+
constructor(tracer, metadata) {
|
|
10706
|
+
this.tracer = tracer;
|
|
10707
|
+
this.metadata = metadata;
|
|
10708
|
+
}
|
|
10709
|
+
tracer;
|
|
10710
|
+
metadata;
|
|
10711
|
+
[NEATLOGS_V7_INTEGRATION] = true;
|
|
10712
|
+
delegatePromise;
|
|
10713
|
+
getDelegate() {
|
|
10714
|
+
return this.delegatePromise ??= import(AI_SDK_OTEL_MODULE).then(
|
|
10715
|
+
({ OpenTelemetry }) => new OpenTelemetry({
|
|
10716
|
+
tracer: this.tracer,
|
|
10717
|
+
enrichSpan: () => this.metadata
|
|
10718
|
+
})
|
|
10719
|
+
).catch((error) => {
|
|
10720
|
+
const detail = error instanceof Error ? `: ${error.message}` : "";
|
|
10721
|
+
throw new Error(
|
|
10722
|
+
"Vercel AI SDK v7 telemetry requires the optional @ai-sdk/otel peer dependency" + detail
|
|
10723
|
+
);
|
|
10724
|
+
});
|
|
10725
|
+
}
|
|
10726
|
+
async notify(method, event) {
|
|
10727
|
+
const delegate = await this.getDelegate();
|
|
10728
|
+
const fn = delegate[method];
|
|
10729
|
+
if (typeof fn === "function") {
|
|
10730
|
+
await Reflect.apply(fn, delegate, [event]);
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
10733
|
+
onStart(event) {
|
|
10734
|
+
return this.notify("onStart", event);
|
|
10735
|
+
}
|
|
10736
|
+
onStepStart(event) {
|
|
10737
|
+
return this.notify("onStepStart", event);
|
|
10738
|
+
}
|
|
10739
|
+
onLanguageModelCallStart(event) {
|
|
10740
|
+
return this.notify("onLanguageModelCallStart", event);
|
|
10741
|
+
}
|
|
10742
|
+
onLanguageModelCallEnd(event) {
|
|
10743
|
+
return this.notify("onLanguageModelCallEnd", event);
|
|
10744
|
+
}
|
|
10745
|
+
onToolExecutionStart(event) {
|
|
10746
|
+
return this.notify("onToolExecutionStart", event);
|
|
10747
|
+
}
|
|
10748
|
+
onToolExecutionEnd(event) {
|
|
10749
|
+
return this.notify("onToolExecutionEnd", event);
|
|
10750
|
+
}
|
|
10751
|
+
onStepEnd(event) {
|
|
10752
|
+
return this.notify("onStepEnd", event);
|
|
10753
|
+
}
|
|
10754
|
+
onStepFinish(event) {
|
|
10755
|
+
return this.notify("onStepFinish", event);
|
|
10756
|
+
}
|
|
10757
|
+
onObjectStepStart(event) {
|
|
10758
|
+
return this.notify("onObjectStepStart", event);
|
|
10759
|
+
}
|
|
10760
|
+
onObjectStepEnd(event) {
|
|
10761
|
+
return this.notify("onObjectStepEnd", event);
|
|
10762
|
+
}
|
|
10763
|
+
onEmbedStart(event) {
|
|
10764
|
+
return this.notify("onEmbedStart", event);
|
|
10765
|
+
}
|
|
10766
|
+
onEmbedEnd(event) {
|
|
10767
|
+
return this.notify("onEmbedEnd", event);
|
|
10768
|
+
}
|
|
10769
|
+
onRerankStart(event) {
|
|
10770
|
+
return this.notify("onRerankStart", event);
|
|
10771
|
+
}
|
|
10772
|
+
onRerankEnd(event) {
|
|
10773
|
+
return this.notify("onRerankEnd", event);
|
|
10774
|
+
}
|
|
10775
|
+
onEnd(event) {
|
|
10776
|
+
return this.notify("onEnd", event);
|
|
10777
|
+
}
|
|
10778
|
+
onAbort(event) {
|
|
10779
|
+
return this.notify("onAbort", event);
|
|
10780
|
+
}
|
|
10781
|
+
onError(event) {
|
|
10782
|
+
return this.notify("onError", event);
|
|
10783
|
+
}
|
|
10784
|
+
async executeLanguageModelCall(options) {
|
|
10785
|
+
const delegate = await this.getDelegate();
|
|
10786
|
+
const fn = delegate.executeLanguageModelCall;
|
|
10787
|
+
return typeof fn === "function" ? Reflect.apply(fn, delegate, [options]) : options.execute();
|
|
10788
|
+
}
|
|
10789
|
+
async executeTool(options) {
|
|
10790
|
+
const delegate = await this.getDelegate();
|
|
10791
|
+
const fn = delegate.executeTool;
|
|
10792
|
+
return typeof fn === "function" ? Reflect.apply(fn, delegate, [options]) : options.execute();
|
|
10793
|
+
}
|
|
10794
|
+
};
|
|
10685
10795
|
function createAITelemetry(opts = {}) {
|
|
10686
10796
|
const userMeta = opts.metadata ?? {};
|
|
10687
10797
|
const neatlogsTracer = getRoutingNeatlogsTracer(TRACER_NAME2);
|
|
10688
10798
|
const callerTracer = opts.tracer;
|
|
10799
|
+
const tracer = callerTracer ? createMirroredTracer(callerTracer, neatlogsTracer) : neatlogsTracer;
|
|
10800
|
+
const metadata = callerTracer ? { ...userMeta } : { ...userMeta, neatlogsWrapped: true };
|
|
10689
10801
|
return {
|
|
10690
10802
|
isEnabled: true,
|
|
10691
10803
|
recordInputs: true,
|
|
@@ -10694,11 +10806,12 @@ function createAITelemetry(opts = {}) {
|
|
|
10694
10806
|
// internally, which would otherwise parent its native spans from the foreign
|
|
10695
10807
|
// global context AND push them onto it (so a co-tenant's next span inherits
|
|
10696
10808
|
// ours). The facade routes both through the private Neatlogs context.
|
|
10697
|
-
tracer
|
|
10809
|
+
tracer,
|
|
10698
10810
|
...opts.functionId !== void 0 ? { functionId: opts.functionId } : {},
|
|
10699
10811
|
// The marker is an implementation detail used only when Neatlogs owns the
|
|
10700
10812
|
// telemetry stream. Do not leak it into caller-owned providers.
|
|
10701
|
-
metadata
|
|
10813
|
+
metadata,
|
|
10814
|
+
integrations: [new LazyV7OpenTelemetryIntegration(tracer, metadata)]
|
|
10702
10815
|
};
|
|
10703
10816
|
}
|
|
10704
10817
|
function safeStringify2(value) {
|
|
@@ -10731,7 +10844,7 @@ function setOutputValue(span2, result) {
|
|
|
10731
10844
|
span2.setAttribute("output.value", text);
|
|
10732
10845
|
}
|
|
10733
10846
|
if (r.finishReason) {
|
|
10734
|
-
span2.setAttribute("
|
|
10847
|
+
span2.setAttribute("neatlogs.llm.finish_reason", String(r.finishReason));
|
|
10735
10848
|
}
|
|
10736
10849
|
return;
|
|
10737
10850
|
}
|
|
@@ -10740,7 +10853,7 @@ function setOutputValue(span2, result) {
|
|
|
10740
10853
|
span2.setAttribute("output.value", safeStringify2(r.object));
|
|
10741
10854
|
}
|
|
10742
10855
|
if (r.finishReason) {
|
|
10743
|
-
span2.setAttribute("
|
|
10856
|
+
span2.setAttribute("neatlogs.llm.finish_reason", String(r.finishReason));
|
|
10744
10857
|
}
|
|
10745
10858
|
return;
|
|
10746
10859
|
}
|
|
@@ -10760,7 +10873,7 @@ function setStreamOutputValue(span2, event) {
|
|
|
10760
10873
|
if (stringified) span2.setAttribute("output.value", stringified);
|
|
10761
10874
|
}
|
|
10762
10875
|
if (e.finishReason) {
|
|
10763
|
-
span2.setAttribute("
|
|
10876
|
+
span2.setAttribute("neatlogs.llm.finish_reason", String(e.finishReason));
|
|
10764
10877
|
}
|
|
10765
10878
|
}
|
|
10766
10879
|
var WRAPPED_FUNCTIONS = [
|
|
@@ -10780,6 +10893,8 @@ var wrappedExports = /* @__PURE__ */ new WeakSet();
|
|
|
10780
10893
|
var wrapperByOriginal = /* @__PURE__ */ new WeakMap();
|
|
10781
10894
|
function wrapAISDK(aiModule) {
|
|
10782
10895
|
const wrapped = { ...aiModule };
|
|
10896
|
+
const hasRegisterTelemetry = "registerTelemetry" in aiModule && typeof Reflect.get(aiModule, "registerTelemetry") === "function";
|
|
10897
|
+
const telemetryKey = hasRegisterTelemetry ? "telemetry" : "experimental_telemetry";
|
|
10783
10898
|
for (const name of WRAPPED_FUNCTIONS) {
|
|
10784
10899
|
const original = aiModule[name];
|
|
10785
10900
|
if (typeof original !== "function") continue;
|
|
@@ -10791,12 +10906,16 @@ function wrapAISDK(aiModule) {
|
|
|
10791
10906
|
if (name === "streamText" || name === "streamObject") {
|
|
10792
10907
|
wrapped[name] = cacheWrapper(
|
|
10793
10908
|
original,
|
|
10794
|
-
createStreamWrapper(name, original)
|
|
10909
|
+
createStreamWrapper(name, original, telemetryKey)
|
|
10795
10910
|
);
|
|
10796
10911
|
} else {
|
|
10797
10912
|
wrapped[name] = cacheWrapper(
|
|
10798
10913
|
original,
|
|
10799
|
-
createAsyncWrapper(
|
|
10914
|
+
createAsyncWrapper(
|
|
10915
|
+
name,
|
|
10916
|
+
original,
|
|
10917
|
+
telemetryKey
|
|
10918
|
+
)
|
|
10800
10919
|
);
|
|
10801
10920
|
}
|
|
10802
10921
|
}
|
|
@@ -10806,7 +10925,7 @@ function wrapAISDK(aiModule) {
|
|
|
10806
10925
|
const existing = getExistingWrapper(original);
|
|
10807
10926
|
wrapped[name] = existing ?? cacheWrapper(
|
|
10808
10927
|
original,
|
|
10809
|
-
createAgentConstructorWrapper(original)
|
|
10928
|
+
createAgentConstructorWrapper(original, telemetryKey)
|
|
10810
10929
|
);
|
|
10811
10930
|
}
|
|
10812
10931
|
return wrapped;
|
|
@@ -10820,26 +10939,30 @@ function cacheWrapper(original, wrapped) {
|
|
|
10820
10939
|
wrappedExports.add(wrapped);
|
|
10821
10940
|
return wrapped;
|
|
10822
10941
|
}
|
|
10823
|
-
function createAgentConstructorWrapper(original) {
|
|
10942
|
+
function createAgentConstructorWrapper(original, telemetryKey) {
|
|
10824
10943
|
return new Proxy(original, {
|
|
10825
10944
|
construct(target, args, newTarget) {
|
|
10826
10945
|
if (args.length === 0 || typeof args[0] !== "object" || args[0] === null) {
|
|
10827
10946
|
return Reflect.construct(target, args, newTarget);
|
|
10828
10947
|
}
|
|
10829
|
-
const settings = mergeAgentSettings(args[0]);
|
|
10948
|
+
const settings = mergeAgentSettings(args[0], telemetryKey);
|
|
10830
10949
|
return Reflect.construct(target, [settings, ...args.slice(1)], newTarget);
|
|
10831
10950
|
}
|
|
10832
10951
|
});
|
|
10833
10952
|
}
|
|
10834
|
-
function mergeAgentSettings(settings) {
|
|
10835
|
-
const merged = mergeTelemetry(settings);
|
|
10953
|
+
function mergeAgentSettings(settings, telemetryKey) {
|
|
10954
|
+
const merged = mergeTelemetry(settings, telemetryKey);
|
|
10836
10955
|
const userPrepareCall = settings.prepareCall;
|
|
10837
10956
|
if (typeof userPrepareCall !== "function") return merged;
|
|
10838
10957
|
return {
|
|
10839
10958
|
...merged,
|
|
10840
10959
|
prepareCall: async function wrappedPrepareCall(...args) {
|
|
10841
10960
|
const prepared = await Reflect.apply(userPrepareCall, this, args);
|
|
10842
|
-
return prepared == null ? prepared : mergeTelemetry(
|
|
10961
|
+
return prepared == null ? prepared : mergeTelemetry(
|
|
10962
|
+
prepared,
|
|
10963
|
+
telemetryKey,
|
|
10964
|
+
settings.telemetry ?? settings.experimental_telemetry
|
|
10965
|
+
);
|
|
10843
10966
|
}
|
|
10844
10967
|
};
|
|
10845
10968
|
}
|
|
@@ -10851,7 +10974,7 @@ function rootSpanKind(name) {
|
|
|
10851
10974
|
function getParentContext() {
|
|
10852
10975
|
return getNeatlogsParentContext();
|
|
10853
10976
|
}
|
|
10854
|
-
function createAsyncWrapper(name, original) {
|
|
10977
|
+
function createAsyncWrapper(name, original, telemetryKey) {
|
|
10855
10978
|
return async function wrappedAsyncFn(opts) {
|
|
10856
10979
|
const tracer = getNeatlogsTracer(TRACER_NAME2);
|
|
10857
10980
|
const parentContext = getParentContext();
|
|
@@ -10871,7 +10994,7 @@ function createAsyncWrapper(name, original) {
|
|
|
10871
10994
|
if (name === "rerank" && opts?.query) {
|
|
10872
10995
|
span2.setAttribute("ai.rerank.query", String(opts.query));
|
|
10873
10996
|
}
|
|
10874
|
-
const merged = mergeTelemetry(opts);
|
|
10997
|
+
const merged = mergeTelemetry(opts, telemetryKey);
|
|
10875
10998
|
const result = await original(merged);
|
|
10876
10999
|
if (!isEmbedOrRerank) {
|
|
10877
11000
|
setOutputValue(span2, result);
|
|
@@ -10888,7 +11011,7 @@ function createAsyncWrapper(name, original) {
|
|
|
10888
11011
|
);
|
|
10889
11012
|
};
|
|
10890
11013
|
}
|
|
10891
|
-
function createStreamWrapper(name, original) {
|
|
11014
|
+
function createStreamWrapper(name, original, telemetryKey) {
|
|
10892
11015
|
return function wrappedStreamFn(opts) {
|
|
10893
11016
|
const tracer = getNeatlogsTracer(TRACER_NAME2);
|
|
10894
11017
|
const parentContext = getParentContext();
|
|
@@ -10908,7 +11031,7 @@ function createStreamWrapper(name, original) {
|
|
|
10908
11031
|
};
|
|
10909
11032
|
try {
|
|
10910
11033
|
setInputValue(span2, opts);
|
|
10911
|
-
const merged = mergeTelemetry(opts);
|
|
11034
|
+
const merged = mergeTelemetry(opts, telemetryKey);
|
|
10912
11035
|
const userOnFinish = opts?.onFinish;
|
|
10913
11036
|
const userOnError = opts?.onError;
|
|
10914
11037
|
const wrappedOpts = {
|
|
@@ -11033,25 +11156,47 @@ function createMirroredTracer(primary, secondary) {
|
|
|
11033
11156
|
})
|
|
11034
11157
|
};
|
|
11035
11158
|
}
|
|
11036
|
-
function
|
|
11159
|
+
function isNeatlogsV7Integration(integration) {
|
|
11160
|
+
return typeof integration === "object" && integration !== null && NEATLOGS_V7_INTEGRATION in integration;
|
|
11161
|
+
}
|
|
11162
|
+
function mergeTelemetry(opts, telemetryKey, fallbackTelemetry) {
|
|
11163
|
+
const legacyTelemetry = opts?.experimental_telemetry ?? {};
|
|
11164
|
+
const v7Telemetry = opts?.telemetry ?? {};
|
|
11165
|
+
const preferredTelemetry = telemetryKey === "telemetry" ? { ...legacyTelemetry, ...v7Telemetry } : { ...v7Telemetry, ...legacyTelemetry };
|
|
11037
11166
|
const requestedTelemetry = {
|
|
11038
11167
|
...fallbackTelemetry,
|
|
11039
|
-
...
|
|
11168
|
+
...preferredTelemetry,
|
|
11040
11169
|
metadata: {
|
|
11041
11170
|
...fallbackTelemetry?.metadata,
|
|
11042
|
-
...
|
|
11171
|
+
...legacyTelemetry.metadata,
|
|
11172
|
+
...v7Telemetry.metadata
|
|
11043
11173
|
}
|
|
11044
11174
|
};
|
|
11045
|
-
const
|
|
11175
|
+
const existingNeatlogsIntegration = Array.isArray(
|
|
11176
|
+
requestedTelemetry.integrations
|
|
11177
|
+
) ? requestedTelemetry.integrations.find(isNeatlogsV7Integration) : void 0;
|
|
11178
|
+
const baseTelemetry = existingNeatlogsIntegration ? {
|
|
11179
|
+
isEnabled: true,
|
|
11180
|
+
recordInputs: true,
|
|
11181
|
+
recordOutputs: true,
|
|
11182
|
+
tracer: requestedTelemetry.tracer,
|
|
11183
|
+
...requestedTelemetry.functionId !== void 0 ? { functionId: requestedTelemetry.functionId } : {},
|
|
11184
|
+
metadata: requestedTelemetry.metadata,
|
|
11185
|
+
integrations: [existingNeatlogsIntegration]
|
|
11186
|
+
} : createAITelemetry({
|
|
11046
11187
|
functionId: requestedTelemetry.functionId,
|
|
11047
11188
|
metadata: requestedTelemetry.metadata,
|
|
11048
11189
|
tracer: requestedTelemetry.tracer
|
|
11049
11190
|
});
|
|
11050
11191
|
const callerTracer = requestedTelemetry.tracer;
|
|
11051
11192
|
const hasCallerTracer = callerTracer !== void 0;
|
|
11193
|
+
const requestedIntegrations = Array.isArray(requestedTelemetry.integrations) ? requestedTelemetry.integrations.filter(
|
|
11194
|
+
(integration) => !isNeatlogsV7Integration(integration)
|
|
11195
|
+
) : [];
|
|
11196
|
+
const { telemetry: _telemetry, experimental_telemetry: _legacy, ...rest } = opts ?? {};
|
|
11052
11197
|
return {
|
|
11053
|
-
...
|
|
11054
|
-
|
|
11198
|
+
...rest,
|
|
11199
|
+
[telemetryKey]: {
|
|
11055
11200
|
...baseTelemetry,
|
|
11056
11201
|
...requestedTelemetry,
|
|
11057
11202
|
isEnabled: true,
|
|
@@ -11061,7 +11206,8 @@ function mergeTelemetry(opts, fallbackTelemetry) {
|
|
|
11061
11206
|
// Do not add Neatlogs-only marker metadata to a caller-owned telemetry
|
|
11062
11207
|
// pipeline such as Laminar. Both providers receive the same AI SDK span
|
|
11063
11208
|
// data, while their providers, parent contexts, and exporters stay separate.
|
|
11064
|
-
metadata: hasCallerTracer ? requestedTelemetry.metadata : baseTelemetry.metadata
|
|
11209
|
+
metadata: hasCallerTracer ? requestedTelemetry.metadata : baseTelemetry.metadata,
|
|
11210
|
+
integrations: [...baseTelemetry.integrations, ...requestedIntegrations]
|
|
11065
11211
|
}
|
|
11066
11212
|
};
|
|
11067
11213
|
}
|