Skip to content

desktop/src-tauri/src/otel_receiver.rs

Comment 1, line 1

desktop/src-tauri/src/otel_receiver.rs:1

//! Opt-in local OTLP/HTTP receiver (M5), bound to 127.0.0.1.

Comment 2, line 2

desktop/src-tauri/src/otel_receiver.rs:2

//! /v1/traces accepts OTLP JSON/protobuf; referenced CodeBuddy exports use protobuf.

Comment 3, line 3

desktop/src-tauri/src/otel_receiver.rs:3

//! Normalize per-request spans into adapter-readable JSONL after bounded gzip decoding.

Comment 4, line 4

desktop/src-tauri/src/otel_receiver.rs:4

//! The managed output directory contains otel/spans.jsonl; supplemental logs stay separate.

Comment 5, line 5

desktop/src-tauri/src/otel_receiver.rs:5

//!

Comment 6, line 6

desktop/src-tauri/src/otel_receiver.rs:6

//! Receiver rules (execution.md M5/V22/V25):

Comment 7, line 7

desktop/src-tauri/src/otel_receiver.rs:7

//! - Disabled by default; enabling authorizes this local instance.

Comment 8, line 8

desktop/src-tauri/src/otel_receiver.rs:8

//! - Bind loopback only; verify each source Bearer token against native current-user credential storage.

Comment 9, line 9

desktop/src-tauri/src/otel_receiver.rs:9

//! - Headers <=64 KiB, body <=64 MiB, and decompressed gzip <=64 MiB.

Comment 10, line 10

desktop/src-tauri/src/otel_receiver.rs:10

//! - Retain only named span identity/timing fields and explicitly selected usage/model/session attributes.

Comment 11, line 11

desktop/src-tauri/src/otel_receiver.rs:11

//! Do not accept arbitrary attribute prefixes or persist bodies/credentials.

Comment 12, line 12

desktop/src-tauri/src/otel_receiver.rs:12

//! - Authenticate before body processing; reject browser Origin and forwarded requests.

Comment 13, line 13

desktop/src-tauri/src/otel_receiver.rs:13

//! - Limit all sources together to 120 requests/minute and four active connections; return HTTP 429.

Comment 14, line 21

desktop/src-tauri/src/otel_receiver.rs:21

/// Keep one owned listener; an occupied port belonging to another process is an error.

Comment 15, line 71

desktop/src-tauri/src/otel_receiver.rs:71

/// True only when this call starts a listener, allowing configuration rollback to stop its own listener.

Comment 16, line 107

desktop/src-tauri/src/otel_receiver.rs:107

/// Maximum body bytes.

Comment 17, line 109

desktop/src-tauri/src/otel_receiver.rs:109

/// Maximum header bytes.

Comment 18, line 111

desktop/src-tauri/src/otel_receiver.rs:111

/// Maximum decompressed gzip bytes.

Comment 19, line 113

desktop/src-tauri/src/otel_receiver.rs:113

/// Exact keys consumed by the checked span adapter; review new attributes before adding them.

Comment 20, line 142

desktop/src-tauri/src/otel_receiver.rs:142

/// Maximum scalar string bytes; discard oversized values instead of persisting body-like text.

Comment 21, line 145

desktop/src-tauri/src/otel_receiver.rs:145

/// Start the test receiver thread; return bind errors, and exit the thread with the process.

Comment 22, line 199

desktop/src-tauri/src/otel_receiver.rs:199

// Explicit FIN and bounded input draining preserve the response

Comment 23, line 200

desktop/src-tauri/src/otel_receiver.rs:200

// during Winsock connection shutdown.

Comment 24, line 201

desktop/src-tauri/src/otel_receiver.rs:201

// Rejected input is neither parsed nor persisted.

Comment 25, line 249

desktop/src-tauri/src/otel_receiver.rs:249

/// Handle one HTTP request per connection, then close the connection.

Comment 26, line 255

desktop/src-tauri/src/otel_receiver.rs:255

// Restore blocking reads/writes explicitly after accepting from a nonblocking listener.

Comment 27, line 260

desktop/src-tauri/src/otel_receiver.rs:260

// Read until headers end or the configured size limit is reached.

Comment 28, line 396

desktop/src-tauri/src/otel_receiver.rs:396

// Non-JSON content uses protobuf, the referenced CodeBuddy export encoding.

Comment 29, line 405

desktop/src-tauri/src/otel_receiver.rs:405

// Supplemental logs are not auto-scanned as spans or added to native session usage.

Comment 30, line 657

desktop/src-tauri/src/otel_receiver.rs:657

/// Flatten only explicitly permitted attribute values.

Comment 31, line 667

desktop/src-tauri/src/otel_receiver.rs:667

// Convert OTLP AnyValue string/int/double/bool values to scalars.

Comment 32, line 704

desktop/src-tauri/src/otel_receiver.rs:704

/// Normalize OTLP JSON ExportTraceServiceRequest to span records.

Comment 33, line 745

desktop/src-tauri/src/otel_receiver.rs:745

/// Map OTLP numeric span kind to its name.

Comment 34, line 791

desktop/src-tauri/src/otel_receiver.rs:791

// Preserve span-level status metadata separately from filtered attributes.

Comment 35, line 792

desktop/src-tauri/src/otel_receiver.rs:792

// ERROR lets the adapter mark error_status without reporting failed calls as successful.

Comment 36, line 812

desktop/src-tauri/src/otel_receiver.rs:812

// Parse ExportTraceServiceRequest protobuf wire fields.

Comment 37, line 818

desktop/src-tauri/src/otel_receiver.rs:818

// A u64 protobuf varint permits only 0/1 in byte ten; larger values are malformed.

Comment 38, line 884

desktop/src-tauri/src/otel_receiver.rs:884

/// Decode protobuf KeyValue into a key and scalar value.

Comment 39, line 920

desktop/src-tauri/src/otel_receiver.rs:920

/// Normalize OTLP protobuf body to span records.

Comment 40, line 989

desktop/src-tauri/src/otel_receiver.rs:989

// Status submessage field 2 is code; enum 2 means ERROR.

Comment 41, line 1190

desktop/src-tauri/src/otel_receiver.rs:1190

// Retain selected usage.* fields; discard bodies and oversized strings.

Comment 42, line 1222

desktop/src-tauri/src/otel_receiver.rs:1222

// Test span: ID 0xab, model_stream name, fixed64 start, usage.input_tokens=100.

Comment 43, line 1224

desktop/src-tauri/src/otel_receiver.rs:1224

// AnyValue int_value is protobuf field 3.

Comment 44, line 1238

desktop/src-tauri/src/otel_receiver.rs:1238

// Resource field 1 repeats KeyValue; its fields 1/2 hold key/AnyValue.

Comment 45, line 1241

desktop/src-tauri/src/otel_receiver.rs:1241

// AnyValue stringValue uses field 1 with length-delimited wire type 2.

Comment 46, line 1274

desktop/src-tauri/src/otel_receiver.rs:1274

// Start on a high port derived from the process ID.

Comment 47, line 1294

desktop/src-tauri/src/otel_receiver.rs:1294

// Wait with bounded polling for the receiver thread to write the file.

Comment 48, line 1303

desktop/src-tauri/src/otel_receiver.rs:1303

// Scan the written file with the otel adapter.

Comment 49, line 1427

desktop/src-tauri/src/otel_receiver.rs:1427

// HTTP clients use Content-Length instead of waiting for EOF

Comment 50, line 1428

desktop/src-tauri/src/otel_receiver.rs:1428

// when unread rejected input can cause a socket reset.

Comment 51, line 1561

desktop/src-tauri/src/otel_receiver.rs:1561

// A huge declared body sends no bytes; authentication must still respond immediately.

Comment 52, line 1605

desktop/src-tauri/src/otel_receiver.rs:1605

// Preserve status.code=ERROR for adapter error_status.

Comment 53, line 1610

desktop/src-tauri/src/otel_receiver.rs:1610

// Spans without status omit that key.

Comment 54, line 1640

desktop/src-tauri/src/otel_receiver.rs:1640

// Status field 2 varint ERROR=2 is nested in Span field 15.

Comment 55, line 1659

desktop/src-tauri/src/otel_receiver.rs:1659

// Reject varint byte ten above 1 instead of truncating high bits.