netra-sdk 1.1.0-beta → 1.1.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 +523 -273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +499 -251
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.cts
CHANGED
|
@@ -1206,13 +1206,12 @@ declare class NetraMistralAIInstrumentor {
|
|
|
1206
1206
|
instrumentationDependencies(): string[];
|
|
1207
1207
|
/**
|
|
1208
1208
|
* Instrument MistralAI client methods (async version)
|
|
1209
|
-
*
|
|
1210
|
-
* that the application uses.
|
|
1209
|
+
* Tries both ESM and CJS resolution to cover dual-package setups.
|
|
1211
1210
|
*/
|
|
1212
1211
|
instrumentAsync(options?: InstrumentorOptions$1): Promise<NetraMistralAIInstrumentor>;
|
|
1213
1212
|
/**
|
|
1214
1213
|
* Instrument MistralAI client methods (sync version - for backwards compatibility)
|
|
1215
|
-
* Note: This uses
|
|
1214
|
+
* Note: This uses cached Mistral classes. Call instrumentAsync() for proper initialization.
|
|
1216
1215
|
*/
|
|
1217
1216
|
instrument(options?: InstrumentorOptions$1): NetraMistralAIInstrumentor;
|
|
1218
1217
|
/**
|
|
@@ -1390,6 +1389,82 @@ declare class TrialAwareOTLPExporter implements SpanExporter {
|
|
|
1390
1389
|
shutdown(): Promise<void>;
|
|
1391
1390
|
}
|
|
1392
1391
|
|
|
1392
|
+
/**
|
|
1393
|
+
* Public helpers for distributed tracing context propagation.
|
|
1394
|
+
*
|
|
1395
|
+
* These utilities let users extract incoming W3C Trace Context from HTTP
|
|
1396
|
+
* headers and run code within that context so that all child spans (LLM
|
|
1397
|
+
* calls, database queries, outgoing HTTP, etc.) are linked to the upstream
|
|
1398
|
+
* trace.
|
|
1399
|
+
*
|
|
1400
|
+
* When `@opentelemetry/instrumentation-http` + `@opentelemetry/instrumentation-express`
|
|
1401
|
+
* are installed and working, incoming context extraction happens automatically.
|
|
1402
|
+
* These helpers cover cases where auto-instrumentation is unavailable (e.g.
|
|
1403
|
+
* ESM module loading order issues, missing peer dependencies, or non-Express
|
|
1404
|
+
* frameworks).
|
|
1405
|
+
*/
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Run a function within a context extracted from HTTP headers.
|
|
1409
|
+
*
|
|
1410
|
+
* All spans created inside `fn` will be children of the trace described by the
|
|
1411
|
+
* incoming `traceparent` / `tracestate` headers, enabling end-to-end
|
|
1412
|
+
* distributed tracing across service boundaries.
|
|
1413
|
+
*
|
|
1414
|
+
* @param headers - Incoming HTTP request headers (e.g. `req.headers`).
|
|
1415
|
+
* @param fn - The function to execute within the extracted context.
|
|
1416
|
+
* May be sync or async -- the return value is forwarded as-is.
|
|
1417
|
+
* @returns The return value of `fn`.
|
|
1418
|
+
*
|
|
1419
|
+
* @example
|
|
1420
|
+
* ```ts
|
|
1421
|
+
* import { runWithExtractedContext } from "netra";
|
|
1422
|
+
*
|
|
1423
|
+
* app.post("/api/chat", async (req, res) => {
|
|
1424
|
+
* await runWithExtractedContext(req.headers, async () => {
|
|
1425
|
+
* const result = await myAgent(req.body.message);
|
|
1426
|
+
* res.json(result);
|
|
1427
|
+
* });
|
|
1428
|
+
* });
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
declare function runWithExtractedContext<T>(headers: Record<string, string | string[] | undefined>, fn: () => T): T;
|
|
1432
|
+
/**
|
|
1433
|
+
* Express/Connect-compatible middleware that extracts W3C Trace Context from
|
|
1434
|
+
* incoming request headers and runs all downstream handlers within the
|
|
1435
|
+
* extracted context.
|
|
1436
|
+
*
|
|
1437
|
+
* This is the recommended way to enable distributed tracing for Express
|
|
1438
|
+
* servers when `@opentelemetry/instrumentation-http` is not available or not
|
|
1439
|
+
* working (e.g. due to ESM module loading order with `tsx`). It is the
|
|
1440
|
+
* TypeScript equivalent of the Python SDK's `NetraFastAPIMiddleware`.
|
|
1441
|
+
*
|
|
1442
|
+
* **Note:** In Express 4.x, async errors thrown inside downstream handlers are
|
|
1443
|
+
* not automatically caught by the Express error handler. Wrap async route
|
|
1444
|
+
* handlers with your own try/catch or use Express 5 which supports async
|
|
1445
|
+
* error propagation natively.
|
|
1446
|
+
*
|
|
1447
|
+
* @returns An Express middleware function.
|
|
1448
|
+
*
|
|
1449
|
+
* @example
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* import express from "express";
|
|
1452
|
+
* import { netraExpressMiddleware } from "netra-sdk";
|
|
1453
|
+
*
|
|
1454
|
+
* const app = express();
|
|
1455
|
+
* app.use(netraExpressMiddleware());
|
|
1456
|
+
*
|
|
1457
|
+
* app.post("/api/chat", async (req, res) => {
|
|
1458
|
+
* // Spans created here are children of the upstream trace
|
|
1459
|
+
* const result = await myAgent(req.body.message);
|
|
1460
|
+
* res.json(result);
|
|
1461
|
+
* });
|
|
1462
|
+
* ```
|
|
1463
|
+
*/
|
|
1464
|
+
declare function netraExpressMiddleware(): (req: {
|
|
1465
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1466
|
+
}, res: unknown, next: () => void) => void;
|
|
1467
|
+
|
|
1393
1468
|
/**
|
|
1394
1469
|
* Netra SDK - Main entry point
|
|
1395
1470
|
* A comprehensive TypeScript/JavaScript SDK for AI application observability
|
|
@@ -1453,4 +1528,4 @@ declare class Netra {
|
|
|
1453
1528
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1454
1529
|
}
|
|
1455
1530
|
|
|
1456
|
-
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 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, openaiAgentsInstrumentor, span, task, workflow };
|
|
1531
|
+
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 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
|
@@ -1206,13 +1206,12 @@ declare class NetraMistralAIInstrumentor {
|
|
|
1206
1206
|
instrumentationDependencies(): string[];
|
|
1207
1207
|
/**
|
|
1208
1208
|
* Instrument MistralAI client methods (async version)
|
|
1209
|
-
*
|
|
1210
|
-
* that the application uses.
|
|
1209
|
+
* Tries both ESM and CJS resolution to cover dual-package setups.
|
|
1211
1210
|
*/
|
|
1212
1211
|
instrumentAsync(options?: InstrumentorOptions$1): Promise<NetraMistralAIInstrumentor>;
|
|
1213
1212
|
/**
|
|
1214
1213
|
* Instrument MistralAI client methods (sync version - for backwards compatibility)
|
|
1215
|
-
* Note: This uses
|
|
1214
|
+
* Note: This uses cached Mistral classes. Call instrumentAsync() for proper initialization.
|
|
1216
1215
|
*/
|
|
1217
1216
|
instrument(options?: InstrumentorOptions$1): NetraMistralAIInstrumentor;
|
|
1218
1217
|
/**
|
|
@@ -1390,6 +1389,82 @@ declare class TrialAwareOTLPExporter implements SpanExporter {
|
|
|
1390
1389
|
shutdown(): Promise<void>;
|
|
1391
1390
|
}
|
|
1392
1391
|
|
|
1392
|
+
/**
|
|
1393
|
+
* Public helpers for distributed tracing context propagation.
|
|
1394
|
+
*
|
|
1395
|
+
* These utilities let users extract incoming W3C Trace Context from HTTP
|
|
1396
|
+
* headers and run code within that context so that all child spans (LLM
|
|
1397
|
+
* calls, database queries, outgoing HTTP, etc.) are linked to the upstream
|
|
1398
|
+
* trace.
|
|
1399
|
+
*
|
|
1400
|
+
* When `@opentelemetry/instrumentation-http` + `@opentelemetry/instrumentation-express`
|
|
1401
|
+
* are installed and working, incoming context extraction happens automatically.
|
|
1402
|
+
* These helpers cover cases where auto-instrumentation is unavailable (e.g.
|
|
1403
|
+
* ESM module loading order issues, missing peer dependencies, or non-Express
|
|
1404
|
+
* frameworks).
|
|
1405
|
+
*/
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Run a function within a context extracted from HTTP headers.
|
|
1409
|
+
*
|
|
1410
|
+
* All spans created inside `fn` will be children of the trace described by the
|
|
1411
|
+
* incoming `traceparent` / `tracestate` headers, enabling end-to-end
|
|
1412
|
+
* distributed tracing across service boundaries.
|
|
1413
|
+
*
|
|
1414
|
+
* @param headers - Incoming HTTP request headers (e.g. `req.headers`).
|
|
1415
|
+
* @param fn - The function to execute within the extracted context.
|
|
1416
|
+
* May be sync or async -- the return value is forwarded as-is.
|
|
1417
|
+
* @returns The return value of `fn`.
|
|
1418
|
+
*
|
|
1419
|
+
* @example
|
|
1420
|
+
* ```ts
|
|
1421
|
+
* import { runWithExtractedContext } from "netra";
|
|
1422
|
+
*
|
|
1423
|
+
* app.post("/api/chat", async (req, res) => {
|
|
1424
|
+
* await runWithExtractedContext(req.headers, async () => {
|
|
1425
|
+
* const result = await myAgent(req.body.message);
|
|
1426
|
+
* res.json(result);
|
|
1427
|
+
* });
|
|
1428
|
+
* });
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
declare function runWithExtractedContext<T>(headers: Record<string, string | string[] | undefined>, fn: () => T): T;
|
|
1432
|
+
/**
|
|
1433
|
+
* Express/Connect-compatible middleware that extracts W3C Trace Context from
|
|
1434
|
+
* incoming request headers and runs all downstream handlers within the
|
|
1435
|
+
* extracted context.
|
|
1436
|
+
*
|
|
1437
|
+
* This is the recommended way to enable distributed tracing for Express
|
|
1438
|
+
* servers when `@opentelemetry/instrumentation-http` is not available or not
|
|
1439
|
+
* working (e.g. due to ESM module loading order with `tsx`). It is the
|
|
1440
|
+
* TypeScript equivalent of the Python SDK's `NetraFastAPIMiddleware`.
|
|
1441
|
+
*
|
|
1442
|
+
* **Note:** In Express 4.x, async errors thrown inside downstream handlers are
|
|
1443
|
+
* not automatically caught by the Express error handler. Wrap async route
|
|
1444
|
+
* handlers with your own try/catch or use Express 5 which supports async
|
|
1445
|
+
* error propagation natively.
|
|
1446
|
+
*
|
|
1447
|
+
* @returns An Express middleware function.
|
|
1448
|
+
*
|
|
1449
|
+
* @example
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* import express from "express";
|
|
1452
|
+
* import { netraExpressMiddleware } from "netra-sdk";
|
|
1453
|
+
*
|
|
1454
|
+
* const app = express();
|
|
1455
|
+
* app.use(netraExpressMiddleware());
|
|
1456
|
+
*
|
|
1457
|
+
* app.post("/api/chat", async (req, res) => {
|
|
1458
|
+
* // Spans created here are children of the upstream trace
|
|
1459
|
+
* const result = await myAgent(req.body.message);
|
|
1460
|
+
* res.json(result);
|
|
1461
|
+
* });
|
|
1462
|
+
* ```
|
|
1463
|
+
*/
|
|
1464
|
+
declare function netraExpressMiddleware(): (req: {
|
|
1465
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1466
|
+
}, res: unknown, next: () => void) => void;
|
|
1467
|
+
|
|
1393
1468
|
/**
|
|
1394
1469
|
* Netra SDK - Main entry point
|
|
1395
1470
|
* A comprehensive TypeScript/JavaScript SDK for AI application observability
|
|
@@ -1453,4 +1528,4 @@ declare class Netra {
|
|
|
1453
1528
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1454
1529
|
}
|
|
1455
1530
|
|
|
1456
|
-
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 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, openaiAgentsInstrumentor, span, task, workflow };
|
|
1531
|
+
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 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 };
|