netra-sdk 1.2.0 → 1.4.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.cjs +1333 -771
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +1328 -767
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -59,10 +59,11 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
59
59
|
declare class Config {
|
|
60
60
|
static readonly SDK_NAME = "netra";
|
|
61
61
|
static readonly LIBRARY_NAME = "netra";
|
|
62
|
-
static readonly LIBRARY_VERSION = "1.
|
|
62
|
+
static readonly LIBRARY_VERSION = "1.4.0";
|
|
63
63
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
64
64
|
static readonly ATTRIBUTE_MAX_LEN: number;
|
|
65
65
|
static readonly CONVERSATION_MAX_LEN: number;
|
|
66
|
+
static readonly SPAN_ATTRIBUTE_MAX_SIZE: number;
|
|
66
67
|
appName: string;
|
|
67
68
|
otlpEndpoint?: string;
|
|
68
69
|
apiKey?: string;
|
|
@@ -94,6 +95,7 @@ declare class Config {
|
|
|
94
95
|
* This ensures the Traceloop SDK picks up our configuration.
|
|
95
96
|
*/
|
|
96
97
|
setTraceloopEnv(): void;
|
|
98
|
+
private _setResourceAttributesEnv;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -847,6 +849,23 @@ declare class Prompts {
|
|
|
847
849
|
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
848
850
|
}
|
|
849
851
|
|
|
852
|
+
/**
|
|
853
|
+
* Attribute Size Limit Span Processor
|
|
854
|
+
*
|
|
855
|
+
* Enforces a hard max length on every span attribute value via setAttribute
|
|
856
|
+
* wrapping in onStart. Prevents "entity too large" errors during export.
|
|
857
|
+
*/
|
|
858
|
+
|
|
859
|
+
declare class AttributeSizeLimitProcessor implements SpanProcessor {
|
|
860
|
+
private maxAttributeSize;
|
|
861
|
+
constructor(maxAttributeSize?: number);
|
|
862
|
+
onStart(span: Span, _parentContext: Context): void;
|
|
863
|
+
onEnd(_span: ReadableSpan): void;
|
|
864
|
+
shutdown(): Promise<void>;
|
|
865
|
+
forceFlush(): Promise<void>;
|
|
866
|
+
private _wrapSetAttribute;
|
|
867
|
+
}
|
|
868
|
+
|
|
850
869
|
/**
|
|
851
870
|
* Instrumentation Span Processor
|
|
852
871
|
*
|
|
@@ -947,6 +966,8 @@ declare class ScrubbingSpanProcessor implements SpanProcessor {
|
|
|
947
966
|
*/
|
|
948
967
|
|
|
949
968
|
declare class SessionSpanProcessor implements SpanProcessor {
|
|
969
|
+
private readonly environment;
|
|
970
|
+
constructor(environment?: string);
|
|
950
971
|
/**
|
|
951
972
|
* Called when a span starts. Adds session and entity context attributes.
|
|
952
973
|
*/
|
|
@@ -1214,6 +1235,28 @@ declare function span(target: AnyClass): void;
|
|
|
1214
1235
|
declare function span<T extends AnyFunction>(target: T): T;
|
|
1215
1236
|
declare function span(options?: DecoratorOptions): UnifiedDecorator;
|
|
1216
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* Shared utility functions for instrumentation.
|
|
1240
|
+
* Handles setting OTel span attributes for LLM request/response tracing.
|
|
1241
|
+
*/
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Controls where native traces are sent.
|
|
1245
|
+
*
|
|
1246
|
+
* - `"netra"` -- Replace the SDK's default processors so traces go
|
|
1247
|
+
* only to Netra. If the SDK does not expose the required APIs, falls back
|
|
1248
|
+
* to additive mode (both Netra and native) and logs a warning.
|
|
1249
|
+
* - `"netra-strict"` (default) -- Same replacement as `"netra"`, but if the SDK APIs
|
|
1250
|
+
* are unavailable the processor is **not** registered at all, ensuring
|
|
1251
|
+
* traces never reach native even at the cost of no tracing.
|
|
1252
|
+
* - `"both"` -- The Netra processor is added alongside the native defaults;
|
|
1253
|
+
* traces go to both Netra and native.
|
|
1254
|
+
*
|
|
1255
|
+
* Can also be set via the `NATIVE_TRACING_MODE` environment
|
|
1256
|
+
* variable using the same string values.
|
|
1257
|
+
*/
|
|
1258
|
+
type NativeTracingMode = "both" | "netra" | "netra-strict";
|
|
1259
|
+
|
|
1217
1260
|
/**
|
|
1218
1261
|
* Custom MistralAI instrumentor for Netra SDK
|
|
1219
1262
|
*
|
|
@@ -1328,12 +1371,15 @@ interface TracingProcessor {
|
|
|
1328
1371
|
forceFlush(): Promise<void> | void;
|
|
1329
1372
|
shutdown(timeout?: number): Promise<void> | void;
|
|
1330
1373
|
}
|
|
1374
|
+
|
|
1331
1375
|
interface InstrumentorOptions {
|
|
1332
1376
|
tracerProvider?: {
|
|
1333
1377
|
getTracer(name: string, version?: string): any;
|
|
1334
1378
|
};
|
|
1335
1379
|
/** Override the `llm.system` attribute value (default: `"openai"`). */
|
|
1336
1380
|
systemName?: string;
|
|
1381
|
+
/** Controls where traces are sent. See {@link NativeTracingMode}. */
|
|
1382
|
+
nativeTracing?: NativeTracingMode;
|
|
1337
1383
|
}
|
|
1338
1384
|
|
|
1339
1385
|
declare class NetraAgentsTracingProcessor implements TracingProcessor {
|
|
@@ -1560,4 +1606,4 @@ declare class Netra {
|
|
|
1560
1606
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1561
1607
|
}
|
|
1562
1608
|
|
|
1563
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
|
1609
|
+
export { type ActionModel, Aggregation, AttributeSizeLimitProcessor, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,10 +59,11 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
59
59
|
declare class Config {
|
|
60
60
|
static readonly SDK_NAME = "netra";
|
|
61
61
|
static readonly LIBRARY_NAME = "netra";
|
|
62
|
-
static readonly LIBRARY_VERSION = "1.
|
|
62
|
+
static readonly LIBRARY_VERSION = "1.4.0";
|
|
63
63
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
64
64
|
static readonly ATTRIBUTE_MAX_LEN: number;
|
|
65
65
|
static readonly CONVERSATION_MAX_LEN: number;
|
|
66
|
+
static readonly SPAN_ATTRIBUTE_MAX_SIZE: number;
|
|
66
67
|
appName: string;
|
|
67
68
|
otlpEndpoint?: string;
|
|
68
69
|
apiKey?: string;
|
|
@@ -94,6 +95,7 @@ declare class Config {
|
|
|
94
95
|
* This ensures the Traceloop SDK picks up our configuration.
|
|
95
96
|
*/
|
|
96
97
|
setTraceloopEnv(): void;
|
|
98
|
+
private _setResourceAttributesEnv;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -847,6 +849,23 @@ declare class Prompts {
|
|
|
847
849
|
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
848
850
|
}
|
|
849
851
|
|
|
852
|
+
/**
|
|
853
|
+
* Attribute Size Limit Span Processor
|
|
854
|
+
*
|
|
855
|
+
* Enforces a hard max length on every span attribute value via setAttribute
|
|
856
|
+
* wrapping in onStart. Prevents "entity too large" errors during export.
|
|
857
|
+
*/
|
|
858
|
+
|
|
859
|
+
declare class AttributeSizeLimitProcessor implements SpanProcessor {
|
|
860
|
+
private maxAttributeSize;
|
|
861
|
+
constructor(maxAttributeSize?: number);
|
|
862
|
+
onStart(span: Span, _parentContext: Context): void;
|
|
863
|
+
onEnd(_span: ReadableSpan): void;
|
|
864
|
+
shutdown(): Promise<void>;
|
|
865
|
+
forceFlush(): Promise<void>;
|
|
866
|
+
private _wrapSetAttribute;
|
|
867
|
+
}
|
|
868
|
+
|
|
850
869
|
/**
|
|
851
870
|
* Instrumentation Span Processor
|
|
852
871
|
*
|
|
@@ -947,6 +966,8 @@ declare class ScrubbingSpanProcessor implements SpanProcessor {
|
|
|
947
966
|
*/
|
|
948
967
|
|
|
949
968
|
declare class SessionSpanProcessor implements SpanProcessor {
|
|
969
|
+
private readonly environment;
|
|
970
|
+
constructor(environment?: string);
|
|
950
971
|
/**
|
|
951
972
|
* Called when a span starts. Adds session and entity context attributes.
|
|
952
973
|
*/
|
|
@@ -1214,6 +1235,28 @@ declare function span(target: AnyClass): void;
|
|
|
1214
1235
|
declare function span<T extends AnyFunction>(target: T): T;
|
|
1215
1236
|
declare function span(options?: DecoratorOptions): UnifiedDecorator;
|
|
1216
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* Shared utility functions for instrumentation.
|
|
1240
|
+
* Handles setting OTel span attributes for LLM request/response tracing.
|
|
1241
|
+
*/
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Controls where native traces are sent.
|
|
1245
|
+
*
|
|
1246
|
+
* - `"netra"` -- Replace the SDK's default processors so traces go
|
|
1247
|
+
* only to Netra. If the SDK does not expose the required APIs, falls back
|
|
1248
|
+
* to additive mode (both Netra and native) and logs a warning.
|
|
1249
|
+
* - `"netra-strict"` (default) -- Same replacement as `"netra"`, but if the SDK APIs
|
|
1250
|
+
* are unavailable the processor is **not** registered at all, ensuring
|
|
1251
|
+
* traces never reach native even at the cost of no tracing.
|
|
1252
|
+
* - `"both"` -- The Netra processor is added alongside the native defaults;
|
|
1253
|
+
* traces go to both Netra and native.
|
|
1254
|
+
*
|
|
1255
|
+
* Can also be set via the `NATIVE_TRACING_MODE` environment
|
|
1256
|
+
* variable using the same string values.
|
|
1257
|
+
*/
|
|
1258
|
+
type NativeTracingMode = "both" | "netra" | "netra-strict";
|
|
1259
|
+
|
|
1217
1260
|
/**
|
|
1218
1261
|
* Custom MistralAI instrumentor for Netra SDK
|
|
1219
1262
|
*
|
|
@@ -1328,12 +1371,15 @@ interface TracingProcessor {
|
|
|
1328
1371
|
forceFlush(): Promise<void> | void;
|
|
1329
1372
|
shutdown(timeout?: number): Promise<void> | void;
|
|
1330
1373
|
}
|
|
1374
|
+
|
|
1331
1375
|
interface InstrumentorOptions {
|
|
1332
1376
|
tracerProvider?: {
|
|
1333
1377
|
getTracer(name: string, version?: string): any;
|
|
1334
1378
|
};
|
|
1335
1379
|
/** Override the `llm.system` attribute value (default: `"openai"`). */
|
|
1336
1380
|
systemName?: string;
|
|
1381
|
+
/** Controls where traces are sent. See {@link NativeTracingMode}. */
|
|
1382
|
+
nativeTracing?: NativeTracingMode;
|
|
1337
1383
|
}
|
|
1338
1384
|
|
|
1339
1385
|
declare class NetraAgentsTracingProcessor implements TracingProcessor {
|
|
@@ -1560,4 +1606,4 @@ declare class Netra {
|
|
|
1560
1606
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1561
1607
|
}
|
|
1562
1608
|
|
|
1563
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
|
1609
|
+
export { type ActionModel, Aggregation, AttributeSizeLimitProcessor, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|