func addLoggingIDsToRequest()

in funcframework/logging.go [36:56]


func addLoggingIDsToRequest(r *http.Request) *http.Request {
	executionID := r.Header.Get("Function-Execution-Id")
	if executionID == "" {
		timestamp := time.Now().UnixNano()
		random := rand.Int63()
		executionID = fmt.Sprintf("%06x%06x", timestamp, random)
	}
	traceID, spanID, _ := deconstructXCloudTraceContext(r.Header.Get("X-Cloud-Trace-Context"))

	if executionID == "" && traceID == "" && spanID == "" {
		return r
	}

	r = r.WithContext(contextWithLoggingIDs(r.Context(), &loggingIDs{
		trace:       traceID,
		spanID:      spanID,
		executionID: executionID,
	}))

	return r
}