MCPcopy Create free account
hub / github.com/coder/coder / extractTimingSpan

Function extractTimingSpan

provisioner/terraform/executor.go:721–748  ·  view source on GitHub ↗
(log *terraformProvisionLog)

Source from the content-addressed store, hash-verified

719}
720
721func extractTimingSpan(log *terraformProvisionLog) (time.Time, *timingSpan, error) {
722 // Input is not well-formed, bail out.
723 if log.Type == "" {
724 return time.Time{}, nil, xerrors.Errorf("invalid timing kind: %q", log.Type)
725 }
726
727 typ := timingKind(log.Type)
728 if !typ.Valid() {
729 return time.Time{}, nil, xerrors.Errorf("unexpected timing kind: %q", log.Type)
730 }
731
732 // Init logs omit millisecond precision, so using `time.Now` as a fallback
733 // for these logs is more precise than parsing the second precision alone.
734 // https://github.com/hashicorp/terraform/pull/37818
735 ts, err := time.Parse("2006-01-02T15:04:05.000000Z07:00", log.Timestamp)
736 if err != nil {
737 // TODO: log
738 ts = time.Now()
739 }
740
741 return ts, &timingSpan{
742 kind: typ,
743 messageCode: log.MessageCode,
744 action: log.Hook.Action,
745 provider: log.Hook.Resource.Provider,
746 resource: log.Hook.Resource.Addr,
747 }, nil
748}
749
750func convertTerraformLogLevel(logLevel string, sink logSink) proto.LogLevel {
751 switch strings.ToLower(logLevel) {

Callers 2

provisionReadAndLogMethod · 0.85
ingestAllSpansFunction · 0.85

Calls 4

timingKindTypeAlias · 0.85
ValidMethod · 0.65
ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

ingestAllSpansFunction · 0.68