@brizz/sdk 0.1.13 → 0.1.15
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 +20 -0
- package/dist/index.cjs +45 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +44 -32
- package/dist/index.js.map +1 -1
- package/dist/preload.cjs +15 -10
- package/dist/preload.cjs.map +1 -1
- package/dist/preload.js +15 -10
- package/dist/preload.js.map +1 -1
- package/package.json +31 -29
package/dist/index.d.cts
CHANGED
|
@@ -130,10 +130,11 @@ declare class Session {
|
|
|
130
130
|
private inputs;
|
|
131
131
|
private outputs;
|
|
132
132
|
constructor(sessionId: string, span: Span);
|
|
133
|
-
setInput(text: string): void;
|
|
134
|
-
setOutput(text: string): void;
|
|
133
|
+
setInput(text: string | null): void;
|
|
134
|
+
setOutput(text: string | null): void;
|
|
135
135
|
updateProperties(properties: Record<string, AttributeValue>): void;
|
|
136
136
|
}
|
|
137
|
+
declare function getActiveSession(): Session | undefined;
|
|
137
138
|
declare function startSession<T>(sessionId: string, callback: (session: Session) => T, extraProperties?: Record<string, AttributeValue>): T;
|
|
138
139
|
|
|
139
140
|
declare function getMetricsExporter(): OTLPMetricExporter;
|
|
@@ -152,4 +153,4 @@ declare namespace init {
|
|
|
152
153
|
export { };
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, Session, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, startSession, withProperties, withSessionId };
|
|
156
|
+
export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, Session, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getActiveSession, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, startSession, withProperties, withSessionId };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,10 +130,11 @@ declare class Session {
|
|
|
130
130
|
private inputs;
|
|
131
131
|
private outputs;
|
|
132
132
|
constructor(sessionId: string, span: Span);
|
|
133
|
-
setInput(text: string): void;
|
|
134
|
-
setOutput(text: string): void;
|
|
133
|
+
setInput(text: string | null): void;
|
|
134
|
+
setOutput(text: string | null): void;
|
|
135
135
|
updateProperties(properties: Record<string, AttributeValue>): void;
|
|
136
136
|
}
|
|
137
|
+
declare function getActiveSession(): Session | undefined;
|
|
137
138
|
declare function startSession<T>(sessionId: string, callback: (session: Session) => T, extraProperties?: Record<string, AttributeValue>): T;
|
|
138
139
|
|
|
139
140
|
declare function getMetricsExporter(): OTLPMetricExporter;
|
|
@@ -152,4 +153,4 @@ declare namespace init {
|
|
|
152
153
|
export { };
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, Session, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, startSession, withProperties, withSessionId };
|
|
156
|
+
export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, Session, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getActiveSession, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, startSession, withProperties, withSessionId };
|
package/dist/index.js
CHANGED
|
@@ -318,7 +318,6 @@ var BRIZZ_SDK_LANGUAGE = "brizz.sdk.language";
|
|
|
318
318
|
var SDK_LANGUAGE = "typescript";
|
|
319
319
|
|
|
320
320
|
// src/internal/instrumentation/registry.ts
|
|
321
|
-
import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
|
|
322
321
|
import { AnthropicInstrumentation as AnthropicInstrumentation2 } from "@traceloop/instrumentation-anthropic";
|
|
323
322
|
import { BedrockInstrumentation as BedrockInstrumentation2 } from "@traceloop/instrumentation-bedrock";
|
|
324
323
|
import { ChromaDBInstrumentation as ChromaDBInstrumentation2 } from "@traceloop/instrumentation-chromadb";
|
|
@@ -419,14 +418,19 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
419
418
|
}
|
|
420
419
|
}
|
|
421
420
|
if (this.manualModules?.langchain?.callbackManagerModule) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
421
|
+
const callbackManagerModule = this.manualModules.langchain.callbackManagerModule;
|
|
422
|
+
void (async () => {
|
|
423
|
+
try {
|
|
424
|
+
const { LangChainInstrumentation } = await import("@arizeai/openinference-instrumentation-langchain");
|
|
425
|
+
const lcInst = new LangChainInstrumentation();
|
|
426
|
+
lcInst.manuallyInstrument(callbackManagerModule);
|
|
427
|
+
logger.debug("Manual instrumentation enabled for LangChain");
|
|
428
|
+
} catch (error) {
|
|
429
|
+
logger.error(
|
|
430
|
+
`Failed to load LangChain instrumentation. Ensure @langchain/core is installed: ${String(error)}`
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
})();
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
436
|
};
|
|
@@ -441,7 +445,7 @@ import {
|
|
|
441
445
|
|
|
442
446
|
// src/internal/version.ts
|
|
443
447
|
function getSDKVersion() {
|
|
444
|
-
return "0.1.
|
|
448
|
+
return "0.1.15";
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
// src/internal/log/processors/log-processor.ts
|
|
@@ -1078,6 +1082,7 @@ var BRIZZ = "brizz";
|
|
|
1078
1082
|
var PROPERTIES = "properties";
|
|
1079
1083
|
var SESSION_ID = "session.id";
|
|
1080
1084
|
var PROPERTIES_CONTEXT_KEY = createContextKey(PROPERTIES);
|
|
1085
|
+
var SESSION_OBJECT_CONTEXT_KEY = createContextKey("brizz.session.object");
|
|
1081
1086
|
var SESSION_INPUT = "brizz.session.input";
|
|
1082
1087
|
var SESSION_OUTPUT = "brizz.session.output";
|
|
1083
1088
|
var SESSION_SPAN_NAME = "brizz.start_session";
|
|
@@ -1713,7 +1718,7 @@ var Session = class {
|
|
|
1713
1718
|
* Use when you need to track specific input data that differs from what's sent to the LLM.
|
|
1714
1719
|
* Multiple calls accumulate in an array.
|
|
1715
1720
|
*
|
|
1716
|
-
* @param text - Text to append to session input
|
|
1721
|
+
* @param text - Text to append to session input, or null to append null
|
|
1717
1722
|
*/
|
|
1718
1723
|
setInput(text) {
|
|
1719
1724
|
this.inputs.push(text);
|
|
@@ -1724,7 +1729,7 @@ var Session = class {
|
|
|
1724
1729
|
* Use when you need to track specific output data that differs from what's received from the LLM.
|
|
1725
1730
|
* Multiple calls accumulate in an array.
|
|
1726
1731
|
*
|
|
1727
|
-
* @param text - Text to append to session output
|
|
1732
|
+
* @param text - Text to append to session output, or null to append null
|
|
1728
1733
|
*/
|
|
1729
1734
|
setOutput(text) {
|
|
1730
1735
|
this.outputs.push(text);
|
|
@@ -1742,6 +1747,9 @@ var Session = class {
|
|
|
1742
1747
|
}
|
|
1743
1748
|
}
|
|
1744
1749
|
};
|
|
1750
|
+
function getActiveSession() {
|
|
1751
|
+
return context3.active().getValue(SESSION_OBJECT_CONTEXT_KEY);
|
|
1752
|
+
}
|
|
1745
1753
|
function startSession(sessionId, callback, extraProperties) {
|
|
1746
1754
|
const tracer = trace.getTracer("@brizz/sdk");
|
|
1747
1755
|
return tracer.startActiveSpan(SESSION_SPAN_NAME, (span) => {
|
|
@@ -1759,27 +1767,30 @@ function startSession(sessionId, callback, extraProperties) {
|
|
|
1759
1767
|
}
|
|
1760
1768
|
}
|
|
1761
1769
|
return callWithProperties(contextProperties, () => {
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
return value
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1770
|
+
const sessionCtx = context3.active().setValue(SESSION_OBJECT_CONTEXT_KEY, session);
|
|
1771
|
+
return context3.with(sessionCtx, () => {
|
|
1772
|
+
try {
|
|
1773
|
+
const result = callback(session);
|
|
1774
|
+
if (result && typeof result.then === "function") {
|
|
1775
|
+
return result.then((value) => {
|
|
1776
|
+
span.end();
|
|
1777
|
+
return value;
|
|
1778
|
+
}).catch((error) => {
|
|
1779
|
+
span.recordException(error);
|
|
1780
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
1781
|
+
span.end();
|
|
1782
|
+
throw error;
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
span.end();
|
|
1786
|
+
return result;
|
|
1787
|
+
} catch (error) {
|
|
1788
|
+
span.recordException(error);
|
|
1789
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
1790
|
+
span.end();
|
|
1791
|
+
throw error;
|
|
1774
1792
|
}
|
|
1775
|
-
|
|
1776
|
-
return result;
|
|
1777
|
-
} catch (error) {
|
|
1778
|
-
span.recordException(error);
|
|
1779
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
1780
|
-
span.end();
|
|
1781
|
-
throw error;
|
|
1782
|
-
}
|
|
1793
|
+
});
|
|
1783
1794
|
});
|
|
1784
1795
|
});
|
|
1785
1796
|
}
|
|
@@ -2038,6 +2049,7 @@ export {
|
|
|
2038
2049
|
callWithSessionId,
|
|
2039
2050
|
detectRuntime,
|
|
2040
2051
|
emitEvent,
|
|
2052
|
+
getActiveSession,
|
|
2041
2053
|
getLogLevel,
|
|
2042
2054
|
getMetricsExporter,
|
|
2043
2055
|
getMetricsReader,
|