datanotes 1.3.0 → 1.5.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.
@@ -1,20 +1,24 @@
1
1
  /**
2
- * OTLP/HTTP log export for programs around the engine (MCP servers, apps): records are buffered
3
- * and POSTed as OTLP JSON to `<endpoint>/v1/logs`, the format SigNoz and any OpenTelemetry
4
- * collector read. No dependency, no SDK. Export failures are counted, never thrown: logging must
5
- * not break the program.
2
+ * OpenTelemetry log export over OTLP/HTTP, vendor-neutral: records are buffered and POSTed to
3
+ * `<endpoint>/v1/logs` as `http/protobuf` (the OTLP default) or `http/json`, which every
4
+ * OpenTelemetry collector and OTLP backend reads. No dependency, no SDK. Export failures are
5
+ * counted, never thrown: logging must not break the program. (OTLP over gRPC is not supported:
6
+ * use the collector's HTTP port, 4318 by default.)
6
7
  *
7
- * Configure it in code, or from the standard environment variables with `otlpFromEnv`.
8
+ * Configure it in code, or from the standard OpenTelemetry variables with `otlpFromEnv`.
8
9
  */
9
10
  export type Severity = "DEBUG" | "INFO" | "WARN" | "ERROR";
10
11
  export type AttrValue = string | number | boolean | null | undefined;
12
+ export type OtlpProtocol = "http/protobuf" | "http/json";
11
13
  export interface OtlpOptions {
12
14
  /** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` is added). */
13
15
  endpoint: string;
14
16
  /** `service.name` of the records. */
15
17
  serviceName: string;
16
18
  serviceVersion?: string;
17
- /** Extra headers, e.g. `{"signoz-ingestion-key": "…"}`. */
19
+ /** `http/protobuf` (default) or `http/json`. */
20
+ protocol?: OtlpProtocol;
21
+ /** Extra headers, e.g. an API key or `Authorization`, as the backend asks. */
18
22
  headers?: Record<string, string>;
19
23
  /** More resource attributes (e.g. `host.name`). */
20
24
  resource?: Record<string, AttrValue>;
@@ -22,8 +26,8 @@ export interface OtlpOptions {
22
26
  maxBatch?: number;
23
27
  /** Send the buffer every this many ms (default 5000; 0: only on `flush`). */
24
28
  flushMs?: number;
25
- /** POST a body; resolves on 2xx (default: fetch). */
26
- send?: (url: string, body: string, headers: Record<string, string>) => Promise<void>;
29
+ /** POST a body; resolves on 2xx (default: fetch). `headers` include the Content-Type. */
30
+ send?: (url: string, body: string | Uint8Array, headers: Record<string, string>) => Promise<void>;
27
31
  now?: () => number;
28
32
  }
29
33
  export declare class OtlpLogExporter {
@@ -38,17 +42,24 @@ export declare class OtlpLogExporter {
38
42
  log(severity: Severity, body: string, attributes?: Record<string, AttrValue>): void;
39
43
  /** Send what is buffered. Never rejects. */
40
44
  flush(): Promise<void>;
45
+ private protobuf;
41
46
  /** Stop the timer and send what is left. */
42
47
  close(): Promise<void>;
43
48
  }
44
49
  /** `k1=v1,k2=v2` (values URL-encoded), the format of `OTEL_EXPORTER_OTLP_HEADERS`. */
45
50
  export declare function parseOtlpHeaders(text: string | undefined): Record<string, string>;
51
+ /** `k1=v1,k2=v2` resource attributes, the format of `OTEL_RESOURCE_ATTRIBUTES`. */
52
+ export declare const parseResourceAttributes: typeof parseOtlpHeaders;
46
53
  /**
47
- * Exporter options from the standard OpenTelemetry variables, or null when no endpoint is set:
48
- * `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (full URL of /v1/logs) or `OTEL_EXPORTER_OTLP_ENDPOINT`,
49
- * `OTEL_EXPORTER_OTLP_HEADERS` / `OTEL_EXPORTER_OTLP_LOGS_HEADERS`, `OTEL_SERVICE_NAME`.
54
+ * Exporter options from the standard OpenTelemetry variables, or null when export is off (no
55
+ * endpoint, `OTEL_SDK_DISABLED=true` or `OTEL_LOGS_EXPORTER=none`):
56
+ * `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (full URL of /v1/logs) or `OTEL_EXPORTER_OTLP_ENDPOINT`;
57
+ * `OTEL_EXPORTER_OTLP_[LOGS_]HEADERS`; `OTEL_EXPORTER_OTLP_[LOGS_]PROTOCOL` (`http/protobuf`,
58
+ * `http/json`); `OTEL_SERVICE_NAME`; `OTEL_RESOURCE_ATTRIBUTES`.
50
59
  */
51
60
  export declare function otlpFromEnv(env: Record<string, string | undefined>, defaults: {
52
61
  serviceName: string;
53
62
  serviceVersion?: string;
54
63
  }): OtlpOptions | null;
64
+ /** `http/protobuf` or `http/json` from a setting or variable; undefined for anything else. */
65
+ export declare function otlpProtocol(v: string | undefined): OtlpProtocol | undefined;