observa-sdk 0.0.2 → 0.0.3

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 CHANGED
@@ -427,39 +427,51 @@ var Observa = class {
427
427
  }
428
428
  try {
429
429
  const url = `${this.apiUrl}/api/v1/traces/ingest`;
430
- console.log(`[Observa] Sending trace to: ${url}`);
431
- console.log(`[Observa] Trace ID: ${trace.traceId}`);
432
- console.log(`[Observa] Tenant: ${trace.tenantId}, Project: ${trace.projectId}`);
433
- console.log(`[Observa] API Key present: ${this.apiKey ? "Yes" : "No"} (length: ${this.apiKey?.length || 0})`);
434
- const response = await fetch(url, {
435
- method: "POST",
436
- headers: {
437
- Authorization: `Bearer ${this.apiKey}`,
438
- "Content-Type": "application/json"
439
- },
440
- body: JSON.stringify(trace)
441
- });
442
- console.log(`[Observa] Response status: ${response.status} ${response.statusText}`);
443
- if (!response.ok) {
444
- const errorText = await response.text().catch(() => "Unknown error");
445
- let errorJson;
446
- try {
447
- errorJson = JSON.parse(errorText);
448
- } catch {
449
- errorJson = { error: errorText };
430
+ console.log(`[Observa] Sending trace - URL: ${url}, TraceID: ${trace.traceId}, Tenant: ${trace.tenantId}, Project: ${trace.projectId}, APIKey: ${this.apiKey ? `Yes(${this.apiKey.length} chars)` : "No"}`);
431
+ const controller = new AbortController();
432
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
433
+ try {
434
+ const response = await fetch(url, {
435
+ method: "POST",
436
+ headers: {
437
+ Authorization: `Bearer ${this.apiKey}`,
438
+ "Content-Type": "application/json"
439
+ },
440
+ body: JSON.stringify(trace),
441
+ signal: controller.signal
442
+ });
443
+ clearTimeout(timeoutId);
444
+ console.log(`[Observa] Response status: ${response.status} ${response.statusText}`);
445
+ if (!response.ok) {
446
+ const errorText = await response.text().catch(() => "Unknown error");
447
+ let errorJson;
448
+ try {
449
+ errorJson = JSON.parse(errorText);
450
+ } catch {
451
+ errorJson = { error: errorText };
452
+ }
453
+ console.error(
454
+ `[Observa] Backend API error: ${response.status} ${response.statusText}`,
455
+ errorJson.error || errorText
456
+ );
457
+ } else {
458
+ console.log(`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`);
450
459
  }
451
- console.error(
452
- `[Observa] Backend API error: ${response.status} ${response.statusText}`,
453
- errorJson.error || errorText
454
- );
455
- } else {
456
- console.log(`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`);
460
+ } catch (fetchError) {
461
+ clearTimeout(timeoutId);
462
+ if (fetchError instanceof Error && fetchError.name === "AbortError") {
463
+ console.error("[Observa] Request timeout after 10 seconds");
464
+ }
465
+ throw fetchError;
457
466
  }
458
467
  } catch (error) {
459
468
  console.error("[Observa] Failed to send trace:", error);
460
469
  if (error instanceof Error) {
461
470
  console.error("[Observa] Error message:", error.message);
462
471
  console.error("[Observa] Error name:", error.name);
472
+ if (error.name === "AbortError") {
473
+ console.error("[Observa] Request timed out - check network connectivity and API URL");
474
+ }
463
475
  if (error.stack) {
464
476
  console.error("[Observa] Error stack:", error.stack);
465
477
  }
package/dist/index.js CHANGED
@@ -402,39 +402,51 @@ var Observa = class {
402
402
  }
403
403
  try {
404
404
  const url = `${this.apiUrl}/api/v1/traces/ingest`;
405
- console.log(`[Observa] Sending trace to: ${url}`);
406
- console.log(`[Observa] Trace ID: ${trace.traceId}`);
407
- console.log(`[Observa] Tenant: ${trace.tenantId}, Project: ${trace.projectId}`);
408
- console.log(`[Observa] API Key present: ${this.apiKey ? "Yes" : "No"} (length: ${this.apiKey?.length || 0})`);
409
- const response = await fetch(url, {
410
- method: "POST",
411
- headers: {
412
- Authorization: `Bearer ${this.apiKey}`,
413
- "Content-Type": "application/json"
414
- },
415
- body: JSON.stringify(trace)
416
- });
417
- console.log(`[Observa] Response status: ${response.status} ${response.statusText}`);
418
- if (!response.ok) {
419
- const errorText = await response.text().catch(() => "Unknown error");
420
- let errorJson;
421
- try {
422
- errorJson = JSON.parse(errorText);
423
- } catch {
424
- errorJson = { error: errorText };
405
+ console.log(`[Observa] Sending trace - URL: ${url}, TraceID: ${trace.traceId}, Tenant: ${trace.tenantId}, Project: ${trace.projectId}, APIKey: ${this.apiKey ? `Yes(${this.apiKey.length} chars)` : "No"}`);
406
+ const controller = new AbortController();
407
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
408
+ try {
409
+ const response = await fetch(url, {
410
+ method: "POST",
411
+ headers: {
412
+ Authorization: `Bearer ${this.apiKey}`,
413
+ "Content-Type": "application/json"
414
+ },
415
+ body: JSON.stringify(trace),
416
+ signal: controller.signal
417
+ });
418
+ clearTimeout(timeoutId);
419
+ console.log(`[Observa] Response status: ${response.status} ${response.statusText}`);
420
+ if (!response.ok) {
421
+ const errorText = await response.text().catch(() => "Unknown error");
422
+ let errorJson;
423
+ try {
424
+ errorJson = JSON.parse(errorText);
425
+ } catch {
426
+ errorJson = { error: errorText };
427
+ }
428
+ console.error(
429
+ `[Observa] Backend API error: ${response.status} ${response.statusText}`,
430
+ errorJson.error || errorText
431
+ );
432
+ } else {
433
+ console.log(`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`);
425
434
  }
426
- console.error(
427
- `[Observa] Backend API error: ${response.status} ${response.statusText}`,
428
- errorJson.error || errorText
429
- );
430
- } else {
431
- console.log(`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`);
435
+ } catch (fetchError) {
436
+ clearTimeout(timeoutId);
437
+ if (fetchError instanceof Error && fetchError.name === "AbortError") {
438
+ console.error("[Observa] Request timeout after 10 seconds");
439
+ }
440
+ throw fetchError;
432
441
  }
433
442
  } catch (error) {
434
443
  console.error("[Observa] Failed to send trace:", error);
435
444
  if (error instanceof Error) {
436
445
  console.error("[Observa] Error message:", error.message);
437
446
  console.error("[Observa] Error name:", error.name);
447
+ if (error.name === "AbortError") {
448
+ console.error("[Observa] Request timed out - check network connectivity and API URL");
449
+ }
438
450
  if (error.stack) {
439
451
  console.error("[Observa] Error stack:", error.stack);
440
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "observa-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Enterprise-grade observability SDK for AI applications. Track and monitor LLM interactions with zero friction.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",