MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / SendLogData

Function SendLogData

lib/cronitor.go:415–454  ·  view source on GitHub ↗
(apiKey string, monitorKey string, seriesID string, outputLogs string)

Source from the content-addressed store, hash-verified

413}
414
415func SendLogData(apiKey string, monitorKey string, seriesID string, outputLogs string) ([]byte, error) {
416 gzippedLogs := gzipLogData(outputLogs)
417 jsonBytes, err := json.Marshal(map[string]string{
418 "job_key": monitorKey,
419 "series": seriesID,
420 })
421 if err != nil {
422 return nil, errors.Wrap(err, "couldn't encode job and series IDs to JSON")
423 }
424
425 var responseJson struct {
426 Url string `json:"url"`
427 }
428 response, err := getPresignedUrl(apiKey, jsonBytes)
429 if err != nil {
430 return nil, errors.Wrap(err, "error generating presign url for log uploading")
431 }
432 if err := json.Unmarshal(response, &responseJson); err != nil {
433 return nil, err
434 }
435
436 s3LogPutUrl := responseJson.Url
437 if len(s3LogPutUrl) == 0 {
438 return nil, errors.New("no presigned S3 url returned. Something is wrong")
439 }
440 req, err := http.NewRequest("PUT", s3LogPutUrl, gzippedLogs)
441 if err != nil {
442 return nil, err
443 }
444 client := &http.Client{
445 Timeout: 120 * time.Second,
446 }
447 resp, err := client.Do(req)
448 if err != nil {
449 return nil, err
450 }
451 defer resp.Body.Close()
452
453 return ioutil.ReadAll(resp.Body)
454}
455
456func (api CronitorApi) Signup(name string, email string, password string) (*SignupResponse, error) {
457 payload := fmt.Sprintf("fullname=%s&email=%s&password=%s",

Callers 2

shipLogDataFunction · 0.92
shipLogDataForDashFunction · 0.92

Calls 3

gzipLogDataFunction · 0.85
getPresignedUrlFunction · 0.85
CloseMethod · 0.80

Tested by

no test coverage detected