MCPcopy
hub / github.com/anomalyco/opencode / toLakeEvent

Function toLakeEvent

packages/console/function/src/log-processor.ts:97–155  ·  view source on GitHub ↗
(time: string, data: Record<string, unknown>)

Source from the content-addressed store, hash-verified

95}
96
97function toLakeEvent(time: string, data: Record<string, unknown>) {
98 return {
99 _datalake_key: "inference.event",
100 event_timestamp: time,
101 event_date: time.slice(0, 10),
102 event_type: string(data, "event_type"),
103 dataset: "zen",
104 cf_continent: string(data, "cf.continent"),
105 cf_country: string(data, "cf.country"),
106 cf_city: string(data, "cf.city"),
107 cf_region: string(data, "cf.region"),
108 cf_latitude: number(data, "cf.latitude"),
109 cf_longitude: number(data, "cf.longitude"),
110 cf_timezone: string(data, "cf.timezone"),
111 duration: number(data, "duration"),
112 request_length: integer(data, "request_length"),
113 status: integer(data, "status"),
114 ip: string(data, "ip"),
115 ip_prefix: string(data, "ip.prefix"),
116 is_stream: boolean(data, "is_stream"),
117 session: string(data, "session"),
118 request: string(data, "request"),
119 client: string(data, "client"),
120 user_agent: string(data, "user_agent"),
121 model: string(data, "model"),
122 model_tier: string(data, "model.tier"),
123 model_variant: string(data, "model.variant"),
124 source: string(data, "source"),
125 provider: string(data, "provider"),
126 provider_model: string(data, "provider.model"),
127 llm_error_code: integer(data, "llm.error.code"),
128 llm_error_message: string(data, "llm.error.message"),
129 error_response: string(data, "error.response"),
130 error_type: string(data, "error.type"),
131 error_message: string(data, "error.message"),
132 error_cause: string(data, "error.cause"),
133 error_cause2: string(data, "error.cause2"),
134 api_key: string(data, "api_key"),
135 workspace: string(data, "workspace"),
136 user_id: string(data, "user_id"),
137 is_subscription: boolean(data, "isSubscription"), // removed
138 subscription: string(data, "subscription"),
139 response_length: integer(data, "response_length"),
140 time_to_first_byte: integer(data, "time_to_first_byte"),
141 timestamp_first_byte: integer(data, "timestamp.first_byte"),
142 timestamp_last_byte: integer(data, "timestamp.last_byte"),
143 tokens_input: integer(data, "tokens.input"),
144 tokens_output: integer(data, "tokens.output"),
145 tokens_reasoning: integer(data, "tokens.reasoning"),
146 tokens_cache_read: integer(data, "tokens.cache_read"),
147 tokens_cache_write_5m: integer(data, "tokens.cache_write_5m"),
148 tokens_cache_write_1h: integer(data, "tokens.cache_write_1h"),
149 cost_input_microcents: integer(data, "cost.input.microcents"),
150 cost_output_microcents: integer(data, "cost.output.microcents"),
151 cost_cache_read_microcents: integer(data, "cost.cache_read.microcents"),
152 cost_cache_write_microcents: integer(data, "cost.cache_write.microcents"),
153 cost_total_microcents: integer(data, "cost.total.microcents"),
154 }

Callers 1

tailFunction · 0.85

Calls 4

stringFunction · 0.70
numberFunction · 0.70
integerFunction · 0.70
booleanFunction · 0.70

Tested by

no test coverage detected