MCPcopy
hub / github.com/cortexlabs/cortex / EventFromException

Function EventFromException

pkg/lib/telemetry/telemetry.go:190–218  ·  view source on GitHub ↗
(exception error)

Source from the content-addressed store, hash-verified

188}
189
190func EventFromException(exception error) *sentry.Event {
191 stacktrace := sentry.ExtractStacktrace(exception)
192
193 if stacktrace == nil {
194 stacktrace = sentry.NewStacktrace()
195 }
196
197 errTypeString := reflect.TypeOf(errors.CauseOrSelf(exception)).String()
198
199 errKind := errors.GetKind(exception)
200 if errKind != "" && errKind != errors.ErrNotCortexError {
201 errTypeString = errKind
202 }
203
204 event := sentry.NewEvent()
205 event.Level = sentry.LevelError
206
207 value := errors.Message(exception)
208 if metadata := errors.GetMetadata(exception); metadata != nil {
209 value = value + "\n\n########## metadata ##########\n" + s.ObjStripped(metadata)
210 }
211
212 event.Exception = []sentry.Exception{{
213 Value: value,
214 Type: errTypeString,
215 Stacktrace: stacktrace,
216 }}
217 return event
218}
219
220func RecordOperatorID(clientID string, operatorID string) {
221 if _config == nil || !_config.Enabled || strings.ToLower(os.Getenv("CORTEX_TELEMETRY_DISABLE")) == "true" {

Callers 1

ErrorFunction · 0.85

Calls 5

CauseOrSelfFunction · 0.92
GetKindFunction · 0.92
MessageFunction · 0.92
GetMetadataFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected