1

Go에서 Stackdriver 오류보고에 오류를 기록하려고합니다. 오류보고의 첫 번째 페이지에는 "응용 프로그램 오류를 Google 스택 드라이버 로깅에 기록하거나 ..."(https://cloud.google.com/error-reporting/docs/)로 표시 할 수 있습니다. Go 클라이언트 라이브러리로 어떻게 할 수 있습니까? Stackdriver 로깅에 오류를 기록하는 방법 Stackdriver 로깅을 통해 오류를보고하는 방법

로깅 라이브러리가 제공하는 Entry

는 다음과 같이 구성된다 :

github.com/GoogleCloudPlatform/.../logging.go#L412

type Entry struct { 
    Timestamp time.Time 
    Severity Severity 
    Payload interface{} 
    Labels map[string]string 
    InsertID string 
    HTTPRequest *HTTPRequest 
    Operation *logpb.LogEntryOperation 
    LogName string 
    Resource *mrpb.MonitoredResource 
} 

내가 페이로드에 this JSON 구조를 마샬링해야합니까? 또는 stacktrace를 문자열로 삽입 할 수 있습니까? docs에서

답변

2

이것을 달성하는 데 도움이되는 a dedicated Go package이 있습니다. import "cloud.google.com/go/errors"

Stackdriver Logging을 통해 오류를보고하도록 구성 할 수 있으며 올바른 로그 구조를 전송할 수 있습니다.

1

:

// Payload must be either a string or something that 
// marshals via the encoding/json package to a JSON object 
// (and not any other type of JSON value). 

문자열 갈 방법이기 때문에 스택 트레이스를 삽입하는 것 같은데.