MCPcopy Create free account
hub / github.com/InferCore/InferCore / post

Method post

internal/telemetry/otlp_http_exporter.go:149–177  ·  view source on GitHub ↗
(endpoint string, payload map[string]any)

Source from the content-addressed store, hash-verified

147}
148
149func (e *OTLPHTTPExporter) post(endpoint string, payload map[string]any) error {
150 raw, err := json.Marshal(payload)
151 if err != nil {
152 return err
153 }
154
155 var lastErr error
156 for attempt := 0; attempt <= e.retries; attempt++ {
157 req, reqErr := http.NewRequest(http.MethodPost, endpoint, bytes.NewReader(raw))
158 if reqErr != nil {
159 return reqErr
160 }
161 req.Header.Set("Content-Type", "application/json")
162 resp, doErr := e.httpClient.Do(req)
163 if doErr != nil {
164 lastErr = doErr
165 continue
166 }
167 _ = resp.Body.Close()
168 e.mu.Lock()
169 e.lastStatusCode = resp.StatusCode
170 e.mu.Unlock()
171 if resp.StatusCode >= 200 && resp.StatusCode < 300 {
172 return nil
173 }
174 lastErr = fmt.Errorf("otlp http exporter got status %d", resp.StatusCode)
175 }
176 return lastErr
177}
178
179func endpointForKind(base, kind string) string {
180 base = strings.TrimRight(base, "/")

Callers 2

flushMethod · 0.95
inferMethod · 0.80

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected